diff --git a/.codespellrc b/.codespellrc index 5782ae4..409cb11 100644 --- a/.codespellrc +++ b/.codespellrc @@ -1,7 +1,7 @@ [codespell] # Ref: https://github.com/codespell-project/codespell#using-a-config-file -skip = .git*,*.svg,package-lock.json,*.css,*-min.*,.codespellrc,*.bundle.*,*.map +skip = .git*,*.svg,package-lock.json,*.css,*-min.*,.codespellrc,*.bundle.*,*.map, *.js check-hidden = true -# ignore-regex = +# ignore-regex = # some favorite albeit unfortunate variable names ignore-words-list = te diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3668fdd..73bc890 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,4 +14,3 @@ repos: rev: v2.3.0 hooks: - id: codespell - diff --git a/neuvue_project/neuvue/settings.py b/neuvue_project/neuvue/settings.py index 949e73f..cfdd1f4 100644 --- a/neuvue_project/neuvue/settings.py +++ b/neuvue_project/neuvue/settings.py @@ -9,6 +9,7 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.2/ref/settings/ """ + import os # Build paths inside the project like this: BASE_DIR / 'subdir'. @@ -24,6 +25,8 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False +SITE_ID = 2 + ALLOWED_HOSTS = [ ".neuvue.io", ".elasticbeanstalk.com", @@ -242,4 +245,7 @@ mimetypes.add_type("application/javascript", ".js", True) -STATIC_NG_FILES = os.listdir(os.path.join(BASE_DIR, "workspace", "static", "workspace")) +STATIC_NG_FILES = os.listdir( + os.path.join(BASE_DIR, "workspace", "static", "workspace") +) + os.listdir(os.path.join(BASE_DIR, "workspace", "static", "spelunker-workspace")) +# STATIC_NG_FILES = os.listdir(os.path.join(BASE_DIR, "workspace", "static", "workspace-spelunker")) diff --git a/neuvue_project/neuvue/urls.py b/neuvue_project/neuvue/urls.py index de107ea..8ac2a15 100644 --- a/neuvue_project/neuvue/urls.py +++ b/neuvue_project/neuvue/urls.py @@ -47,6 +47,11 @@ path("tasks/", TaskView.as_view(), name="tasks"), path("getting-started/", GettingStartedView.as_view(), name="getting-started"), path("workspace/", WorkspaceView.as_view(), name="workspace"), + path( + "spelunker-workspace/", + WorkspaceView.as_view(), + name="spelunker-workspace", + ), path("admin/", admin.site.urls), path("__debug__/", include("debug_toolbar.urls")), path("accounts/", include("allauth.urls")), diff --git a/neuvue_project/neuvueDB.sqlite3 b/neuvue_project/neuvueDB.sqlite3 index 8c6c3df..016babc 100644 Binary files a/neuvue_project/neuvueDB.sqlite3 and b/neuvue_project/neuvueDB.sqlite3 differ diff --git a/neuvue_project/templates/about.html b/neuvue_project/templates/about.html index 0e8fa7d..b7fc105 100644 --- a/neuvue_project/templates/about.html +++ b/neuvue_project/templates/about.html @@ -82,7 +82,7 @@

Collaborators

Contact Us

- We'd love to hear from you! Reach out at info@neuvue.io with questions or if you are interested in collaborating with us. + We'd love to hear from you! Reach out at info@bossdb.org with questions or if you are interested in collaborating with us.

diff --git a/neuvue_project/templates/inspect.html b/neuvue_project/templates/inspect.html index 81b0dcf..7712dff 100644 --- a/neuvue_project/templates/inspect.html +++ b/neuvue_project/templates/inspect.html @@ -101,7 +101,11 @@

Inspect Task

- +{% if ng_host == "spelunker" %} + +{% else %} + +{% endif %} {% endif%} @@ -111,18 +115,41 @@

Inspect Task

+ +{% if ng_host == "spelunker" %} + +{% else %} +{% endif %} + + + +

This page is a placeholder for Keycloak redirection.

+

+ + diff --git a/neuvue_project/workspace/static/spelunker-workspace/compresso.0d45ed2ede4537f701f8.wasm b/neuvue_project/workspace/static/spelunker-workspace/compresso.0d45ed2ede4537f701f8.wasm new file mode 100644 index 0000000..748ebb3 Binary files /dev/null and b/neuvue_project/workspace/static/spelunker-workspace/compresso.0d45ed2ede4537f701f8.wasm differ diff --git a/neuvue_project/workspace/static/spelunker-workspace/google_oauth2_redirect.html b/neuvue_project/workspace/static/spelunker-workspace/google_oauth2_redirect.html new file mode 100644 index 0000000..d1a777d --- /dev/null +++ b/neuvue_project/workspace/static/spelunker-workspace/google_oauth2_redirect.html @@ -0,0 +1,21 @@ + + + + Google oauth redirect + + + +

Google authentication successful.

+

+ + diff --git a/neuvue_project/workspace/static/spelunker-workspace/index.html b/neuvue_project/workspace/static/spelunker-workspace/index.html new file mode 100644 index 0000000..6d30448 --- /dev/null +++ b/neuvue_project/workspace/static/spelunker-workspace/index.html @@ -0,0 +1 @@ +Neuroglancer \ No newline at end of file diff --git a/neuvue_project/workspace/static/spelunker-workspace/libpng.4e1203f419dab329d4f3.wasm b/neuvue_project/workspace/static/spelunker-workspace/libpng.4e1203f419dab329d4f3.wasm new file mode 100644 index 0000000..06c63a5 Binary files /dev/null and b/neuvue_project/workspace/static/spelunker-workspace/libpng.4e1203f419dab329d4f3.wasm differ diff --git a/neuvue_project/workspace/static/spelunker-workspace/main.cb26101b553ed6b82856.css b/neuvue_project/workspace/static/spelunker-workspace/main.cb26101b553ed6b82856.css new file mode 100644 index 0000000..f0bf9d3 --- /dev/null +++ b/neuvue_project/workspace/static/spelunker-workspace/main.cb26101b553ed6b82856.css @@ -0,0 +1,115 @@ +.neuroglancer-annotation-rendering-tab{display:flex;flex-direction:column;overflow-y:auto}.neuroglancer-annotation-rendering-tab .neuroglancer-shader-code-widget{flex-shrink:0}.neuroglancer-annotation-shader-property-list{max-height:8em;overflow:auto;flex-shrink:0}.neuroglancer-annotation-shader-property{white-space:pre;font-family:monospace;font-size:medium}.neuroglancer-annotation-shader-property-type{color:#c6c;margin-right:1ch}.neuroglancer-annotation-shader-property-identifier{user-select:text}.neuroglancer-annotation-shader-property-identifier:after{content:"()";color:#999}.neuroglancer-annotation-tag-property-type{color:#999}.neuroglancer-tag-list>div{display:grid}.neuroglancer-add-tag-control>input,.neuroglancer-tag-list-entry>input{background-color:#151515;color:#fff;font-family:monospace;font-size:medium;border:2px solid #333;padding:2px;outline:0px}.neuroglancer-tags-container{display:flex;flex-direction:column;flex:1;align-items:stretch}.neuroglancer-tag-list-outer{position:relative;margin:2px 0 0;padding:0;overflow-y:auto;height:0px;flex:1;flex-basis:0px;min-height:0px}.neuroglancer-tag-list-entry{display:grid;grid-template-columns:min-content auto min-content;align-items:center;white-space:nowrap;padding:2px 20px 2px 0}.neuroglancer-tag-list-entry.add .neuroglancer-tool-button{visibility:hidden}.neuroglancer-tag-list-entry:hover .neuroglancer-tag-list-entry-delete{visibility:visible}.neuroglancer-tag-list-entry .neuroglancer-tag-list-entry-delete{visibility:hidden}/** + * @license + * Copyright 2024 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */.neuroglancer-transfer-function-panel{height:60px;border:1px solid #666;margin-top:5px}.neuroglancer-transfer-function-color-picker{text-align:right}.neuroglancer-transfer-function-widget-bound{background-color:transparent;border-color:transparent;box-shadow:none;border:0;margin:0;font-family:monospace;font-size:medium;color:#0ff}.neuroglancer-transfer-function-window-bounds{display:flex;justify-content:space-between}.neuroglancer-invlerp-cdfpanel{height:50px;cursor:ew-resize}.neuroglancer-invlerp-cdfpanel,.neuroglancer-invlerp-legend-panel{border:1px solid #666}.neuroglancer-invlerp-legend-panel{height:15px}.neuroglancer-invlerp-widget-bound{background-color:transparent;border-color:transparent;box-shadow:none;border:0;margin:0;font-family:monospace;font-size:medium}.neuroglancer-invlerp-widget-window-bound{color:#0ff}.neuroglancer-invlerp-widget-range-bound{color:#fff}.neuroglancer-invlerp-widget-bounds{display:flex}.neuroglancer-invlerp-widget-range-spacer{flex:1;text-align:center}.neuroglancer-invlerp-widget-window-bounds{justify-content:space-between}.neuroglancer-icon{display:inline-flex;text-decoration:none;align-self:center;white-space:nowrap;padding-left:2px;padding-right:2px;min-width:18px;min-height:18px;border-radius:20%;align-items:center;justify-content:center;color:#fff;font:12px sans-serif;cursor:pointer;font-weight:900;margin-left:1px;margin-right:1px;user-select:none}.neuroglancer-icon svg{width:16px;height:16px;fill:transparent;stroke:#fff;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}.neuroglancer-icon:hover{background-color:#db4437}.neuroglancer-icon-hover:not(:hover) svg:last-child{display:none}.neuroglancer-icon-hover:hover svg:first-child{display:none}.neuroglancer-tab-view{display:flex;flex-direction:column}.neuroglancer-tab-view-bar{display:block;background-color:#333;border-bottom:1px solid white}.neuroglancer-tab-label{display:inline-block;border-top:1px solid transparent;border-left:1px solid transparent;border-right:1px solid transparent;border-bottom:none;margin-right:4px;padding-top:1px;padding-left:2px;padding-right:2px;font:10pt sans-serif;font-weight:700;cursor:pointer}.neuroglancer-tab-label:hover{color:#daa520}.neuroglancer-tab-label.neuroglancer-selected-tab-label{background-color:#000;border-top:1px solid white;border-left:1px solid white;border-right:1px solid white;border-bottom:1px solid black;padding-bottom:1px;margin-bottom:-1px}.neuroglancer-stack-view{display:contents}.neuroglancer-tab-view>.neuroglancer-stack-view>.neuroglancer-tab-content{flex:1;flex-basis:0px;height:0px;min-height:0px;padding:2px}.neuroglancer-position-widget{display:inline-flex;align-items:center}.neuroglancer-position-widget input:disabled{pointer-events:none}.neuroglancer-position-widget .neuroglancer-copy-button:first-child{display:none}.neuroglancer-position-dimension-coordinate,.neuroglancer-position-dimension-name,.neuroglancer-position-dimension-scale{background-color:transparent;border-color:transparent;box-shadow:none;border:0;margin:0;font-family:monospace;font-size:medium}.neuroglancer-position-dimension[data-coordinate-array=valid] .neuroglancer-position-dimension-scale{display:none}.neuroglancer-position-dimension[data-coordinate-array=invalid] .neuroglancer-position-dimension-scale{text-decoration-line:underline;text-decoration-style:wavy;text-decoration-color:red}.neuroglancer-position-dimension-coordinate{color:#fff;text-align:right}.neuroglancer-position-widget input:invalid,.neuroglancer-position-widget input::placeholder,.neuroglancer-position-widget input[data-is-valid=false]{text-decoration:solid underline red}.neuroglancer-position-widget *:focus{outline:0px}.neuroglancer-position-dimension+.neuroglancer-position-dimension{margin-left:1ch}.neuroglancer-position-dimension[data-dropdown-visible=true]:after{content:"";display:block;left:0;right:0;bottom:-1px;position:absolute;border-bottom:1px solid black;z-index:100;height:0px}.neuroglancer-position-dimension-dropdown,.neuroglancer-position-dimension-coordinate-dropdown{position:absolute;min-width:calc(100% + 2px);border:1px solid #aaa;box-sizing:border-box;padding:2px;left:-1px;z-index:100;background-color:#000}.neuroglancer-position-dimension-coordinate-dropdown{display:flex;flex-direction:column;overflow-y:auto}.neuroglancer-dimension-dropdown-coordinate-entry{display:flex;flex-direction:row;justify-content:space-between}.neuroglancer-dimension-dropdown-coordinate-entry:hover{background-color:#333}.neuroglancer-dimension-dropdown-coordinate-label{width:var(--neuroglancer-coordinate-label-width);color:#0ff}.neuroglancer-position-dimension-dropdown:focus,.neuroglancer-position-dimension-coordinate-dropdown:focus{outline:0px}.neuroglancer-position-dimension:focus-within,.neuroglancer-position-dimension[data-dropdown-visible=true]{border:1px solid #aaa;background-color:#000}.neuroglancer-position-dimension{border:1px solid transparent;position:relative;display:inline-block;white-space:nowrap}.neuroglancer-position-dimension-name{color:#ff6;padding-left:2px}.neuroglancer-position-dimension-scale-container[data-is-empty=false]:before{content:"(";color:#aaa}.neuroglancer-position-dimension-scale-container[data-is-empty=false]:after{content:")";color:#aaa}.neuroglancer-position-dimension-scale-container[data-is-empty=false]{margin-right:5px}.neuroglancer-position-dimension-scale{color:#bbb}.neuroglancer-position-dimension-scale-container{margin-right:2px;margin-left:4px}.neuroglancer-mouse-position-widget{margin-left:1ch;vertical-align:center;font-family:monospace;font-size:medium;color:orange;white-space:pre}.neuroglancer-position-dimension-coordinate-label{display:inline-block;color:#0ff}.neuroglancer-position-dimension-coordinate-label:not(:empty):before{content:"[";color:#aaa}.neuroglancer-position-dimension-coordinate-label:not(:empty):after{content:"]";color:#aaa}.neuroglancer-position-dimension-playback{font-family:sans-serif;font-size:10pt;display:flex;flex-direction:column}.neuroglancer-position-dimension-playback .neuroglancer-number-input{display:flex;flex-direction:row;align-items:center;margin-bottom:2px}.neuroglancer-position-dimension-playback input[type=text]{background-color:#ffffff4d;color:#fff;border:0px;font-family:monospace;width:8ch;text-align:right}.neuroglancer-position-dimension-playback select{align-self:center}.neuroglancer-position-dimension>.neuroglancer-icon{min-width:14px;min-height:14px;position:relative;top:1px}.neuroglancer-position-dimension>.neuroglancer-icon svg{width:12px;height:12px}.neuroglancer-position-tool{background-color:#474747}.neuroglancer-position-dimension-playback-header{display:flex;flex-direction:row;align-items:center}#statusContainer{position:absolute;bottom:0;z-index:100;background-color:gray;color:#fff;margin:0;padding:0;font:10pt sans-serif}#statusContainer li{width:100vw;max-height:25vh;overflow-y:auto}.neuroglancer-status-header{display:inline-block;font:10pt sans-serif;font-weight:700;background-color:#333;padding:2px}#statusContainerModal{pointer-events:none;position:absolute;z-index:100;color:#fff;margin:0;padding:0;font:10pt sans-serif;display:grid;align-content:center;justify-content:center;height:100vh;width:80vw;left:10vw;grid-row-gap:10px}#statusContainerModal>div{pointer-events:initial;position:relative;background-color:gray;padding:30px 20px 20px}#statusContainerModal>div>div:first-child{position:absolute;top:4px;right:4px;margin:0;padding:0}#statusContainerModal li{display:block}.neuroglancer-tool-key-binding{display:inline-block;color:#0ff;font:9pt monospace;white-space:pre}.neuroglancer-tool-key-binding:hover{outline:1px solid #fff}.neuroglancer-tool-key-binding:before{content:"["}.neuroglancer-tool-key-binding:after{content:"]"}.neuroglancer-tool-key-binding:before,.neuroglancer-tool-key-binding:after{color:#999}.neuroglancer-tool-button{display:inline-flex;flex-direction:row}#statusContainer li.neuroglancer-tool-status{max-height:50vh}.neuroglancer-tool-status-bindings{background-color:#333;user-select:none}.neuroglancer-tool-status-content{display:flex;flex-direction:row}.neuroglancer-tool-status-header-container{background-color:#555;width:min-content;padding:3px;display:flex;flex-direction:row;align-items:center}.neuroglancer-tool-status-header{align-self:center}.neuroglancer-tool-status-body{flex:1;padding:2px}.neuroglancer-checkbox-icon.light-background[data-checked=true]{background-color:#00000080}.neuroglancer-checkbox-icon.dark-background[data-checked=true]{background-color:#fff3}.neuroglancer-position-dimension-plot{display:grid;overflow:hidden;position:relative}.neuroglancer-position-dimension-plot[data-orientation=column]{grid-template-areas:"labels . graph";grid-template-rows:1fr;grid-template-columns:0fr 3px 0fr}.neuroglancer-position-dimension-plot[data-orientation=row]{grid-template-areas:"labels" "." "graph";grid-template-columns:minmax(0px,1fr);grid-template-rows:0fr 3px 0fr}.neuroglancer-position-dimension-plot-lowerbound,.neuroglancer-position-dimension-plot-upperbound,.neuroglancer-position-dimension-plot-hoverposition{grid-area:labels;font-family:monospace;font-size:medium;user-select:none}.neuroglancer-position-dimension-plot[data-orientation=column] :is(.neuroglancer-position-dimension-plot-lowerbound,.neuroglancer-position-dimension-plot-upperbound,.neuroglancer-position-dimension-plot-hoverposition){text-align:right}.neuroglancer-position-dimension-plot[data-orientation=row] :is(.neuroglancer-position-dimension-plot-lowerbound,.neuroglancer-position-dimension-plot-upperbound,.neuroglancer-position-dimension-plot-hoverposition){max-width:max-content}.neuroglancer-position-dimension-plot>canvas{grid-area:graph}.neuroglancer-position-dimension-plot[data-orientation=column]>canvas{margin-top:.5em;margin-bottom:.5em}.neuroglancer-segmentation-rendering-tab{display:flex;flex-direction:column;overflow-y:auto}.neuroglancer-segmentation-rendering-tab .neuroglancer-shader-code-widget{height:6em}.neuroglancer-segmentation-dropdown-skeleton-shader-header{display:flex;flex-direction:row;align-items:center}.neuroglancer-segmentation-layer-skeleton-shader-overlay .neuroglancer-shader-code-widget{width:80vw;height:80vh}.neuroglancer-segment-list-entry{display:flex;flex-direction:row;width:min-content;min-width:100%;background-color:#000;align-items:start}.neuroglancer-segment-list-entry.neuroglancer-segment-list-entry-double-line{display:inline-flex;min-width:initial;background-color:initial}.neuroglancer-segment-list-entry[data-selected=true],.neuroglancer-selection-details-segment[data-selected=true]{background-color:#222}.neuroglancer-segment-list-entry-copy-container{display:flex;flex-direction:column}.neuroglancer-segment-list-entry-id-container{order:1;align-self:center}.neuroglancer-segment-list-entry-id,.neuroglancer-selection-details-segment-id{display:block;font-family:monospace;font-size:medium;flex-shrink:0;text-align:right;color:#000;background-color:#fff;user-select:text;width:var(--neuroglancer-segment-list-width)}.neuroglancer-segment-list .neuroglancer-segment-list-entry-sticky{position:sticky;left:0}.neuroglancer-segment-list-entry-sticky{white-space:nowrap;flex-direction:row;align-items:start;background-color:inherit;display:flex}.neuroglancer-segment-list-entry.neuroglancer-segment-list-header .neuroglancer-segment-list-entry-star,.neuroglancer-segment-list-entry.neuroglancer-segment-list-header:hover .neuroglancer-segment-list-entry-copy{visibility:hidden}.neuroglancer-segment-list-entry-extra-property{padding-left:8px;flex-shrink:0;text-align:right;user-select:text}.neuroglancer-selection-details-segment-description,.neuroglancer-selection-details-segment-property{font-family:sans-serif;font-size:small}.neuroglancer-selection-details-segment-property{display:flex;flex-direction:row}.neuroglancer-selection-details-segment-property-name{user-select:text;font-style:italic}.neuroglancer-selection-details-segment-property-value{text-align:right;flex:1}.neuroglancer-segmentation-toolbox{display:inline-block}.neuroglancer-segmentation-toolbox .neuroglancer-tool-button+.neuroglancer-tool-button{margin-left:1em}.neuroglancer-segment-list-entry .neuroglancer-color-widget{border:none;border-color:transparent;appearance:none;background-color:transparent;padding:0;margin:0 0 0 3px;height:19px;width:20px}.neuroglancer-segment-list-entry .neuroglancer-color-widget.overridden{background-color:#fff}.neuroglancer-layer-options-control-container .neuroglancer-layer-control-label-container{margin-right:auto}.neuroglancer-layer-control-label-container{white-space:nowrap}.neuroglancer-layer-control-label{display:flex;flex-direction:row;align-items:center}.neuroglancer-layer-control-label-text-container{display:flex;flex-direction:row;align-items:start}.neuroglancer-layer-control-container{margin-top:1.5px;margin-bottom:1.5px;display:flex;flex-direction:row;align-items:center}.neuroglancer-layer-control-control{flex:1;margin-left:5px;max-width:500px}select.neuroglancer-layer-control-control,input[type=checkbox].neuroglancer-layer-control-control,input[type=color].neuroglancer-layer-control-control{flex:initial}.range-slider{display:flex;flex-direction:row;white-space:nowrap;justify-content:flex-end}.range-slider input[type=range]{background:transparent;flex-basis:0px}.range-slider input[type=number]{background-color:#ffffff4d;color:#fff;border:0px}.range-slider input[type=range]::-moz-range-track{background-color:#fff}.neuroglancer-render-scale-widget{margin-top:2px;margin-bottom:2px;display:flex;flex-direction:row;align-items:center}.neuroglancer-render-scale-widget-prompt{white-space:nowrap}.neuroglancer-render-scale-widget>canvas{height:36px;flex:1;flex-basis:0px;width:0px}.neuroglancer-render-scale-widget-legend{width:15ch;font-size:11px;text-align:right}.neuroglancer-render-scale-widget-legend>div{height:12px}.neuroglancer-segmentation-color-seed-control{display:flex;flex-direction:row;align-items:center;justify-content:flex-end}.neuroglancer-segmentation-color-seed-control input{background-color:#ffffff4d;color:#fff;border:0px}.neuroglancer-selection-details-body{height:0px;flex:1;overflow-y:auto;flex-basis:0px;min-height:0px}.neuroglancer-selection-details-position{display:flex;flex-direction:row;align-items:center;justify-items:left;font-family:monospace;font-size:medium}.neuroglancer-selection-details-position-dimension+.neuroglancer-selection-details-position-dimension{margin-left:8px}.neuroglancer-selection-details-position-dimension-name{color:#ff6}.neuroglancer-selection-details-position-dimension-coordinate{margin-left:5px;user-select:text}.neuroglancer-selection-details-layer{margin-top:4px;margin-bottom:4px;border:1px solid #222}.neuroglancer-selection-details-layer-title{cursor:pointer;background-color:#222;font-family:sans-serif;font-size:10pt}.neuroglancer-selection-details-layer-title:hover{background-color:#333}.neuroglancer-selection-details-layer-body{padding:2px;display:flex;flex-direction:column}.neuroglancer-side-panel-column{display:flex;flex-direction:column;min-width:0px}.neuroglancer-side-panel-row{display:flex;flex-direction:row;min-height:0px}.neuroglancer-side-panel{display:flex;flex-direction:column;min-width:0px;overflow:hidden}.neuroglancer-side-panel-titlebar{display:flex;flex-direction:row;align-items:center;font-family:sans-serif;font-size:10pt;background-color:#03c;padding:2px;color:#fff}.neuroglancer-side-panel-title{flex:1;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.neuroglancer-side-panel-drop-zone{z-index:1000;display:none}[data-neuroglancer-side-panel-drag] .neuroglancer-side-panel-drop-zone{display:block}.neuroglancer-resize-gutter-vertical{height:1px;background-color:#333;background-clip:content-box;padding-top:2px;padding-bottom:2px;cursor:row-resize}.neuroglancer-resize-gutter-horizontal{width:1px;background-color:#333;background-clip:content-box;padding-right:2px;padding-left:2px;cursor:col-resize}.neuroglancer-drag-status{position:absolute;top:0;z-index:1000;background-color:#ff0;color:#000;font:10pt sans-serif;padding:2px}.neuroglancer-eye-icon.neuroglancer-visible>svg>:last-child{display:none}.neuroglancer-eye-icon.neuroglancer-indeterminate>svg>:last-child{stroke:#fff6}/** + * @license + * Copyright 2023 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */.neuroglancer-star-icon>svg{stroke:#fff}.neuroglancer-star-icon.neuroglancer-starred>svg{fill:#fff}.neuroglancer-star-icon.neuroglancer-indeterminate>svg{fill:#fff6}.neuroglancer-annotations-tab,.neuroglancer-annotation-layer-view,.neuroglancer-tags-tab{display:flex;align-items:stretch;flex:1;flex-direction:column}.neuroglancer-annotation-list{position:relative;margin:2px 0 0;padding:0;overflow-y:auto;height:0px;flex:1;flex-basis:0px;min-height:0px}.neuroglancer-annotation-list-entry{display:grid;grid-auto-rows:min-content;cursor:pointer;justify-content:start}.neuroglancer-annotation-position{display:contents}.neuroglancer-annotation-list-header{grid-auto-rows:min-content;display:grid;padding-bottom:2px;justify-content:start}.neuroglancer-annotation-coordinate{font-family:monospace;text-align:right}.neuroglancer-annotation-icon{grid-column:symbol;padding-right:5px}.neuroglancer-annotation-description,.neuroglancer-annotation-tags{grid-column:dim / -1;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.neuroglancer-annotation-list-entry-delete{grid-column:delete;margin-left:1ch;align-self:start;visibility:hidden}.neuroglancer-annotation-list-entry:hover>.neuroglancer-annotation-list-entry-delete{visibility:visible}.neuroglancer-annotation-hover{background-color:#333}.neuroglancer-annotation-selected{background-color:#939}.neuroglancer-annotation-hover.neuroglancer-annotation-selected{background-color:#969}.neuroglancer-tab-content.neuroglancer-annotation-details{flex:0 0 auto;align-self:stretch;display:flex;flex-direction:column;-webkit-touch-callout:default;-webkit-user-select:text;-khtml-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text}.neuroglancer-annotation-details-title{display:flex;flex-direction:row;background-color:#03c;align-self:stretch;padding:2px}.neuroglancer-voxel-coordinates-link{cursor:pointer}.neuroglancer-voxel-coordinates-link:hover{background-color:#db4437}.neuroglancer-annotation-details-icon{display:inline-block;margin-right:5px}.neuroglancer-annotation-details-title-text{display:inline-block;flex:1}textarea.neuroglancer-annotation-details-description{align-self:stretch;background-color:#222;color:#fff;font:10pt sans-serif;border:0px;outline:0px;resize:none;overflow-y:scroll}div.neuroglancer-annotation-details-description{align-self:stretch;color:#fff;font:10pt sans-serif}.neuroglancer-annotation-toolbox{display:flex;align-items:stretch}.neuroglancer-annotation-segment-item{color:#000;background-color:#fff}.neuroglancer-annotations-view-dimension{font-family:monospace;text-align:right}.neuroglancer-annotations-view-dimension-name{color:#ff6}.neuroglancer-annotations-view-dimension-scale{color:#bbb}.neuroglancer-annotations-view-dimension-scale:not(:empty):before{content:"(";margin-left:1ch}.neuroglancer-annotations-view-dimension-scale:not(:empty):after{content:")"}.neuroglancer-annotation-relationship-label,.neuroglancer-annotation-property-label{margin-right:5px}.neuroglancer-selected-annotation-details-position-grid{display:grid;grid-auto-rows:auto;font-family:monospace;font-size:medium;grid-auto-flow:dense}.neuroglancer-selected-annotation-details-icon{grid-rows:1 / -1;grid-column:icon;align-self:start}.neuroglancer-selected-annotation-details-delete{grid-rows:1 / -1;grid-column:delete;align-self:start}.neuroglancer-selected-annotation-details-position-dim{color:#ff6;margin-left:1ch}.neuroglancer-selected-annotation-details-position-coord{text-align:right;margin-left:.5ch}.neuroglancer-related-segment-list-title{font-family:sans-serif;font-size:small;background-color:#333}.neuroglancer-related-segment-list-header{display:flex;flex-direction:row}.neuroglancer-annotation-property{display:flex;flex-direction:row;font-family:sans-serif;font-size:small;user-select:text}.neuroglancer-annotation-property-label{color:#999}.neuroglancer-annotation-property-value{text-align:right;font-family:monospace;font-size:medium;flex:1}input.neuroglancer-segment-list-entry-id{outline:0px;border:0px;text-align:left}.neuroglancer-segment-list-entry-new>.neuroglancer-segment-list-entry-copy{visibility:hidden}.neuroglancer-segment-list-entry-new>input[type=checkbox]{visibility:hidden}.neuroglancer-selection-annotation-status{font-family:sans-serif;font-size:small}:root{--neuroglancer-segment-list-width: auto}.neuroglancer-segment-list{position:relative;overflow-y:auto;overflow-x:auto;flex:1}.neuroglancer-segment-display-tab{display:flex;flex-direction:column}.neuroglancer-segment-query-errors{margin:0;list-style-type:none;padding:0 0 0 3px;background-color:#333}.neuroglancer-segment-query-errors>li{display:block;color:red}.neuroglancer-segment-list-entry:not(.neuroglancer-segment-list-entry-double-line) .neuroglancer-segment-list-entry-unmapped-id:empty+.neuroglancer-segment-list-entry-copy{display:none}.neuroglancer-segment-list-entry.neuroglancer-segment-list-entry-double-line .neuroglancer-segment-list-entry-unmapped-id:empty+.neuroglancer-segment-list-entry-copy{visibility:hidden}.neuroglancer-segment-list-entry-name:empty+.neuroglancer-segment-list-entry-filter{display:none}.neuroglancer-segment-list-entry-name{order:1000;display:inline-block;font-family:monospace;font-size:medium;user-select:text;white-space:nowrap}.neuroglancer-segment-list-query{background-color:#151515;color:#fff;font-family:monospace;font-size:medium;border:2px solid #333;padding:2px;outline:0px}.neuroglancer-segment-list-query::placeholder{color:#aaa}.neuroglancer-segment-list-status{display:flex;flex-direction:row;align-items:center;background-color:#333}.neuroglancer-segment-list-entry-copy{order:-2;visibility:hidden}.neuroglancer-segment-list-entry:hover .neuroglancer-segment-list-entry-copy{visibility:visible}.neuroglancer-segment-list .neuroglancer-segment-list-entry:not(:hover) .neuroglancer-star-icon:not(.neuroglancer-starred){visibility:hidden}.neuroglancer-segment-list .neuroglancer-segment-list-entry:not(:hover) .neuroglancer-eye-icon:not(.neuroglancer-visible){visibility:hidden}.neuroglancer-segment-list-entry-visible-checkbox{order:1}.neuroglancer-segment-list-entry-filter{visibility:hidden;grid-column:filter;order:999}.neuroglancer-segment-list-entry:hover .neuroglancer-segment-list-entry-filter{visibility:visible}.neuroglancer-segment-query-result-tag-list{display:grid;grid-auto-rows:auto;grid-template-columns:[include] min-content [exclude] min-content [tag] 1fr [count] min-content}.neuroglancer-segment-query-result-tag{display:contents}.neuroglancer-segment-query-result-tag:hover *{background-color:#222}.neuroglancer-segment-query-result-tag-name{grid-column:tag;white-space:nowrap;cursor:pointer;font-weight:700}.neuroglancer-segment-query-result-tag-name:before{content:"#";color:#aaa;font-weight:400}.neuroglancer-segment-query-result-tag-toggle{display:inline-block;white-space:nowrap}.neuroglancer-segment-query-result-tag-include{grid-column:include}.neuroglancer-segment-query-result-tag-exclude{grid-column:exclude}.neuroglancer-segment-query-result-statistics{background-color:#333;max-height:30%;flex-shrink:0;overflow:auto}.neuroglancer-segment-query-result-statistics:not(:empty){padding-top:3px}.neuroglancer-segment-query-result-statistics:not(:empty)+.neuroglancer-segment-list-status{border-top:1px solid white}.neuroglancer-segment-query-result-statistics-separator{height:3px;background-color:#333;border-bottom:1px solid white}.neuroglancer-segment-query-result-tag-count{grid-column:count;text-align:right}.neuroglancer-segment-query-result-tag-count:not(:empty):before{content:"(";color:#aaa}.neuroglancer-segment-query-result-tag-count:not(:empty):after{content:")";color:#aaa}.neuroglancer-segment-query-result-numerical-list{display:flex;flex-direction:column}.neuroglancer-segment-query-result-numerical-plot-container{justify-self:stretch;display:flex;flex-direction:column;padding:2px}.neuroglancer-segment-query-result-numerical-plot{display:block;height:30px;cursor:ew-resize;justify-self:stretch;border:1px solid #666}.neuroglancer-segment-query-result-numerical-plot-bound{background-color:transparent;border-color:transparent;box-shadow:none;border:0;margin:0;font:10pt sans-serif;pointer-events:auto}.neuroglancer-segment-query-result-numerical-plot-window-bound{color:#0ff}.neuroglancer-segment-query-result-numerical-plot-range-bound{color:#fff}.neuroglancer-segment-query-result-numerical-plot-bounds{display:flex;flex-direction:row;color:#aaa}.neuroglancer-segment-query-result-numerical-plot-bound-constraint-symbol{align-self:center}.neuroglancer-segment-query-result-numerical-plot-bound-constraint-spacer{flex:1;color:#fff;font-weight:700;display:flex;flex-direction:row;justify-content:center;align-items:center}.neuroglancer-segment-query-result-numerical-plot-label{cursor:pointer}.neuroglancer-segment-query-result-numerical-plot-sort,.neuroglancer-segment-list-header-label-sort{visibility:hidden}.neuroglancer-segment-query-result-numerical-plot-label:hover .neuroglancer-segment-query-result-numerical-plot-sort,.neuroglancer-segment-list-header-label:hover .neuroglancer-segment-list-header-label-sort,.neuroglancer-segment-query-result-numerical-plot-container:hover .neuroglancer-segment-query-result-numerical-plot-bounds-window{visibility:visible}.neuroglancer-segment-query-result-numerical-plot-bounds-window{justify-content:space-between;margin-top:-16px;visibility:hidden;pointer-events:none}.neuroglancer-segment-list-entry.neuroglancer-segment-list-header{background-color:#666}.neuroglancer-segment-list-header .neuroglancer-segment-list-entry-id{background-color:inherit;color:#fff;text-align:center}.neuroglancer-segment-list-header-label{cursor:pointer;font:10pt sans-serif}.neuroglancer-segment-list-header .neuroglancer-segment-list-entry-extra-property{text-align:center}.neuroglancer-segment-list-status-message{overflow:hidden;white-space:nowrap}/** + * @license + * Copyright 2021 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */.neuroglancer-merge-segments-status{display:flex;flex-direction:row}.neuroglancer-merge-segments-status .neuroglancer-segment-list-entry{margin-left:1em;margin-right:1em}.overlay{height:100%;width:100%;position:fixed;z-index:99;top:0;left:0;background-color:#000c}.overlay-content{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);background-color:#fff;z-index:100;color:#000;padding:1em}/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */.neuroglancer-linked-layer-widget-layer{display:flex;flex-direction:row}.neuroglancer-linked-layer-widget-layer:hover{background-color:#333}.neuroglancer-shader-code-widget.invalid-input{border:1px solid red}.neuroglancer-shader-code-widget.valid-input{border:1px solid green}.neuroglancer-shader-code-widget{border:1px solid transparent}.CodeMirror{font-family:monospace;height:300px;color:#000;direction:ltr}.CodeMirror-lines{padding:4px 0}.CodeMirror pre.CodeMirror-line,.CodeMirror pre.CodeMirror-line-like{padding:0 4px}.CodeMirror-scrollbar-filler,.CodeMirror-gutter-filler{background-color:#fff}.CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f7f7f7;white-space:nowrap}.CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;white-space:nowrap}.CodeMirror-guttermarker{color:#000}.CodeMirror-guttermarker-subtle{color:#999}.CodeMirror-cursor{border-left:1px solid black;border-right:none;width:0}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.cm-fat-cursor .CodeMirror-cursor{width:auto;border:0!important;background:#7e7}.cm-fat-cursor div.CodeMirror-cursors{z-index:1}.cm-fat-cursor .CodeMirror-line::selection,.cm-fat-cursor .CodeMirror-line>span::selection,.cm-fat-cursor .CodeMirror-line>span>span::selection{background:transparent}.cm-fat-cursor .CodeMirror-line::-moz-selection,.cm-fat-cursor .CodeMirror-line>span::-moz-selection,.cm-fat-cursor .CodeMirror-line>span>span::-moz-selection{background:transparent}.cm-fat-cursor{caret-color:transparent}@-moz-keyframes blink{50%{background-color:transparent}}@-webkit-keyframes blink{50%{background-color:transparent}}@keyframes blink{50%{background-color:transparent}}.cm-tab{display:inline-block;text-decoration:inherit}.CodeMirror-rulers{position:absolute;inset:-50px 0 0;overflow:hidden}.CodeMirror-ruler{border-left:1px solid #ccc;top:0;bottom:0;position:absolute}.cm-s-default .cm-header{color:#00f}.cm-s-default .cm-quote{color:#090}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:700}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-strikethrough{text-decoration:line-through}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-variable-3,.cm-s-default .cm-type{color:#085}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta,.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-s-default .cm-error,.cm-invalidchar{color:red}.CodeMirror-composing{border-bottom:2px solid}div.CodeMirror span.CodeMirror-matchingbracket{color:#0b0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#a22}.CodeMirror-matchingtag{background:#ff96004d}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{position:relative;overflow:hidden;background:#fff}.CodeMirror-scroll{overflow:scroll!important;margin-bottom:-50px;margin-right:-50px;padding-bottom:50px;height:100%;outline:none;position:relative;z-index:0}.CodeMirror-sizer{position:relative;border-right:50px solid transparent}.CodeMirror-vscrollbar,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-gutter-filler{position:absolute;z-index:6;display:none;outline:none}.CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.CodeMirror-scrollbar-filler{right:0;bottom:0}.CodeMirror-gutter-filler{left:0;bottom:0}.CodeMirror-gutters{position:absolute;left:0;top:0;min-height:100%;z-index:3}.CodeMirror-gutter{white-space:normal;height:100%;display:inline-block;vertical-align:top;margin-bottom:-50px}.CodeMirror-gutter-wrapper{position:absolute;z-index:4;background:none!important;border:none!important}.CodeMirror-gutter-background{position:absolute;top:0;bottom:0;z-index:4}.CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.CodeMirror-gutter-wrapper ::selection{background-color:transparent}.CodeMirror-gutter-wrapper ::-moz-selection{background-color:transparent}.CodeMirror-lines{cursor:text;min-height:1px}.CodeMirror pre.CodeMirror-line,.CodeMirror pre.CodeMirror-line-like{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border-width:0;background:transparent;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible;-webkit-tap-highlight-color:transparent;-webkit-font-variant-ligatures:contextual;font-variant-ligatures:contextual}.CodeMirror-wrap pre.CodeMirror-line,.CodeMirror-wrap pre.CodeMirror-line-like{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-linebackground{position:absolute;inset:0;z-index:0}.CodeMirror-linewidget{position:relative;z-index:2;padding:.1px}.CodeMirror-rtl pre{direction:rtl}.CodeMirror-code{outline:none}.CodeMirror-scroll,.CodeMirror-sizer,.CodeMirror-gutter,.CodeMirror-gutters,.CodeMirror-linenumber{-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.CodeMirror-cursor{position:absolute;pointer-events:none}.CodeMirror-measure pre{position:static}div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:3}div.CodeMirror-dragcursors,.CodeMirror-focused div.CodeMirror-cursors{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.CodeMirror-crosshair{cursor:crosshair}.CodeMirror-line::selection,.CodeMirror-line>span::selection,.CodeMirror-line>span>span::selection{background:#d7d4f0}.CodeMirror-line::-moz-selection,.CodeMirror-line>span::-moz-selection,.CodeMirror-line>span>span::-moz-selection{background:#d7d4f0}.cm-searching{background-color:#ffa;background-color:#ff06}.cm-force-border{padding-right:.1px}@media print{.CodeMirror div.CodeMirror-cursors{visibility:hidden}}.cm-tab-wrap-hack:after{content:""}span.CodeMirror-selectedtext{background:none}.CodeMirror-lint-markers{width:16px}.CodeMirror-lint-tooltip{background-color:#ffd;border:1px solid black;border-radius:4px;color:#000;font-family:monospace;font-size:10pt;overflow:hidden;padding:2px 5px;position:fixed;white-space:pre;white-space:pre-wrap;z-index:100;max-width:600px;opacity:0;transition:opacity .4s;-moz-transition:opacity .4s;-webkit-transition:opacity .4s;-o-transition:opacity .4s;-ms-transition:opacity .4s}.CodeMirror-lint-mark{background-position:left bottom;background-repeat:repeat-x}.CodeMirror-lint-mark-warning{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII=)}.CodeMirror-lint-mark-error{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg==)}.CodeMirror-lint-marker{background-position:center center;background-repeat:no-repeat;cursor:pointer;display:inline-block;height:16px;width:16px;vertical-align:middle;position:relative}.CodeMirror-lint-message{padding-left:18px;background-position:top left;background-repeat:no-repeat}.CodeMirror-lint-marker-warning,.CodeMirror-lint-message-warning{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII=)}.CodeMirror-lint-marker-error,.CodeMirror-lint-message-error{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII=)}.CodeMirror-lint-marker-multiple{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAMAAADzjKfhAAAACVBMVEUAAAAAAAC/v7914kyHAAAAAXRSTlMAQObYZgAAACNJREFUeNo1ioEJAAAIwmz/H90iFFSGJgFMe3gaLZ0od+9/AQZ0ADosbYraAAAAAElFTkSuQmCC);background-repeat:no-repeat;background-position:right bottom;width:100%;height:100%}.CodeMirror-lint-line-error{background-color:#b74c5114}.CodeMirror-lint-line-warning{background-color:#ffd3001a}.neuroglancer-layer-data-sources-tab{display:flex;flex-direction:column}.neuroglancer-layer-data-sources-container{overflow-y:auto;display:flex;flex-direction:column;flex:1;height:0px;z-index:1}.neuroglancer-layer-data-source-url-input input.autocomplete-input{color:#fff}.neuroglancer-layer-data-source-url-input input.autocomplete-hint{color:#aaa}.neuroglancer-layer-data-source-url-input .autocomplete-dropdown{background-color:#333}.neuroglancer-layer-data-sources-source-id{font-weight:700}.neuroglancer-layer-data-sources-source-id:not(:empty):before{content:"["}.neuroglancer-layer-data-sources-source-id:not(:empty):after{content:"]"}.neuroglancer-layer-data-sources-source-id:not(:empty){margin-right:4px;color:#0ff}.neuroglancer-layer-data-sources-source-messages:empty{display:none}.neuroglancer-layer-data-sources-source-messages{margin-top:0;list-style:none;padding-left:0}li.neuroglancer-message{word-wrap:break-word;user-select:text}li.neuroglancer-message-error{color:red}li.neuroglancer-message-warning{color:#ff0}li.neuroglancer-message-info{color:#ccc}.neuroglancer-layer-data-sources-source-default{display:block;margin-bottom:4px}.neuroglancer-layer-data-sources-info-line[data-is-active=false]{text-decoration:solid line-through #caa}.neuroglancer-layer-data-sources-tab-type-detection{position:sticky;bottom:0;background-color:#ff9;color:#000;text-align:center;cursor:pointer}.neuroglancer-layer-data-sources-tab-type-detection:hover{background-color:#ffc}.neuroglancer-layer-data-sources-tab-type-detection-type{font-weight:700}.neuroglancer-coordinate-space-transform-widget{display:grid;justify-items:stretch}.neuroglancer-coordinate-space-transform-widget input{font-family:monospace;justify-self:stretch;background-color:#000;color:#fff;padding:2px}.neuroglancer-coordinate-space-transform-widget *[data-will-be-deleted=true]{color:#666}.neuroglancer-coordinate-space-transform-label{font-style:italic;color:#fcc;align-self:center}.neuroglancer-coordinate-space-transform-input-lower-label{grid-row:sourceLower;grid-column:outputLabel / sourceDim 1}.neuroglancer-coordinate-space-transform-translation-label{grid-row:sourceLabel / outputDim 1;grid-column:sourceDim -1;writing-mode:vertical-lr;text-orientation:mixed;align-self:end;justify-self:center;margin-bottom:2px}.neuroglancer-coordinate-space-transform-input-lower-label,.neuroglancer-coordinate-space-transform-input-upper-label,.neuroglancer-coordinate-space-transform-input-scale-label{text-align:right;margin-right:4px}.neuroglancer-coordinate-space-transform-input-upper-label{grid-row:sourceUpper;grid-column:headerStart / headerEnd}.neuroglancer-coordinate-space-transform-input-scale-label{grid-row:5;grid-column:headerStart / headerEnd}.neuroglancer-coordinate-space-transform-source-label{grid-row:sourceLabel;grid-column:sourceDim 1 / sourceDim -1;text-align:center}.neuroglancer-coordinate-space-transform-output-label{grid-row:outputDim 1 / outputDim -1;grid-column:outputLabel;writing-mode:vertical-lr;text-orientation:mixed;align-self:center;justify-self:end;margin-right:2px}.neuroglancer-coordinate-space-transform-input-name{text-align:center}.neuroglancer-coordinate-space-transform-input-name,input.neuroglancer-coordinate-space-transform-output-name{font-family:monospace;color:#ff6}.neuroglancer-coordinate-space-transform-scale{text-align:right}.neuroglancer-coordinate-space-transform-input-bounds,.neuroglancer-coordinate-space-transform-output-bounds{white-space:nowrap;font-family:monospace;font-size:small;text-align:right;padding-left:2px;padding-right:2px;color:#aff}.neuroglancer-coordinate-space-transform-input-bounds.neuroglancer-coordinate-space-transform-singleton:not(*[data-will-be-deleted=true]){color:#fa6}.neuroglancer-coordinate-space-transform-widget input[data-is-valid=false],.neuroglancer-coordinate-space-transform-widget input[data-is-valid=false]::placeholder{text-decoration:solid underline red}.neuroglancer-coordinate-space-transform-output-extend{grid-row:outputDim -1;grid-column:outputNames;display:flex;flex-direction:column}.neuroglancer-coordinate-space-transform-output-extend input{align-self:stretch}.neuroglancer-coordinate-space-transform-output-extend[data-is-active=false] input,.neuroglancer-coordinate-space-transform-output-extend[data-is-active=true] .neuroglancer-icon{display:none}.neuroglancer-coordinate-space-transform-output-extend .neuroglancer-icon{align-self:start}.neuroglancer-coordinate-space-transform-translation-coeff{margin-left:3px}.neuroglancer-coordinate-space-transform-output-scale-container{margin-right:3px}.neuroglancer-coordinate-space-transform-input-scale-container,.neuroglancer-coordinate-space-transform-input-scale-label{margin-bottom:3px}.neuroglancer-coordinate-space-transform-widget input,.neuroglancer-coordinate-space-transform-output-name-container,.neuroglancer-coordinate-space-transform-scale-container{border:1px solid #333}.neuroglancer-coordinate-space-transform-widget .neuroglancer-coordinate-space-transform-output-name,.neuroglancer-coordinate-space-transform-widget .neuroglancer-coordinate-space-transform-scale{border:0px}.neuroglancer-coordinate-space-transform-output-name-container{display:flex;flex-direction:column;align-items:stretch;margin-right:3px}.neuroglancer-coordinate-space-transform-scale-container{display:flex;flex-direction:column;align-items:stretch}.neuroglancer-coordinate-space-transform-scale-suggestion{font-family:monospace;cursor:pointer;border-radius:20%;border:1px solid #333;align-self:flex-end;margin:2px;color:#aaa}.neuroglancer-coordinate-space-transform-scale-suggestion svg{width:16px;height:16px;fill:transparent;stroke:#aaa;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}.neuroglancer-coordinate-space-transform-scale-suggestion:hover{background-color:#db4437;border:1px solid transparent;color:#fff}.neuroglancer-coordinate-space-transform-scale-suggestion:hover svg{stroke:#fff}.neuroglancer-coordinate-space-transform-widget-reset-buttons{grid-row:outputDim -1;grid-column:headerEnd / -1;justify-self:start}.neuroglancer-multiline-autocomplete{margin-top:2px;padding:2px;position:relative;background-color:#222}.neuroglancer-multiline-autocomplete-hint,.neuroglancer-multiline-autocomplete-input{font-family:monospace;color:#fff;word-wrap:break-word}.neuroglancer-multiline-autocomplete-input:focus{outline:0px}.neuroglancer-multiline-autocomplete-input:not(:focus):empty:before{content:attr(data-placeholder);color:#aaa}.neuroglancer-multiline-autocomplete-hint{color:#aaa}.neuroglancer-multiline-autocomplete-hint,.neuroglancer-multiline-autocomplete-input,.neuroglancer-multiline-autocomplete-completion{font-family:monospace;font-size:medium}.neuroglancer-multiline-autocomplete-dropdown{color:#fff;background-color:#181818;position:fixed;display:block;outline:0;margin:0;padding:0;left:0;right:0;text-align:left;cursor:default;border-style:solid;border-width:1px;border-color:#aaa;overflow-y:scroll;word-wrap:break-word}.neuroglancer-multiline-autocomplete-completion:nth-child(2n):not(.neuroglancer-multiline-autocomplete-completion-active){background-color:#2b2b2b}.neuroglancer-multiline-autocomplete-completion:hover{outline:1px solid #ddd}.neuroglancer-multiline-autocomplete-completion-active{background-color:#666}.neuroglancer-multiline-autocomplete-completion-description{font-style:italic;color:#f9f}.neuroglancer-image-dropdown{overflow-y:auto;display:flex;flex-direction:column;height:0px}.neuroglancer-image-dropdown .neuroglancer-shader-code-widget{flex-shrink:0;height:8em;border:1px solid transparent}.neuroglancer-image-dropdown-top-row{display:flex;flex-direction:row;align-items:center}.neuroglancer-image-layer-shader-overlay .neuroglancer-shader-code-widget{width:80vw;height:80vh}.neuroglancer-selection-details-value-grid{display:grid;grid-auto-rows:auto;font-family:monospace;font-size:medium;align-items:center}.neuroglancer-selection-details-value-grid-dim{grid-column:dim;color:#ff6}.neuroglancer-selection-details-value-grid-dim:after{content:"=";color:#aaa}.neuroglancer-selection-details-value-grid-coord{grid-column:coord;color:#aaa;margin-right:1ch}.neuroglancer-selection-details-value-grid-value{grid-column:value;user-select:text}.neuroglancer-channel-dimensions-widget-dim{display:contents}.neuroglancer-channel-dimensions-widget{display:grid;grid-template-columns:[name] min-content [lower] min-content [upper] min-content}.neuroglancer-channel-dimensions-widget-name-container{grid-column:name}.neuroglancer-channel-dimensions-widget-name[data-is-valid=false],.neuroglancer-channel-dimensions-widget-name::placeholder{text-decoration:solid underline red}.neuroglancer-channel-dimensions-widget-name{background-color:transparent;border-color:transparent;box-shadow:none;border:0;margin:0;font-family:monospace;font-size:medium;color:#ff6}.neuroglancer-channel-dimensions-widget-name,.neuroglancer-channel-dimensions-widget-lower,.neuroglancer-channel-dimensions-widget-upper{font-family:monospace}.neuroglancer-channel-dimensions-widget-lower{grid-column:lower;text-align:right}.neuroglancer-channel-dimensions-widget-upper{grid-column:upper;text-align:right}.neuroglancer-channel-dimensions-widget-lower,.neuroglancer-channel-dimensions-widget-upper{text-align:right;margin-left:1ch;user-select:text}.neuroglancer-channel-dimensions-widget-upper:after{content:")"}.neuroglancer-channel-dimensions-widget-lower:after{content:","}.neuroglancer-channel-dimensions-widget-lower:before{content:"["}.neuroglancer-channel-dimensions-widget-upper:after,.neuroglancer-channel-dimensions-widget-lower:before,.neuroglancer-channel-dimensions-widget-lower:after{color:#999}.neuroglancer-single-mesh-dropdown .neuroglancer-single-mesh-attribute-widget{max-height:6em;margin-bottom:8px}.neuroglancer-single-mesh-dropdown .neuroglancer-shader-code-widget{height:6em;width:60ch;border:1px solid transparent}.neuroglancer-single-mesh-dropdown-top-row{display:flex;flex-direction:row;align-items:center}.neuroglancer-single-mesh-shader-overlay .neuroglancer-shader-code-widget{width:80vw;height:80vh}.neuroglancer-single-mesh-attribute-widget{word-wrap:break-word;overflow-y:auto;display:grid;grid-template-columns:[type] auto [name] auto [range] auto}.neuroglancer-single-mesh-layer-shader-overlay .neuroglancer-single-mesh-attribute-widget{max-height:20vh}.neuroglancer-single-mesh-attribute{font-family:monospace;display:contents}.neuroglancer-single-mesh-attribute-type{color:#c6c;grid-column:type}.neuroglancer-single-mesh-attribute-name{margin-left:1ch;color:#fff;grid-column:name;user-select:text}.neuroglancer-single-mesh-attribute-range{margin-left:1ch;white-space:nowrap;color:#999;grid-column:range}.neuroglancer-graphene-tab .neuroglancer-annotation-toolbox{display:none}.neuroglancer-graphene-tab div[data-color="#ff0000"]>.neuroglancer-annotation-position{color:red}.neuroglancer-graphene-tab div[data-color="#0000ff"]>.neuroglancer-annotation-position{color:#44f}.graphene-tool-status{display:flex;gap:10px}.graphene-multicut>.activeGroupIndicator{padding:2px;margin:auto 0;background-color:red;font:12px sans-serif;font-weight:900}.graphene-multicut>.activeGroupIndicator.blueGroup{background-color:#00f}.graphene-multicut>.activeGroupIndicator:after{content:"Red"}.graphene-multicut>.activeGroupIndicator.blueGroup:after{content:"Blue"}.graphene-merge-segments-merges{display:flex;flex-direction:column}.graphene-merge-segments-submission{display:flex;gap:10px}.graphene-tool-status .neuroglancer-icon{height:100%}.graphene-merge-segments-status label{display:grid;grid-template-columns:min-content min-content;white-space:nowrap;justify-content:center;align-content:center}.graphene-merge-segments-point{display:flex;align-items:center;gap:10px}.graphene-merge-segments-point .neuroglancer-segment-list-entry-visible-checkbox,.graphene-merge-segments-point .neuroglancer-segment-list-entry-copy-container{display:none}.graphene-find-path>label{display:flex}.graphene-find-path>label>span{display:flex;align-content:center;flex-wrap:wrap}.find-path-annotations{display:flex;gap:10px}.find-path-annotations>.neuroglancer-annotation-list-entry{background-color:#000}html,body{margin:0;padding:0;overflow:hidden;width:100vw;height:100vh;background-color:#000;color:#fff}body{position:relative;display:flex;flex-direction:column}#neuroglancer-container{width:100vw;overflow:hidden;flex:1}.neuroglancer-viewer{outline:0px}.neuroglancer-viewer-top-row{display:flex;flex-direction:row;align-items:center;background-color:#222;margin-bottom:3px;padding-right:2px}.neuroglancer-viewer-side-panel{display:flex;flex-direction:column;align-items:stretch;max-width:80%;color:#fff}.neuroglancer-noselect{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.neuroglancer-select-text{-webkit-touch-callout:default;-webkit-user-select:text;-khtml-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text}.neuroglancer-data-panel-layout-controls{position:absolute;top:2px;right:2px;display:flex;align-items:start}.neuroglancer-data-panel-layout-controls>button{display:flex;margin:2px;border:0px;background-color:#00000080;flex-direction:row;align-self:top;align-items:center;justify-content:center;border:1px solid white;font-size:15px;width:18px;height:18px;color:#fff}.neuroglancer-data-panel-layout-controls>button>div{display:inline-block;text-align:center;line-height:12px;width:15px;height:15px}.neuroglancer-data-panel-layout-controls>button:hover{color:#6ff}label.perspective-panel-show-slice-views{pointer-events:none;position:absolute;right:2px;bottom:2px;font-family:sans-serif;font-size:small}input.perspective-panel-show-slice-views{pointer-events:all}.neuroglancer-rendered-data-panel{cursor:crosshair;position:relative;outline:0;touch-action:none;color:#fff;text-align:left}.neuroglancer-display-dimensions-widget{position:absolute;cursor:default;top:2px;left:2px;background-color:#0000004d}.neuroglancer-display-dimensions-widget-dimension-grid{display:grid;grid-template-rows:0fr 0fr 0fr 0fr;grid-template-columns:0fr 0fr 0fr}.neuroglancer-display-dimensions-widget input{outline:0px;background-color:transparent;border-color:transparent;box-shadow:none;margin:0;border:0;padding:2px}.neuroglancer-display-dimensions-widget input,.neuroglancer-display-dimensions-widget{font-family:monospace;color:#fff}.neuroglancer-display-dimensions-widget-dimension:hover{outline:1px solid black}.neuroglancer-display-dimensions-widget-name[data-is-valid=false]{text-decoration:solid underline red}.neuroglancer-display-dimensions-widget-scale-factor{text-align:right;align-items:end;display:inline-block;white-space:nowrap;margin-left:2px}.neuroglancer-display-dimensions-widget-scale{display:inline-block;white-space:nowrap;padding-left:10px}.neuroglancer-display-dimensions-widget-scale:not(:empty):before{content:"("}.neuroglancer-display-dimensions-widget-scale:not(:empty):after{content:")"}.neuroglancer-display-dimensions-widget-scale-factor:after{content:"\d7"}.neuroglancer-display-dimensions-widget-scale{text-align:right;margin-left:5px}.neuroglancer-display-dimensions-widget:not(:hover):not([data-active=true]) .neuroglancer-display-dimensions-widget-scale-factor,.neuroglancer-display-dimensions-widget:not(:hover):not([data-active=true]) .neuroglancer-display-dimensions-widget-scale,.neuroglancer-display-dimensions-widget:not(:hover):not([data-active=true]) .neuroglancer-display-dimensions-widget-default,.neuroglancer-display-dimensions-widget:not(:hover):not([data-active=true]) .neuroglancer-depth-range-widget-grid,.neuroglancer-display-dimensions-widget:not(:hover):not([data-active=true]) .neuroglancer-depth-range-relative-checkbox-label{display:none}.neuroglancer-display-dimensions-widget-dimension[data-is-modified=true] .neuroglancer-display-dimensions-widget-scale-factor,.neuroglancer-display-dimensions-widget-dimension[data-is-modified=true] .neuroglancer-display-dimensions-widget-scale{visibility:hidden}.neuroglancer-display-dimensions-widget *:focus{outline:0px}.neuroglancer-display-dimensions-widget-default{grid-row:4;grid-column-start:1;grid-column-end:3;display:inline-block;white-space:nowrap}.neuroglancer-display-dimensions-widget-default input{margin-right:3px}.neuroglancer-depth-range-widget-grid{margin-top:1em;display:grid;grid-template-columns:0fr 0fr 0fr;grid-auto-rows:0fr}.neuroglancer-depth-range-widget-dimension-names:not(:empty):before{content:"("}.neuroglancer-depth-range-widget-dimension-names:not(:empty):after{content:")"}.neuroglancer-depth-range-widget-dimension-names{margin-left:1ch;white-space:nowrap}.neuroglancer-help-body{flex-basis:0px;flex:1;height:0px;min-height:0px;font-family:sans-serif;display:flex;flex-direction:column}.neuroglancer-help-scroll-container{flex:1;flex-basis:0px;position:relative;overflow:auto}.neuroglancer-help-scroll-container div+h2{margin-top:1em}.neuroglancer-help-scroll-container h2{font-size:10pt;padding:4px;position:sticky;top:0;background-color:#333;margin-top:0}.neuroglancer-help-scroll-container .dt{font-family:monospace;font-weight:700;color:#ff0}.neuroglancer-help-scroll-container .dd{font-size:10pt;margin-left:4ex}.neuroglancer-build-info{font-size:10pt;user-select:text}.neuroglancer-build-info a{color:#fff;text-decoration:none;font-weight:700}.neuroglancer-build-info a:hover{background-color:#db4437}.neuroglancer-panel{flex:1}.neuroglancer-show-panel-borders .neuroglancer-panel{border-style:solid;border-color:#000;border-width:2px}.neuroglancer-panel:focus-within{border-color:#fff}.neuroglancer-layer-group-viewer{outline:0px}.neuroglancer-layer-group-viewer-context-menu{flex-direction:column;align-items:stretch}.neuroglancer-layer-group-viewer-context-menu label{display:flex;flex-direction:row;justify-content:space-between}.neuroglancer-layer-group-viewer-context-menu select:before{flex:1;content:" "}.neuroglancer-layer-group-viewer-context-menu select{margin-left:5px}.neuroglancer-context-menu{position:absolute;z-index:100;border:1px solid white;background-color:#000;box-shadow:5px 5px 2px 1px #00000080;font-family:sans-serif;font-size:11pt;padding:5px;color:#fff;outline:0px}:root{--layer-number-color: #9a7518}.neuroglancer-layer-panel{width:100%;display:flex;flex-direction:row;flex-wrap:wrap;align-items:stretch;margin-left:-5px;margin-top:-1px;z-index:-.1}.neuroglancer-layer-item{position:relative;display:flex;align-items:center;color:#fff;cursor:pointer;border-width:1px;border-style:solid;border-color:#ccc;font-family:sans-serif;font-size:10pt;background-color:#000;padding:1px}.neuroglancer-layer-item,.neuroglancer-layer-add-button{margin:1px 1px 1px 5px}.neuroglancer-layer-item[data-selected=true]{border-color:#8c8}.neuroglancer-layer-item[data-selected=true]:hover{border-color:#3c3}.neuroglancer-layer-item:hover{border-color:#daa520}.neuroglancer-layer-item[data-pick=true] .neuroglancer-layer-item-label{background-color:#939}.neuroglancer-layer-item-label{display:inline-block;position:relative;background-color:#222;padding-right:3px}.neuroglancer-layer-item-number{display:inline-block;background-color:var(--layer-number-color);font-weight:700;padding-left:1px;padding-right:1px}.neuroglancer-layer-panel[data-show-hover-values=true] .neuroglancer-layer-item-value{display:inline-block;font-family:monospace;font-size:medium;max-width:50ch;margin-left:1ch;white-space:nowrap;overflow:hidden;text-overflow:ellipses;text-align:center}.neuroglancer-layer-panel[data-show-hover-values=false] .neuroglancer-layer-item-value{display:none}.neuroglancer-layer-item[data-visible=false] .neuroglancer-layer-item-label{text-decoration:line-through}.neuroglancer-layer-item[data-visible=false]{color:#bbb}.neuroglancer-layer-panel-drop-zone{display:inline-block;flex:1}.neuroglancer-layer-item-visible-progress,.neuroglancer-layer-item-prefetch-progress{position:absolute;left:0;height:2px;background-color:#666}.neuroglancer-layer-item-visible-progress{top:0}.neuroglancer-layer-item-prefetch-progress{bottom:0}.neuroglancer-layer-item-value-container{display:grid;grid-template-columns:min-content;align-items:center}.neuroglancer-layer-item-value{grid-row:1;grid-column:1;visibility:visible}.neuroglancer-layer-item-button-container{grid-row:1;grid-column:1;white-space:nowrap;display:flex;flex-direction:row;align-items:center;visibility:hidden;justify-self:right}.neuroglancer-layer-panel:hover .neuroglancer-layer-item-value{visibility:hidden}.neuroglancer-layer-panel:hover .neuroglancer-layer-item-button-container{visibility:visible}/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */.neuroglancer-layout-split-drop-zone{position:absolute;z-index:1000}.neuroglancer-drag-over{background-color:#0000ff80}.neuroglancer-stack-layout-row>.neuroglancer-stack-layout-drop-placeholder{padding-left:4px;padding-right:4px;width:1px;cursor:col-resize}.neuroglancer-stack-layout-column>.neuroglancer-stack-layout-drop-placeholder{padding-top:4px;padding-bottom:4px;height:1px;cursor:row-resize}.neuroglancer-stack-layout-drop-placeholder{background-clip:content-box;background-color:#666;z-index:1}.neuroglancer-stack-layout-drop-placeholder.neuroglancer-drag-over{background-clip:border-box;background-color:#8080ff80}.neuroglancer-stack-layout-drop-placeholder:first-child,.neuroglancer-stack-layout-drop-placeholder:last-child{display:none}.neuroglancer-layer-list-panel-items{display:flex;flex-direction:column;flex:1;overflow:auto;height:0px;min-height:0px;flex-basis:0px}.neuroglancer-layer-list-panel-item{display:flex;flex-direction:row;padding:2px;border:1px solid #aaa;margin:2px}.neuroglancer-layer-list-panel-item[data-selected=true]{border-color:#3c3}.neuroglancer-layer-list-panel-item[data-archived=true]{border-color:#666}.neuroglancer-layer-list-panel-item[data-archived=true] .neuroglancer-layer-side-panel-name,.neuroglancer-layer-list-panel-item[data-archived=true] .neuroglancer-icon svg{color:#999;stroke:#999}.neuroglancer-layer-list-panel-item:hover{background-color:#333}.neuroglancer-layer-list-panel-item-number{font-family:sans-serif;background-color:var(--layer-number-color);color:#fff;font-weight:700;display:inline-block}.neuroglancer-layer-list-panel-item:not(:hover)>.neuroglancer-layer-list-panel-item-delete{display:none}.neuroglancer-layer-list-panel-item:not(:hover)>.neuroglancer-layer-list-panel-item-controls{display:none}[data-neuroglancer-layer-panel-pinned=false] .neuroglancer-side-panel-titlebar.neuroglancer-layer-side-panel-title{background-color:#393}[data-neuroglancer-layer-visible=false] .neuroglancer-side-panel-titlebar.neuroglancer-layer-side-panel-title input{text-decoration:line-through}.neuroglancer-layer-side-panel-name{flex:1;background-color:transparent;border:0px;color:#fff;outline:0px;width:0px;min-width:0px}.neuroglancer-layer-side-panel-tab-view{flex:1;display:flex;flex-direction:column;font:10pt sans-serif}.neuroglancer-layer-side-panel-type-measure{position:absolute;visibility:hidden;top:0;height:auto;width:auto;white-space:nowrap}.neuroglancer-layer-side-panel-type,.neuroglancer-layer-side-panel-type-measure{padding-left:3px;padding-right:3px;font-weight:700;font-family:sans-serif;font-size:10pt;box-sizing:border-box}.neuroglancer-layer-side-panel-type{-webkit-appearance:none;color:#fff;cursor:pointer;background-color:#00000080;margin-right:5px;border:0px;outline:0px}.neuroglancer-layer-side-panel-type option{background-color:#000}.CodeMirror-foldmarker{color:#00f;text-shadow:#b9f 1px 1px 2px,#b9f -1px -1px 2px,#b9f 1px -1px 2px,#b9f -1px 1px 2px;font-family:arial;line-height:.3;cursor:pointer}.CodeMirror-foldgutter{width:.7em}.CodeMirror-foldgutter-open,.CodeMirror-foldgutter-folded{cursor:pointer}.CodeMirror-foldgutter-open:after{content:"\25be"}.CodeMirror-foldgutter-folded:after{content:"\25b8"}.neuroglancer-state-editor{width:80%}.close-button{position:absolute;right:15px}/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */.neuroglancer-statistics-panel-body{flex:1;flex-basis:0px;min-width:0px;display:flex;flex-direction:column;overflow-y:auto;font:10pt sans-serif}.neuroglancer-statistics-panel-body>table{position:relative;flex:1;width:100%}.neuroglancer-statistics-panel-body>table>thead td{position:sticky;top:0;z-index:2;background-color:#333;font-weight:700}.neuroglancer-statistics-panel-body>table>tbody tr:hover{background-color:#336}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */.neuroglancer-settings-body{flex-basis:0px;flex:1;height:0px;min-height:0px;font-family:sans-serif;display:flex;flex-direction:column;font-size:10pt}.neuroglancer-settings-body input[type=text],.neuroglancer-settings-body input[type=number]{background-color:#333;color:#fff;border:0px}.neuroglancer-settings-scroll-container{flex:1;flex-basis:0px;position:relative;overflow:auto;display:flex;flex-direction:column}.neuroglancer-settings-scroll-container>*{margin-top:3px}.neuroglancer-settings-title{align-self:stretch}.neuroglancer-settings-scroll-container>label{display:flex;flex-direction:row;justify-content:space-between}.neuroglancer-settings-scroll-container>label>input:before{flex:1;content:" "}.neuroglancer-settings-scroll-container>label>input{margin-left:5px;width:11ch}.neuroglancer-settings-limit-widget>input{width:11ch}/** + * @license + * Copyright 2018 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */.neuroglancer-annotation-tool-status{display:flex;flex-direction:row;align-items:center;overflow-x:scroll;scrollbar-width:none}.neuroglancer-annotation-tool-status::-webkit-scrollbar{display:none}.neuroglancer-annotation-tool-status-widget+.neuroglancer-annotation-tool-status-widget{margin-left:3px}.neuroglancer-annotation-tool-status-widget:hover{outline:1px solid #fff}.neuroglancer-annotation-tool-status-widget{display:flex;flex-direction:row;align-items:center}.neuroglancer-annotation-tool-status-widget-layer-number{display:inline-block;font:10pt sans-serif;font-weight:700;background-color:#9a7518}.neuroglancer-annotation-tool-status-widget-key{display:inline-block;font:9pt monospace;color:#0ff}.neuroglancer-annotation-tool-status-widget-key:before{content:"["}.neuroglancer-annotation-tool-status-widget-key:after{content:"]"}.neuroglancer-annotation-tool-status-widget-key:before,.neuroglancer-annotation-tool-status-widget-key:after{color:#999}.neuroglancer-annotation-tool-status-widget-description{display:inline-block;color:#3c3;font:10pt sans-serif;white-space:nowrap}.neuroglancer-annotation-tool-status-widget-delete{visibility:hidden}.neuroglancer-annotation-tool-status-widget:hover>.neuroglancer-annotation-tool-status-widget-delete{visibility:inherit} + +/*# sourceMappingURL=main.cb26101b553ed6b82856.css.map*/ \ No newline at end of file diff --git a/neuvue_project/workspace/static/spelunker-workspace/main.cb26101b553ed6b82856.css.map b/neuvue_project/workspace/static/spelunker-workspace/main.cb26101b553ed6b82856.css.map new file mode 100644 index 0000000..66436e3 --- /dev/null +++ b/neuvue_project/workspace/static/spelunker-workspace/main.cb26101b553ed6b82856.css.map @@ -0,0 +1 @@ +{"version":3,"file":"main.cb26101b553ed6b82856.css","mappings":"AAgBA,CAAC,sCACC,QAAS,KACT,eAAgB,OAChB,WAAY,IACd,CAEA,CANC,sCAMsC,CAAC,gCACtC,YAAa,CACf,CAEA,C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,CAAE,MACxC,QAAS,KACT,eAAgB,IAChB,gBAAiB,aACnB,CAEA,CAvBC,sCAuBuC,CAAE,KAAM,CAAE,KAAK,QACrD,KAAM,EACN,QAAS,GACX,CAEA,CA5BC,sCA4BuC,CAAE,KAAM,CAAE,MAChD,YAAa,IACb,MAAO,IACT,CAEA,CAAC,kCAAmC,CAAE,MACpC,MAAO,IACT,CCrEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAgBA,CAAC,oCACC,QAAS,KACT,eAAgB,IAChB,YAAa,OACb,WAAY,OACZ,gBAAiB,IACnB,CAEA,CARC,mCAQmC,oBAClC,QAAS,IACX,CAEA,CAAC,0C,EAAA,2CAEC,YAAa,GACf,CAEA,CALC,0CAK0C,OACzC,QAAS,IAAI,MAAM,IACrB,CAEA,CATC,2CAUC,QAAS,KACT,eAAgB,IAChB,YAAa,MACf,CAEA,CAAC,wDACC,QAAS,aACT,KAAM,KAAK,WACX,YAAa,IACb,iBAAkB,OACpB,CAEA,CAAC,+CACC,QAAS,aACT,KAAM,IAAI,UACV,MAAO,IACT,CAEA,CANC,8CAM8C,QAC7C,QAAS,GACX,CAEA,CAVC,8CAU8C,OAC7C,QAAS,GACX,CAEA,CAdC,8CAc8C,Q,CAd9C,8C,OAgBC,MAAO,IACT,CAEA,CAAC,uDACC,QAAS,aACT,MAAO,KACP,KAAM,KAAK,WACX,YAAa,MACf,CAEA,CAAC,kDACC,WAAY,MACd,CAEA,CApDC,0CAoD0C,M,EAJ1C,kDAMC,WAAY,OACd","sources":["webpack://neuroglancer/./src/layer/annotation/style.css","webpack://neuroglancer/./src/widget/transfer_function.css","webpack://neuroglancer/./src/widget/invlerp.css","webpack://neuroglancer/./src/widget/icon.css","webpack://neuroglancer/./src/widget/tab_view.css","webpack://neuroglancer/./src/widget/position_widget.css","webpack://neuroglancer/./src/status.css","webpack://neuroglancer/./src/ui/tool.css","webpack://neuroglancer/./src/widget/checkbox_icon.css","webpack://neuroglancer/./src/widget/position_plot.css","webpack://neuroglancer/./src/layer/segmentation/style.css","webpack://neuroglancer/./src/widget/layer_control.css","webpack://neuroglancer/./src/widget/range.css","webpack://neuroglancer/./src/widget/render_scale_widget.css","webpack://neuroglancer/./src/widget/segmentation_color_mode.css","webpack://neuroglancer/./src/ui/selection_details.css","webpack://neuroglancer/./src/ui/side_panel.css","webpack://neuroglancer/./src/ui/drag_and_drop.css","webpack://neuroglancer/./src/widget/eye_button.css","webpack://neuroglancer/./src/widget/star_button.css","webpack://neuroglancer/./src/ui/annotations.css","webpack://neuroglancer/./src/ui/segment_list.css","webpack://neuroglancer/./src/ui/segment_split_merge_tools.css","webpack://neuroglancer/./src/overlay.css","webpack://neuroglancer/./src/widget/linked_layer.css","webpack://neuroglancer/./src/widget/shader_code_widget.css","webpack://neuroglancer/./node_modules/codemirror/lib/codemirror.css","webpack://neuroglancer/./node_modules/codemirror/addon/lint/lint.css","webpack://neuroglancer/./src/ui/layer_data_sources_tab.css","webpack://neuroglancer/./src/widget/coordinate_transform.css","webpack://neuroglancer/./src/widget/multiline_autocomplete.css","webpack://neuroglancer/./src/layer/image/style.css","webpack://neuroglancer/./src/widget/channel_dimensions_widget.css","webpack://neuroglancer/./src/layer/single_mesh/style.css","webpack://neuroglancer/./src/datasource/graphene/graphene.css","webpack://neuroglancer/./src/ui/default_viewer.css","webpack://neuroglancer/./src/viewer.css","webpack://neuroglancer/./src/noselect.css","webpack://neuroglancer/./src/data_panel_layout.css","webpack://neuroglancer/./src/perspective_view/panel.css","webpack://neuroglancer/./src/rendered_data_panel.css","webpack://neuroglancer/./src/widget/display_dimensions_widget.css","webpack://neuroglancer/./src/help/input_event_bindings.css","webpack://neuroglancer/./src/layer_group_viewer.css","webpack://neuroglancer/./src/ui/context_menu.css","webpack://neuroglancer/./src/ui/layer_bar.css","webpack://neuroglancer/./src/layer_groups_layout.css","webpack://neuroglancer/./src/ui/layer_list_panel.css","webpack://neuroglancer/./src/ui/layer_side_panel.css","webpack://neuroglancer/./node_modules/codemirror/addon/fold/foldgutter.css","webpack://neuroglancer/./src/ui/state_editor.css","webpack://neuroglancer/./src/ui/statistics.css","webpack://neuroglancer/./src/ui/viewer_settings.css","webpack://neuroglancer/./src/widget/annotation_tool_status.css"],"sourcesContent":["/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-annotation-rendering-tab {\n display: flex;\n flex-direction: column;\n overflow-y: auto;\n}\n\n.neuroglancer-annotation-rendering-tab .neuroglancer-shader-code-widget {\n flex-shrink: 0;\n}\n\n.neuroglancer-annotation-shader-property-list {\n max-height: 8em;\n overflow: auto;\n flex-shrink: 0;\n}\n\n.neuroglancer-annotation-shader-property {\n white-space: pre;\n font-family: monospace;\n font-size: medium;\n}\n\n.neuroglancer-annotation-shader-property-type {\n color: #c6c;\n margin-right: 1ch;\n}\n\n.neuroglancer-annotation-shader-property-identifier {\n user-select: text;\n}\n\n.neuroglancer-annotation-shader-property-identifier::after {\n content: \"()\";\n color: #999;\n}\n\n.neuroglancer-annotation-tag-property-type {\n color: #999;\n}\n\n.neuroglancer-tag-list > div {\n display: grid;\n}\n\n.neuroglancer-add-tag-control > input,\n.neuroglancer-tag-list-entry > input {\n background-color: #151515;\n color: white;\n font-family: monospace;\n font-size: medium;\n border: 2px solid #333;\n padding: 2px;\n outline: 0px;\n}\n\n/* copy of .neuroglancer-annotation-layer-view */\n/* layer/annotation/style.css vs src/ui/annotations.css */\n.neuroglancer-tags-container {\n display: flex;\n flex-direction: column;\n flex: 1;\n align-items: stretch;\n}\n\n.neuroglancer-tag-list-outer {\n position: relative;\n margin: 0px;\n padding: 0px;\n margin-top: 2px;\n overflow-y: auto;\n height: 0px;\n flex: 1;\n flex-basis: 0px;\n min-height: 0px;\n}\n\n.neuroglancer-tag-list-entry {\n display: grid;\n grid-template-columns: min-content auto min-content;\n align-items: center;\n white-space: nowrap;\n padding: 2px 20px 2px 0;\n}\n\n.neuroglancer-tag-list-entry.add .neuroglancer-tool-button {\n visibility: hidden;\n}\n\n.neuroglancer-tag-list-entry:hover .neuroglancer-tag-list-entry-delete {\n visibility: visible;\n}\n\n.neuroglancer-tag-list-entry .neuroglancer-tag-list-entry-delete {\n visibility: hidden;\n}","/**\n * @license\n * Copyright 2024 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-transfer-function-panel {\n height: 60px;\n border: 1px solid #666;\n margin-top: 5px;\n}\n\n.neuroglancer-transfer-function-color-picker {\n text-align: right;\n}\n\n.neuroglancer-transfer-function-widget-bound {\n background-color: transparent;\n border-color: transparent;\n box-shadow: none;\n border: 0;\n margin: 0;\n font-family: monospace;\n font-size: medium;\n color: cyan;\n}\n\n.neuroglancer-transfer-function-window-bounds {\n display: flex;\n justify-content: space-between;\n}\n","/**\n * @license\n * Copyright 2020 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-invlerp-cdfpanel {\n height: 50px;\n cursor: ew-resize;\n}\n\n.neuroglancer-invlerp-cdfpanel,\n.neuroglancer-invlerp-legend-panel {\n border: 1px solid #666;\n}\n\n.neuroglancer-invlerp-legend-panel {\n height: 15px;\n}\n\n.neuroglancer-invlerp-widget-bound {\n background-color: transparent;\n border-color: transparent;\n box-shadow: none;\n border: 0;\n margin: 0;\n font-family: monospace;\n font-size: medium;\n}\n\n.neuroglancer-invlerp-widget-window-bound {\n color: cyan;\n}\n\n.neuroglancer-invlerp-widget-range-bound {\n color: white;\n}\n\n.neuroglancer-invlerp-widget-bounds {\n display: flex;\n}\n\n.neuroglancer-invlerp-widget-range-spacer {\n flex: 1;\n text-align: center;\n}\n\n.neuroglancer-invlerp-widget-window-bounds {\n justify-content: space-between;\n}\n","/**\n * @license\n * Copyright 2018 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n.neuroglancer-icon {\n display: inline-flex;\n text-decoration: none;\n align-self: center;\n white-space: nowrap;\n padding-left: 2px;\n padding-right: 2px;\n min-width: 18px;\n min-height: 18px;\n border-radius: 20%;\n align-items: center;\n justify-content: center;\n color: white;\n font: 12px sans-serif;\n cursor: pointer;\n font-weight: 900;\n margin-left: 1px;\n margin-right: 1px;\n user-select: none;\n}\n\n.neuroglancer-icon svg {\n width: 16px;\n height: 16px;\n fill: transparent;\n stroke: white;\n stroke-width: 2;\n stroke-linecap: round;\n stroke-linejoin: round;\n}\n\n.neuroglancer-icon:hover {\n background-color: #db4437;\n}\n\n.neuroglancer-icon-hover:not(:hover) svg:last-child {\n display: none;\n}\n\n.neuroglancer-icon-hover:hover svg:first-child {\n display: none;\n}\n","/**\n * @license\n * Copyright 2018 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-tab-view {\n display: flex;\n flex-direction: column;\n}\n\n.neuroglancer-tab-view-bar {\n display: block;\n background-color: #333;\n border-bottom: 1px solid white;\n}\n\n.neuroglancer-tab-label {\n display: inline-block;\n border-top: 1px solid transparent;\n border-left: 1px solid transparent;\n border-right: 1px solid transparent;\n border-bottom: none;\n margin-right: 4px;\n padding-top: 1px;\n padding-left: 2px;\n padding-right: 2px;\n font: 10pt sans-serif;\n font-weight: bold;\n cursor: pointer;\n}\n.neuroglancer-tab-label:hover {\n color: #daa520;\n}\n\n.neuroglancer-tab-label.neuroglancer-selected-tab-label {\n background-color: black;\n border-top: 1px solid white;\n border-left: 1px solid white;\n border-right: 1px solid white;\n border-bottom: 1px solid black;\n padding-bottom: 1px;\n margin-bottom: -1px;\n}\n\n.neuroglancer-stack-view {\n display: contents;\n}\n\n.neuroglancer-tab-view > .neuroglancer-stack-view > .neuroglancer-tab-content {\n flex: 1;\n flex-basis: 0px;\n height: 0px;\n min-height: 0px;\n padding: 2px;\n}\n","/**\n * @license\n * Copyright 2017 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-position-widget {\n display: inline-flex;\n align-items: center;\n}\n\n/* In Firefox, disabled input elements block all pointer events, even on parent elements, and that\ninterferes with our click handling. Setting `pointer-events: none;` avoids that problem. */\n.neuroglancer-position-widget input:disabled {\n pointer-events: none;\n}\n\n.neuroglancer-position-widget .neuroglancer-copy-button:first-child {\n display: none;\n}\n\n.neuroglancer-position-dimension-coordinate,\n.neuroglancer-position-dimension-name,\n.neuroglancer-position-dimension-scale {\n background-color: transparent;\n border-color: transparent;\n box-shadow: none;\n border: 0;\n margin: 0;\n font-family: monospace;\n font-size: medium;\n}\n\n.neuroglancer-position-dimension[data-coordinate-array=\"valid\"]\n .neuroglancer-position-dimension-scale {\n display: none;\n}\n\n.neuroglancer-position-dimension[data-coordinate-array=\"invalid\"]\n .neuroglancer-position-dimension-scale {\n text-decoration-line: underline;\n text-decoration-style: wavy;\n text-decoration-color: red;\n}\n\n.neuroglancer-position-dimension-coordinate {\n color: white;\n text-align: right;\n}\n\n.neuroglancer-position-widget input:invalid,\n.neuroglancer-position-widget input::placeholder,\n.neuroglancer-position-widget input[data-is-valid=\"false\"] {\n text-decoration: solid underline red;\n}\n\n.neuroglancer-position-widget *:focus {\n outline: 0px;\n}\n\n.neuroglancer-position-dimension + .neuroglancer-position-dimension {\n margin-left: 1ch;\n}\n\n.neuroglancer-position-dimension[data-dropdown-visible=\"true\"]::after {\n content: \"\";\n display: block;\n left: 0px;\n right: 0px;\n bottom: -1px;\n position: absolute;\n border-bottom: 1px solid black;\n z-index: 100;\n height: 0px;\n}\n\n.neuroglancer-position-dimension-dropdown,\n.neuroglancer-position-dimension-coordinate-dropdown {\n position: absolute;\n min-width: calc(100% + 2px);\n border: 1px solid #aaa;\n box-sizing: border-box;\n padding: 2px;\n left: -1px;\n z-index: 100;\n background-color: black;\n}\n\n.neuroglancer-position-dimension-coordinate-dropdown {\n display: flex;\n flex-direction: column;\n overflow-y: auto;\n}\n\n.neuroglancer-dimension-dropdown-coordinate-entry {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n}\n\n.neuroglancer-dimension-dropdown-coordinate-entry:hover {\n background-color: #333;\n}\n\n.neuroglancer-dimension-dropdown-coordinate-label {\n width: var(--neuroglancer-coordinate-label-width);\n color: #0ff;\n}\n\n.neuroglancer-position-dimension-dropdown:focus,\n.neuroglancer-position-dimension-coordinate-dropdown:focus {\n outline: 0px;\n}\n\n.neuroglancer-position-dimension:focus-within,\n.neuroglancer-position-dimension[data-dropdown-visible=\"true\"] {\n border: 1px solid #aaa;\n background-color: black;\n}\n\n.neuroglancer-position-dimension {\n border: 1px solid transparent;\n position: relative;\n display: inline-block;\n white-space: nowrap;\n}\n\n.neuroglancer-position-dimension-name {\n color: #ff6;\n padding-left: 2px;\n}\n\n.neuroglancer-position-dimension-scale-container[data-is-empty=\"false\"]::before {\n content: \"(\";\n color: #aaa;\n}\n\n.neuroglancer-position-dimension-scale-container[data-is-empty=\"false\"]::after {\n content: \")\";\n color: #aaa;\n}\n\n.neuroglancer-position-dimension-scale-container[data-is-empty=\"false\"] {\n margin-right: 5px;\n}\n\n.neuroglancer-position-dimension-scale {\n color: #bbb;\n}\n\n.neuroglancer-position-dimension-scale-container {\n margin-right: 2px;\n margin-left: 4px;\n}\n\n.neuroglancer-mouse-position-widget {\n margin-left: 1ch;\n vertical-align: center;\n font-family: monospace;\n font-size: medium;\n color: orange;\n white-space: pre;\n}\n\n.neuroglancer-position-dimension-coordinate-label {\n display: inline-block;\n color: #0ff;\n}\n\n.neuroglancer-position-dimension-coordinate-label:not(:empty)::before {\n content: \"[\";\n color: #aaa;\n}\n\n.neuroglancer-position-dimension-coordinate-label:not(:empty)::after {\n content: \"]\";\n color: #aaa;\n}\n\n.neuroglancer-position-dimension-playback {\n font-family: sans-serif;\n font-size: 10pt;\n display: flex;\n flex-direction: column;\n}\n\n.neuroglancer-position-dimension-playback .neuroglancer-number-input {\n display: flex;\n flex-direction: row;\n align-items: center;\n margin-bottom: 2px;\n}\n\n.neuroglancer-position-dimension-playback input[type=\"text\"] {\n background-color: rgba(255, 255, 255, 0.3);\n color: #fff;\n border: 0px;\n font-family: monospace;\n width: 8ch;\n text-align: right;\n}\n\n.neuroglancer-position-dimension-playback select {\n align-self: center;\n}\n\n.neuroglancer-position-dimension > .neuroglancer-icon {\n min-width: 14px;\n min-height: 14px;\n position: relative;\n top: 1px;\n}\n\n.neuroglancer-position-dimension > .neuroglancer-icon svg {\n width: 12px;\n height: 12px;\n}\n\n.neuroglancer-position-tool {\n background-color: #474747;\n}\n\n.neuroglancer-position-dimension-playback-header {\n display: flex;\n flex-direction: row;\n align-items: center;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#statusContainer {\n position: absolute;\n bottom: 0px;\n z-index: 100;\n background-color: #808080;\n color: white;\n margin: 0px;\n padding: 0px;\n font: 10pt sans-serif;\n}\n\n#statusContainer li {\n width: 100vw;\n max-height: 25vh;\n overflow-y: auto;\n}\n\n.neuroglancer-status-header {\n display: inline-block;\n font: 10pt sans-serif;\n font-weight: bold;\n background-color: #333;\n padding: 2px;\n}\n\n#statusContainerModal {\n pointer-events: none;\n position: absolute;\n z-index: 100;\n color: white;\n margin: 0px;\n padding: 0px;\n font: 10pt sans-serif;\n\n display: grid;\n align-content: center;\n justify-content: center;\n height: 100vh;\n width: 80vw;\n left: 10vw;\n grid-row-gap: 10px;\n}\n\n#statusContainerModal > div {\n pointer-events: initial;\n position: relative;\n background-color: #808080;\n padding: 20px;\n padding-top: 30px;\n}\n\n#statusContainerModal > div > div:first-child {\n position: absolute;\n top: 4px;\n right: 4px;\n margin: 0;\n padding: 0;\n}\n\n#statusContainerModal li {\n display: block;\n}\n","/**\n * @license\n * Copyright 2021 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-tool-key-binding {\n display: inline-block;\n color: #0ff;\n font: 9pt monospace;\n white-space: pre;\n}\n\n.neuroglancer-tool-key-binding:hover {\n outline: 1px solid #fff;\n}\n\n.neuroglancer-tool-key-binding::before {\n content: \"[\";\n}\n\n.neuroglancer-tool-key-binding::after {\n content: \"]\";\n}\n\n.neuroglancer-tool-key-binding::before,\n.neuroglancer-tool-key-binding::after {\n color: #999;\n}\n\n.neuroglancer-tool-button {\n display: inline-flex;\n flex-direction: row;\n}\n\n#statusContainer li.neuroglancer-tool-status {\n max-height: 50vh;\n}\n\n.neuroglancer-tool-status-bindings {\n background-color: #333;\n user-select: none;\n}\n\n.neuroglancer-tool-status-content {\n display: flex;\n flex-direction: row;\n}\n\n.neuroglancer-tool-status-header-container {\n background-color: #555;\n width: min-content;\n padding: 3px;\n display: flex;\n flex-direction: row;\n align-items: center;\n}\n\n.neuroglancer-tool-status-header {\n align-self: center;\n}\n\n.neuroglancer-tool-status-body {\n flex: 1;\n padding: 2px;\n}\n","/**\n * @license\n * Copyright 2020 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-checkbox-icon.light-background[data-checked=\"true\"] {\n background-color: rgba(0, 0, 0, 0.5);\n}\n\n.neuroglancer-checkbox-icon.dark-background[data-checked=\"true\"] {\n background-color: rgba(255, 255, 255, 0.2);\n}\n","/**\n * @license\n * Copyright 2017 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-position-dimension-plot {\n display: grid;\n overflow: hidden;\n position: relative;\n}\n\n.neuroglancer-position-dimension-plot[data-orientation=\"column\"] {\n grid-template-areas: \"labels . graph\";\n grid-template-rows: 1fr;\n grid-template-columns: 0fr 3px 0fr;\n}\n\n.neuroglancer-position-dimension-plot[data-orientation=\"row\"] {\n grid-template-areas:\n \"labels\"\n \".\"\n \"graph\";\n grid-template-columns: minmax(0px, 1fr);\n grid-template-rows: 0fr 3px 0fr;\n}\n\n.neuroglancer-position-dimension-plot-lowerbound,\n.neuroglancer-position-dimension-plot-upperbound,\n.neuroglancer-position-dimension-plot-hoverposition {\n grid-area: labels;\n font-family: monospace;\n font-size: medium;\n user-select: none;\n}\n\n.neuroglancer-position-dimension-plot[data-orientation=\"column\"]\n :is(\n .neuroglancer-position-dimension-plot-lowerbound,\n .neuroglancer-position-dimension-plot-upperbound,\n .neuroglancer-position-dimension-plot-hoverposition\n ) {\n text-align: right;\n}\n\n.neuroglancer-position-dimension-plot[data-orientation=\"row\"]\n :is(\n .neuroglancer-position-dimension-plot-lowerbound,\n .neuroglancer-position-dimension-plot-upperbound,\n .neuroglancer-position-dimension-plot-hoverposition\n ) {\n max-width: max-content;\n}\n\n.neuroglancer-position-dimension-plot > canvas {\n grid-area: graph;\n}\n\n.neuroglancer-position-dimension-plot[data-orientation=\"column\"] > canvas {\n margin-top: 0.5em;\n margin-bottom: 0.5em;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-segmentation-rendering-tab {\n display: flex;\n flex-direction: column;\n overflow-y: auto;\n}\n\n.neuroglancer-segmentation-rendering-tab .neuroglancer-shader-code-widget {\n height: 6em;\n}\n\n.neuroglancer-segmentation-dropdown-skeleton-shader-header {\n display: flex;\n flex-direction: row;\n align-items: center;\n}\n\n.neuroglancer-segmentation-layer-skeleton-shader-overlay\n .neuroglancer-shader-code-widget {\n width: 80vw;\n height: 80vh;\n}\n\n.neuroglancer-segment-list-entry {\n display: flex;\n flex-direction: row;\n width: min-content;\n min-width: 100%;\n background-color: black;\n align-items: start;\n}\n\n.neuroglancer-segment-list-entry.neuroglancer-segment-list-entry-double-line {\n display: inline-flex;\n min-width: initial;\n background-color: initial;\n}\n\n.neuroglancer-segment-list-entry[data-selected=\"true\"],\n.neuroglancer-selection-details-segment[data-selected=\"true\"] {\n background-color: #222;\n}\n\n.neuroglancer-segment-list-entry-copy-container {\n display: flex;\n flex-direction: column;\n}\n\n.neuroglancer-segment-list-entry-id-container {\n order: 1;\n align-self: center;\n}\n\n.neuroglancer-segment-list-entry-id,\n.neuroglancer-selection-details-segment-id {\n display: block;\n font-family: monospace;\n font-size: medium;\n flex-shrink: 0;\n text-align: right;\n color: black;\n background-color: white;\n user-select: text;\n width: var(--neuroglancer-segment-list-width);\n}\n\n.neuroglancer-segment-list .neuroglancer-segment-list-entry-sticky {\n position: sticky;\n left: 0;\n}\n\n.neuroglancer-segment-list-entry-sticky {\n white-space: nowrap;\n flex-direction: row;\n align-items: start;\n background-color: inherit;\n display: flex;\n}\n\n.neuroglancer-segment-list-entry.neuroglancer-segment-list-header\n .neuroglancer-segment-list-entry-star,\n.neuroglancer-segment-list-entry.neuroglancer-segment-list-header:hover\n .neuroglancer-segment-list-entry-copy {\n visibility: hidden;\n}\n\n.neuroglancer-segment-list-entry-extra-property {\n padding-left: 8px;\n flex-shrink: 0;\n text-align: right;\n user-select: text;\n}\n\n.neuroglancer-selection-details-segment-description,\n.neuroglancer-selection-details-segment-property {\n font-family: sans-serif;\n font-size: small;\n}\n\n.neuroglancer-selection-details-segment-property {\n display: flex;\n flex-direction: row;\n}\n\n.neuroglancer-selection-details-segment-property-name {\n user-select: text;\n font-style: italic;\n}\n\n.neuroglancer-selection-details-segment-property-value {\n text-align: right;\n flex: 1;\n}\n\n.neuroglancer-segmentation-toolbox {\n display: inline-block;\n}\n\n.neuroglancer-segmentation-toolbox\n .neuroglancer-tool-button\n + .neuroglancer-tool-button {\n margin-left: 1em;\n}\n\n.neuroglancer-segment-list-entry .neuroglancer-color-widget {\n border: none;\n border-color: transparent;\n appearance: none;\n background-color: transparent;\n padding: 0;\n margin: 0;\n margin-left: 3px;\n height: 19px;\n width: 20px;\n}\n\n.neuroglancer-segment-list-entry .neuroglancer-color-widget.overridden {\n background-color: white;\n}\n","/**\n * @license\n * Copyright 2021 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-layer-options-control-container\n .neuroglancer-layer-control-label-container {\n margin-right: auto;\n}\n\n.neuroglancer-layer-control-label-container {\n white-space: nowrap;\n}\n\n.neuroglancer-layer-control-label {\n display: flex;\n flex-direction: row;\n align-items: center;\n}\n\n.neuroglancer-layer-control-label-text-container {\n display: flex;\n flex-direction: row;\n align-items: start;\n}\n\n.neuroglancer-layer-control-container {\n margin-top: 1.5px;\n margin-bottom: 1.5px;\n display: flex;\n flex-direction: row;\n align-items: center;\n}\n\n.neuroglancer-layer-control-control {\n flex: 1;\n margin-left: 5px;\n max-width: 500px;\n}\n\nselect.neuroglancer-layer-control-control,\ninput[type=\"checkbox\"].neuroglancer-layer-control-control,\ninput[type=\"color\"].neuroglancer-layer-control-control {\n flex: initial;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.range-slider {\n display: flex;\n flex-direction: row;\n white-space: nowrap;\n justify-content: flex-end;\n}\n\n.range-slider input[type=\"range\"] {\n background: transparent;\n flex-basis: 0px;\n}\n\n.range-slider input[type=\"number\"] {\n background-color: rgba(255, 255, 255, 0.3);\n color: #fff;\n border: 0px;\n}\n\n.range-slider input[type=\"range\"]::-moz-range-track {\n background-color: white;\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-render-scale-widget {\n margin-top: 2px;\n margin-bottom: 2px;\n display: flex;\n flex-direction: row;\n align-items: center;\n}\n\n.neuroglancer-render-scale-widget-prompt {\n white-space: nowrap;\n}\n\n.neuroglancer-render-scale-widget > canvas {\n height: 36px;\n flex: 1;\n flex-basis: 0px;\n width: 0px;\n}\n\n.neuroglancer-render-scale-widget-legend {\n width: 15ch;\n font-size: 11px;\n text-align: right;\n}\n\n.neuroglancer-render-scale-widget-legend > div {\n height: 12px;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-segmentation-color-seed-control {\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: flex-end;\n}\n\n.neuroglancer-segmentation-color-seed-control input {\n background-color: rgba(255, 255, 255, 0.3);\n color: #fff;\n border: 0px;\n}\n","/**\n * @license\n * Copyright 2020 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-selection-details-body {\n height: 0px;\n flex: 1;\n overflow-y: auto;\n flex-basis: 0px;\n min-height: 0px;\n}\n\n.neuroglancer-selection-details-position {\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-items: left;\n font-family: monospace;\n font-size: medium;\n}\n\n.neuroglancer-selection-details-position-dimension\n + .neuroglancer-selection-details-position-dimension {\n margin-left: 8px;\n}\n\n.neuroglancer-selection-details-position-dimension-name {\n color: #ff6;\n}\n\n.neuroglancer-selection-details-position-dimension-coordinate {\n margin-left: 5px;\n user-select: text;\n}\n\n.neuroglancer-selection-details-layer {\n margin-top: 4px;\n margin-bottom: 4px;\n border: 1px solid #222;\n}\n\n.neuroglancer-selection-details-layer-title {\n cursor: pointer;\n background-color: #222;\n font-family: sans-serif;\n font-size: 10pt;\n}\n\n.neuroglancer-selection-details-layer-title:hover {\n background-color: #333;\n}\n\n.neuroglancer-selection-details-layer-body {\n padding: 2px;\n display: flex;\n flex-direction: column;\n}\n",".neuroglancer-side-panel-column {\n display: flex;\n flex-direction: column;\n min-width: 0px;\n}\n\n.neuroglancer-side-panel-row {\n display: flex;\n flex-direction: row;\n min-height: 0px;\n}\n\n.neuroglancer-side-panel {\n display: flex;\n flex-direction: column;\n min-width: 0px;\n overflow: hidden;\n}\n\n.neuroglancer-side-panel-titlebar {\n display: flex;\n flex-direction: row;\n align-items: center;\n font-family: sans-serif;\n font-size: 10pt;\n background-color: #03c;\n padding: 2px;\n color: white;\n}\n\n.neuroglancer-side-panel-title {\n flex: 1;\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n}\n\n.neuroglancer-side-panel-drop-zone {\n z-index: 1000;\n display: none;\n}\n\n[data-neuroglancer-side-panel-drag] .neuroglancer-side-panel-drop-zone {\n display: block;\n}\n\n.neuroglancer-resize-gutter-vertical {\n height: 1px;\n background-color: #333;\n background-clip: content-box;\n padding-top: 2px;\n padding-bottom: 2px;\n cursor: row-resize;\n}\n\n.neuroglancer-resize-gutter-horizontal {\n width: 1px;\n background-color: #333;\n background-clip: content-box;\n padding-right: 2px;\n padding-left: 2px;\n cursor: col-resize;\n}\n","/**\n * @license\n * Copyright 2021 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-drag-status {\n position: absolute;\n top: 0px;\n z-index: 1000;\n background-color: yellow;\n color: black;\n font: 10pt sans-serif;\n padding: 2px;\n}\n","/**\n * @license\n * Copyright 2023 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-eye-icon.neuroglancer-visible > svg > :last-child {\n display: none;\n}\n\n.neuroglancer-eye-icon.neuroglancer-indeterminate > svg > :last-child {\n stroke: rgba(255, 255, 255, 0.4);\n}\n","/**\n * @license\n * Copyright 2023 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-star-icon > svg {\n stroke: white;\n}\n\n.neuroglancer-star-icon.neuroglancer-starred > svg {\n fill: white;\n}\n\n.neuroglancer-star-icon.neuroglancer-indeterminate > svg {\n fill: rgba(255, 255, 255, 0.4);\n}\n","/**\n * @license\n * Copyright 2018 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-annotations-tab, .neuroglancer-annotation-layer-view, .neuroglancer-tags-tab {\n display: flex;\n align-items: stretch;\n flex: 1;\n flex-direction: column;\n}\n\n.neuroglancer-annotation-list {\n position: relative;\n margin: 0px;\n padding: 0px;\n margin-top: 2px;\n overflow-y: auto;\n height: 0px;\n flex: 1;\n flex-basis: 0px;\n min-height: 0px;\n}\n\n.neuroglancer-annotation-list-entry {\n display: grid;\n grid-auto-rows: min-content;\n cursor: pointer;\n justify-content: start;\n}\n\n.neuroglancer-annotation-position {\n display: contents;\n}\n\n.neuroglancer-annotation-list-header {\n grid-auto-rows: min-content;\n display: grid;\n padding-bottom: 2px;\n justify-content: start;\n}\n\n.neuroglancer-annotation-coordinate {\n font-family: monospace;\n text-align: right;\n}\n\n.neuroglancer-annotation-icon {\n grid-column: symbol;\n padding-right: 5px;\n}\n\n.neuroglancer-annotation-description, .neuroglancer-annotation-tags {\n grid-column: dim / -1;\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n}\n\n.neuroglancer-annotation-list-entry-delete {\n grid-column: delete;\n margin-left: 1ch;\n align-self: start;\n visibility: hidden;\n}\n\n.neuroglancer-annotation-list-entry:hover\n > .neuroglancer-annotation-list-entry-delete {\n visibility: visible;\n}\n\n.neuroglancer-annotation-hover {\n background-color: #333;\n}\n\n.neuroglancer-annotation-selected {\n background-color: #939;\n}\n\n.neuroglancer-annotation-hover.neuroglancer-annotation-selected {\n background-color: #969;\n}\n\n.neuroglancer-tab-content.neuroglancer-annotation-details {\n flex: 0 0 auto;\n align-self: stretch;\n display: flex;\n flex-direction: column;\n\n -webkit-touch-callout: default;\n -webkit-user-select: text;\n -khtml-user-select: text;\n -moz-user-select: text;\n -ms-user-select: text;\n user-select: text;\n}\n\n.neuroglancer-annotation-details-title {\n display: flex;\n flex-direction: row;\n background-color: #03c;\n align-self: stretch;\n padding: 2px;\n}\n\n.neuroglancer-voxel-coordinates-link {\n cursor: pointer;\n}\n\n.neuroglancer-voxel-coordinates-link:hover {\n background-color: #db4437;\n}\n\n.neuroglancer-annotation-details-icon {\n display: inline-block;\n margin-right: 5px;\n}\n\n.neuroglancer-annotation-details-title-text {\n display: inline-block;\n flex: 1;\n}\n\ntextarea.neuroglancer-annotation-details-description {\n align-self: stretch;\n background-color: #222;\n color: white;\n font: 10pt sans-serif;\n border: 0px;\n outline: 0px;\n resize: none;\n overflow-y: scroll;\n}\n\ndiv.neuroglancer-annotation-details-description {\n align-self: stretch;\n color: white;\n font: 10pt sans-serif;\n}\n\n.neuroglancer-annotation-details-position {\n}\n\n.neuroglancer-annotation-toolbox {\n display: flex;\n align-items: stretch;\n}\n\n.neuroglancer-annotation-segment-list {\n}\n\n.neuroglancer-annotation-segment-item {\n color: black;\n background-color: white;\n}\n\n.neuroglancer-annotations-view-dimension {\n font-family: monospace;\n text-align: right;\n}\n\n.neuroglancer-annotations-view-dimension-name {\n color: #ff6;\n}\n\n.neuroglancer-annotations-view-dimension-scale {\n color: #bbb;\n}\n\n.neuroglancer-annotations-view-dimension-scale:not(:empty)::before {\n content: \"(\";\n margin-left: 1ch;\n}\n\n.neuroglancer-annotations-view-dimension-scale:not(:empty)::after {\n content: \")\";\n}\n\n.neuroglancer-annotation-relationship-label,\n.neuroglancer-annotation-property-label {\n margin-right: 5px;\n}\n\n.neuroglancer-selected-annotation-details-position-grid {\n display: grid;\n grid-auto-rows: auto;\n font-family: monospace;\n font-size: medium;\n grid-auto-flow: dense;\n}\n\n.neuroglancer-selected-annotation-details-icon {\n grid-rows: 1 / -1;\n grid-column: icon;\n align-self: start;\n}\n\n.neuroglancer-selected-annotation-details-delete {\n grid-rows: 1 / -1;\n grid-column: delete;\n align-self: start;\n}\n\n.neuroglancer-selected-annotation-details-position-dim {\n color: #ff6;\n margin-left: 1ch;\n}\n\n.neuroglancer-selected-annotation-details-position-coord {\n text-align: right;\n margin-left: 0.5ch;\n}\n\n.neuroglancer-related-segment-list-title {\n font-family: sans-serif;\n font-size: small;\n background-color: #333;\n}\n\n.neuroglancer-related-segment-list-header {\n display: flex;\n flex-direction: row;\n}\n\n.neuroglancer-related-segment-list {\n /* border: 1px solid #333;\n margin: 3px;*/\n}\n\n.neuroglancer-annotation-property {\n display: flex;\n flex-direction: row;\n font-family: sans-serif;\n font-size: small;\n user-select: text;\n}\n\n.neuroglancer-annotation-property-label {\n color: #999;\n}\n\n.neuroglancer-annotation-property-value {\n text-align: right;\n font-family: monospace;\n font-size: medium;\n flex: 1;\n}\n\ninput.neuroglancer-segment-list-entry-id {\n outline: 0px;\n border: 0px;\n text-align: left;\n}\n\n.neuroglancer-segment-list-entry-new > .neuroglancer-segment-list-entry-copy {\n visibility: hidden;\n}\n\n.neuroglancer-segment-list-entry-new > input[type=\"checkbox\"] {\n visibility: hidden;\n}\n\n.neuroglancer-selection-annotation-status {\n font-family: sans-serif;\n font-size: small;\n}\n","/**\n * @license\n * Copyright 2020 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n:root {\n --neuroglancer-segment-list-width: auto;\n}\n\n.neuroglancer-segment-list {\n position: relative;\n overflow-y: auto;\n overflow-x: auto;\n flex: 1;\n}\n\n.neuroglancer-segment-display-tab {\n display: flex;\n flex-direction: column;\n}\n\n.neuroglancer-segment-query-errors {\n margin: 0px;\n list-style-type: none;\n padding: 0px;\n padding-left: 3px;\n background-color: #333;\n}\n\n.neuroglancer-segment-query-errors > li {\n display: block;\n color: red;\n}\n\n.neuroglancer-segment-list-entry:not(\n .neuroglancer-segment-list-entry-double-line\n )\n .neuroglancer-segment-list-entry-unmapped-id:empty\n + .neuroglancer-segment-list-entry-copy {\n display: none;\n}\n\n.neuroglancer-segment-list-entry.neuroglancer-segment-list-entry-double-line\n .neuroglancer-segment-list-entry-unmapped-id:empty\n + .neuroglancer-segment-list-entry-copy {\n visibility: hidden;\n}\n\n.neuroglancer-segment-list-entry-name:empty\n + .neuroglancer-segment-list-entry-filter {\n display: none;\n}\n\n.neuroglancer-segment-list-entry-name {\n order: 1000;\n display: inline-block;\n font-family: monospace;\n font-size: medium;\n user-select: text;\n white-space: nowrap;\n}\n\n.neuroglancer-segment-list-query {\n background-color: #151515;\n color: white;\n font-family: monospace;\n font-size: medium;\n border: 2px solid #333;\n padding: 2px;\n outline: 0px;\n}\n\n.neuroglancer-segment-list-query::placeholder {\n color: #aaa;\n}\n\n.neuroglancer-segment-list-status {\n display: flex;\n flex-direction: row;\n align-items: center;\n background-color: #333;\n}\n\n.neuroglancer-segment-list-entry-copy {\n order: -2;\n visibility: hidden;\n}\n\n.neuroglancer-segment-list-entry:hover .neuroglancer-segment-list-entry-copy {\n visibility: visible;\n}\n\n.neuroglancer-segment-list\n .neuroglancer-segment-list-entry:not(:hover)\n .neuroglancer-star-icon:not(.neuroglancer-starred) {\n visibility: hidden;\n}\n\n.neuroglancer-segment-list\n .neuroglancer-segment-list-entry:not(:hover)\n .neuroglancer-eye-icon:not(.neuroglancer-visible) {\n visibility: hidden;\n}\n\n.neuroglancer-segment-list-entry-visible-checkbox {\n order: 1;\n}\n\n.neuroglancer-segment-list-entry-filter {\n visibility: hidden;\n grid-column: filter;\n order: 999;\n}\n\n.neuroglancer-segment-list-entry:hover .neuroglancer-segment-list-entry-filter {\n visibility: visible;\n}\n\n.neuroglancer-segment-query-result-tag-list {\n display: grid;\n grid-auto-rows: auto;\n grid-template-columns: [include] min-content [exclude] min-content [tag] 1fr [count] min-content;\n}\n\n.neuroglancer-segment-query-result-tag {\n display: contents;\n}\n\n.neuroglancer-segment-query-result-tag:hover * {\n background-color: #222;\n}\n\n.neuroglancer-segment-query-result-tag-name {\n grid-column: tag;\n white-space: nowrap;\n cursor: pointer;\n font-weight: bold;\n}\n\n.neuroglancer-segment-query-result-tag-name::before {\n content: \"#\";\n color: #aaa;\n font-weight: normal;\n}\n\n.neuroglancer-segment-query-result-tag-toggle {\n display: inline-block;\n white-space: nowrap;\n}\n\n.neuroglancer-segment-query-result-tag-include {\n grid-column: include;\n}\n\n.neuroglancer-segment-query-result-tag-exclude {\n grid-column: exclude;\n}\n\n.neuroglancer-segment-query-result-statistics {\n background-color: #333;\n max-height: 30%;\n flex-shrink: 0;\n overflow: auto;\n}\n\n.neuroglancer-segment-query-result-statistics:not(:empty) {\n padding-top: 3px;\n}\n\n.neuroglancer-segment-query-result-statistics:not(:empty)\n + .neuroglancer-segment-list-status {\n border-top: 1px solid white;\n}\n\n.neuroglancer-segment-query-result-statistics-separator {\n height: 3px;\n background-color: #333;\n border-bottom: 1px solid white;\n}\n\n.neuroglancer-segment-query-result-tag-count {\n grid-column: count;\n text-align: right;\n}\n\n.neuroglancer-segment-query-result-tag-count:not(:empty)::before {\n content: \"(\";\n color: #aaa;\n}\n\n.neuroglancer-segment-query-result-tag-count:not(:empty)::after {\n content: \")\";\n color: #aaa;\n}\n\n.neuroglancer-segment-query-result-numerical-list {\n display: flex;\n flex-direction: column;\n}\n\n.neuroglancer-segment-query-result-numerical-plot-container {\n justify-self: stretch;\n display: flex;\n flex-direction: column;\n padding: 2px;\n}\n\n.neuroglancer-segment-query-result-numerical-plot {\n display: block;\n height: 30px;\n cursor: ew-resize;\n justify-self: stretch;\n border: 1px solid #666;\n}\n\n.neuroglancer-segment-query-result-numerical-plot-bound {\n background-color: transparent;\n border-color: transparent;\n box-shadow: none;\n border: 0;\n margin: 0;\n font: 10pt sans-serif;\n pointer-events: auto;\n}\n\n.neuroglancer-segment-query-result-numerical-plot-window-bound {\n color: cyan;\n}\n\n.neuroglancer-segment-query-result-numerical-plot-range-bound {\n color: white;\n}\n\n.neuroglancer-segment-query-result-numerical-plot-bounds {\n display: flex;\n flex-direction: row;\n color: #aaa;\n}\n\n.neuroglancer-segment-query-result-numerical-plot-bound-constraint-symbol {\n align-self: center;\n}\n\n.neuroglancer-segment-query-result-numerical-plot-bound-constraint-spacer {\n flex: 1;\n color: white;\n font-weight: bold;\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n}\n\n.neuroglancer-segment-query-result-numerical-plot-label {\n cursor: pointer;\n}\n\n.neuroglancer-segment-query-result-numerical-plot-sort,\n.neuroglancer-segment-list-header-label-sort {\n visibility: hidden;\n}\n\n.neuroglancer-segment-query-result-numerical-plot-label:hover\n .neuroglancer-segment-query-result-numerical-plot-sort,\n.neuroglancer-segment-list-header-label:hover\n .neuroglancer-segment-list-header-label-sort {\n visibility: visible;\n}\n\n.neuroglancer-segment-query-result-numerical-plot-container:hover\n .neuroglancer-segment-query-result-numerical-plot-bounds-window {\n visibility: visible;\n}\n\n.neuroglancer-segment-query-result-numerical-plot-bounds-window {\n justify-content: space-between;\n margin-top: -16px;\n visibility: hidden;\n pointer-events: none;\n}\n\n.neuroglancer-segment-list-entry.neuroglancer-segment-list-header {\n background-color: #666;\n}\n\n.neuroglancer-segment-list-header .neuroglancer-segment-list-entry-id {\n background-color: inherit;\n color: white;\n text-align: center;\n}\n\n.neuroglancer-segment-list-header-label {\n cursor: pointer;\n font: 10pt sans-serif;\n}\n\n.neuroglancer-segment-list-header\n .neuroglancer-segment-list-entry-extra-property {\n text-align: center;\n}\n\n.neuroglancer-segment-list-status-message {\n overflow: hidden;\n white-space: nowrap;\n}\n","/**\n * @license\n * Copyright 2021 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-merge-segments-status {\n display: flex;\n flex-direction: row;\n}\n\n.neuroglancer-merge-segments-status .neuroglancer-segment-list-entry {\n margin-left: 1em;\n margin-right: 1em;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.overlay {\n height: 100%;\n width: 100%;\n position: fixed;\n z-index: 99;\n top: 0;\n left: 0;\n background-color: rgba(0, 0, 0, 0.8);\n}\n\n.overlay-content {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n background-color: white;\n z-index: 100;\n color: black;\n padding: 1em;\n}\n","/**\n * @license\n * Copyright 2020 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-linked-layer-widget-layer {\n display: flex;\n flex-direction: row;\n}\n\n.neuroglancer-linked-layer-widget-layer:hover {\n background-color: #333;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-shader-code-widget.invalid-input {\n border: 1px solid red;\n}\n\n.neuroglancer-shader-code-widget.valid-input {\n border: 1px solid green;\n}\n\n.neuroglancer-shader-code-widget {\n border: 1px solid transparent;\n}\n","/* BASICS */\n\n.CodeMirror {\n /* Set height, width, borders, and global font properties here */\n font-family: monospace;\n height: 300px;\n color: black;\n direction: ltr;\n}\n\n/* PADDING */\n\n.CodeMirror-lines {\n padding: 4px 0; /* Vertical padding around content */\n}\n.CodeMirror pre.CodeMirror-line,\n.CodeMirror pre.CodeMirror-line-like {\n padding: 0 4px; /* Horizontal padding of content */\n}\n\n.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {\n background-color: white; /* The little square between H and V scrollbars */\n}\n\n/* GUTTER */\n\n.CodeMirror-gutters {\n border-right: 1px solid #ddd;\n background-color: #f7f7f7;\n white-space: nowrap;\n}\n.CodeMirror-linenumbers {}\n.CodeMirror-linenumber {\n padding: 0 3px 0 5px;\n min-width: 20px;\n text-align: right;\n color: #999;\n white-space: nowrap;\n}\n\n.CodeMirror-guttermarker { color: black; }\n.CodeMirror-guttermarker-subtle { color: #999; }\n\n/* CURSOR */\n\n.CodeMirror-cursor {\n border-left: 1px solid black;\n border-right: none;\n width: 0;\n}\n/* Shown when moving in bi-directional text */\n.CodeMirror div.CodeMirror-secondarycursor {\n border-left: 1px solid silver;\n}\n.cm-fat-cursor .CodeMirror-cursor {\n width: auto;\n border: 0 !important;\n background: #7e7;\n}\n.cm-fat-cursor div.CodeMirror-cursors {\n z-index: 1;\n}\n.cm-fat-cursor .CodeMirror-line::selection,\n.cm-fat-cursor .CodeMirror-line > span::selection, \n.cm-fat-cursor .CodeMirror-line > span > span::selection { background: transparent; }\n.cm-fat-cursor .CodeMirror-line::-moz-selection,\n.cm-fat-cursor .CodeMirror-line > span::-moz-selection,\n.cm-fat-cursor .CodeMirror-line > span > span::-moz-selection { background: transparent; }\n.cm-fat-cursor { caret-color: transparent; }\n@-moz-keyframes blink {\n 0% {}\n 50% { background-color: transparent; }\n 100% {}\n}\n@-webkit-keyframes blink {\n 0% {}\n 50% { background-color: transparent; }\n 100% {}\n}\n@keyframes blink {\n 0% {}\n 50% { background-color: transparent; }\n 100% {}\n}\n\n/* Can style cursor different in overwrite (non-insert) mode */\n.CodeMirror-overwrite .CodeMirror-cursor {}\n\n.cm-tab { display: inline-block; text-decoration: inherit; }\n\n.CodeMirror-rulers {\n position: absolute;\n left: 0; right: 0; top: -50px; bottom: 0;\n overflow: hidden;\n}\n.CodeMirror-ruler {\n border-left: 1px solid #ccc;\n top: 0; bottom: 0;\n position: absolute;\n}\n\n/* DEFAULT THEME */\n\n.cm-s-default .cm-header {color: blue;}\n.cm-s-default .cm-quote {color: #090;}\n.cm-negative {color: #d44;}\n.cm-positive {color: #292;}\n.cm-header, .cm-strong {font-weight: bold;}\n.cm-em {font-style: italic;}\n.cm-link {text-decoration: underline;}\n.cm-strikethrough {text-decoration: line-through;}\n\n.cm-s-default .cm-keyword {color: #708;}\n.cm-s-default .cm-atom {color: #219;}\n.cm-s-default .cm-number {color: #164;}\n.cm-s-default .cm-def {color: #00f;}\n.cm-s-default .cm-variable,\n.cm-s-default .cm-punctuation,\n.cm-s-default .cm-property,\n.cm-s-default .cm-operator {}\n.cm-s-default .cm-variable-2 {color: #05a;}\n.cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;}\n.cm-s-default .cm-comment {color: #a50;}\n.cm-s-default .cm-string {color: #a11;}\n.cm-s-default .cm-string-2 {color: #f50;}\n.cm-s-default .cm-meta {color: #555;}\n.cm-s-default .cm-qualifier {color: #555;}\n.cm-s-default .cm-builtin {color: #30a;}\n.cm-s-default .cm-bracket {color: #997;}\n.cm-s-default .cm-tag {color: #170;}\n.cm-s-default .cm-attribute {color: #00c;}\n.cm-s-default .cm-hr {color: #999;}\n.cm-s-default .cm-link {color: #00c;}\n\n.cm-s-default .cm-error {color: #f00;}\n.cm-invalidchar {color: #f00;}\n\n.CodeMirror-composing { border-bottom: 2px solid; }\n\n/* Default styles for common addons */\n\ndiv.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;}\ndiv.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}\n.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }\n.CodeMirror-activeline-background {background: #e8f2ff;}\n\n/* STOP */\n\n/* The rest of this file contains styles related to the mechanics of\n the editor. You probably shouldn't touch them. */\n\n.CodeMirror {\n position: relative;\n overflow: hidden;\n background: white;\n}\n\n.CodeMirror-scroll {\n overflow: scroll !important; /* Things will break if this is overridden */\n /* 50px is the magic margin used to hide the element's real scrollbars */\n /* See overflow: hidden in .CodeMirror */\n margin-bottom: -50px; margin-right: -50px;\n padding-bottom: 50px;\n height: 100%;\n outline: none; /* Prevent dragging from highlighting the element */\n position: relative;\n z-index: 0;\n}\n.CodeMirror-sizer {\n position: relative;\n border-right: 50px solid transparent;\n}\n\n/* The fake, visible scrollbars. Used to force redraw during scrolling\n before actual scrolling happens, thus preventing shaking and\n flickering artifacts. */\n.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {\n position: absolute;\n z-index: 6;\n display: none;\n outline: none;\n}\n.CodeMirror-vscrollbar {\n right: 0; top: 0;\n overflow-x: hidden;\n overflow-y: scroll;\n}\n.CodeMirror-hscrollbar {\n bottom: 0; left: 0;\n overflow-y: hidden;\n overflow-x: scroll;\n}\n.CodeMirror-scrollbar-filler {\n right: 0; bottom: 0;\n}\n.CodeMirror-gutter-filler {\n left: 0; bottom: 0;\n}\n\n.CodeMirror-gutters {\n position: absolute; left: 0; top: 0;\n min-height: 100%;\n z-index: 3;\n}\n.CodeMirror-gutter {\n white-space: normal;\n height: 100%;\n display: inline-block;\n vertical-align: top;\n margin-bottom: -50px;\n}\n.CodeMirror-gutter-wrapper {\n position: absolute;\n z-index: 4;\n background: none !important;\n border: none !important;\n}\n.CodeMirror-gutter-background {\n position: absolute;\n top: 0; bottom: 0;\n z-index: 4;\n}\n.CodeMirror-gutter-elt {\n position: absolute;\n cursor: default;\n z-index: 4;\n}\n.CodeMirror-gutter-wrapper ::selection { background-color: transparent }\n.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }\n\n.CodeMirror-lines {\n cursor: text;\n min-height: 1px; /* prevents collapsing before first draw */\n}\n.CodeMirror pre.CodeMirror-line,\n.CodeMirror pre.CodeMirror-line-like {\n /* Reset some styles that the rest of the page might have set */\n -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;\n border-width: 0;\n background: transparent;\n font-family: inherit;\n font-size: inherit;\n margin: 0;\n white-space: pre;\n word-wrap: normal;\n line-height: inherit;\n color: inherit;\n z-index: 2;\n position: relative;\n overflow: visible;\n -webkit-tap-highlight-color: transparent;\n -webkit-font-variant-ligatures: contextual;\n font-variant-ligatures: contextual;\n}\n.CodeMirror-wrap pre.CodeMirror-line,\n.CodeMirror-wrap pre.CodeMirror-line-like {\n word-wrap: break-word;\n white-space: pre-wrap;\n word-break: normal;\n}\n\n.CodeMirror-linebackground {\n position: absolute;\n left: 0; right: 0; top: 0; bottom: 0;\n z-index: 0;\n}\n\n.CodeMirror-linewidget {\n position: relative;\n z-index: 2;\n padding: 0.1px; /* Force widget margins to stay inside of the container */\n}\n\n.CodeMirror-widget {}\n\n.CodeMirror-rtl pre { direction: rtl; }\n\n.CodeMirror-code {\n outline: none;\n}\n\n/* Force content-box sizing for the elements where we expect it */\n.CodeMirror-scroll,\n.CodeMirror-sizer,\n.CodeMirror-gutter,\n.CodeMirror-gutters,\n.CodeMirror-linenumber {\n -moz-box-sizing: content-box;\n box-sizing: content-box;\n}\n\n.CodeMirror-measure {\n position: absolute;\n width: 100%;\n height: 0;\n overflow: hidden;\n visibility: hidden;\n}\n\n.CodeMirror-cursor {\n position: absolute;\n pointer-events: none;\n}\n.CodeMirror-measure pre { position: static; }\n\ndiv.CodeMirror-cursors {\n visibility: hidden;\n position: relative;\n z-index: 3;\n}\ndiv.CodeMirror-dragcursors {\n visibility: visible;\n}\n\n.CodeMirror-focused div.CodeMirror-cursors {\n visibility: visible;\n}\n\n.CodeMirror-selected { background: #d9d9d9; }\n.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }\n.CodeMirror-crosshair { cursor: crosshair; }\n.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }\n.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }\n\n.cm-searching {\n background-color: #ffa;\n background-color: rgba(255, 255, 0, .4);\n}\n\n/* Used to force a border model for a node */\n.cm-force-border { padding-right: .1px; }\n\n@media print {\n /* Hide the cursor when printing */\n .CodeMirror div.CodeMirror-cursors {\n visibility: hidden;\n }\n}\n\n/* See issue #2901 */\n.cm-tab-wrap-hack:after { content: ''; }\n\n/* Help users use markselection to safely style text background */\nspan.CodeMirror-selectedtext { background: none; }\n","/* The lint marker gutter */\n.CodeMirror-lint-markers {\n width: 16px;\n}\n\n.CodeMirror-lint-tooltip {\n background-color: #ffd;\n border: 1px solid black;\n border-radius: 4px 4px 4px 4px;\n color: black;\n font-family: monospace;\n font-size: 10pt;\n overflow: hidden;\n padding: 2px 5px;\n position: fixed;\n white-space: pre;\n white-space: pre-wrap;\n z-index: 100;\n max-width: 600px;\n opacity: 0;\n transition: opacity .4s;\n -moz-transition: opacity .4s;\n -webkit-transition: opacity .4s;\n -o-transition: opacity .4s;\n -ms-transition: opacity .4s;\n}\n\n.CodeMirror-lint-mark {\n background-position: left bottom;\n background-repeat: repeat-x;\n}\n\n.CodeMirror-lint-mark-warning {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII=\");\n}\n\n.CodeMirror-lint-mark-error {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg==\");\n}\n\n.CodeMirror-lint-marker {\n background-position: center center;\n background-repeat: no-repeat;\n cursor: pointer;\n display: inline-block;\n height: 16px;\n width: 16px;\n vertical-align: middle;\n position: relative;\n}\n\n.CodeMirror-lint-message {\n padding-left: 18px;\n background-position: top left;\n background-repeat: no-repeat;\n}\n\n.CodeMirror-lint-marker-warning, .CodeMirror-lint-message-warning {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII=\");\n}\n\n.CodeMirror-lint-marker-error, .CodeMirror-lint-message-error {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII=\");\n}\n\n.CodeMirror-lint-marker-multiple {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAMAAADzjKfhAAAACVBMVEUAAAAAAAC/v7914kyHAAAAAXRSTlMAQObYZgAAACNJREFUeNo1ioEJAAAIwmz/H90iFFSGJgFMe3gaLZ0od+9/AQZ0ADosbYraAAAAAElFTkSuQmCC\");\n background-repeat: no-repeat;\n background-position: right bottom;\n width: 100%; height: 100%;\n}\n\n.CodeMirror-lint-line-error {\n background-color: rgba(183, 76, 81, 0.08);\n}\n\n.CodeMirror-lint-line-warning {\n background-color: rgba(255, 211, 0, 0.1);\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-layer-data-sources-tab {\n display: flex;\n flex-direction: column;\n}\n\n.neuroglancer-layer-data-sources-container {\n overflow-y: auto;\n display: flex;\n flex-direction: column;\n flex: 1;\n height: 0px;\n z-index: 1;\n}\n\n.neuroglancer-layer-data-source-url-input input.autocomplete-input {\n color: #fff;\n}\n\n.neuroglancer-layer-data-source-url-input input.autocomplete-hint {\n color: #aaa;\n}\n\n.neuroglancer-layer-data-source-url-input .autocomplete-dropdown {\n background-color: #333;\n}\n\n.neuroglancer-layer-data-sources-source-id {\n font-weight: bold;\n}\n\n.neuroglancer-layer-data-sources-source-id:not(:empty)::before {\n content: \"[\";\n}\n\n.neuroglancer-layer-data-sources-source-id:not(:empty)::after {\n content: \"]\";\n}\n\n.neuroglancer-layer-data-sources-source-id:not(:empty) {\n margin-right: 4px;\n color: #0ff;\n}\n\n.neuroglancer-layer-data-sources-source-type {\n}\n\n.neuroglancer-layer-data-sources-source-messages:empty {\n display: none;\n}\n\n.neuroglancer-layer-data-sources-source-messages {\n margin-top: 0px;\n list-style: none;\n padding-left: 0px;\n}\n\nli.neuroglancer-message {\n word-wrap: break-word;\n user-select: text;\n}\n\nli.neuroglancer-message-error {\n color: red;\n}\n\nli.neuroglancer-message-warning {\n color: yellow;\n}\n\nli.neuroglancer-message-info {\n color: #ccc;\n}\n\n.neuroglancer-layer-data-sources-source-default {\n display: block;\n margin-bottom: 4px;\n}\n\n.neuroglancer-layer-data-sources-info-line[data-is-active=\"false\"] {\n text-decoration: solid line-through #caa;\n}\n\n.neuroglancer-layer-data-sources-tab-type-detection {\n position: sticky;\n bottom: 0px;\n background-color: #ff9;\n color: black;\n text-align: center;\n cursor: pointer;\n}\n\n.neuroglancer-layer-data-sources-tab-type-detection:hover {\n background-color: #ffc;\n}\n\n.neuroglancer-layer-data-sources-tab-type-detection-type {\n font-weight: bold;\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-coordinate-space-transform-widget {\n display: grid;\n justify-items: stretch;\n}\n\n.neuroglancer-coordinate-space-transform-widget input {\n font-family: monospace;\n justify-self: stretch;\n background-color: black;\n color: white;\n padding: 2px;\n}\n\n.neuroglancer-coordinate-space-transform-widget *[data-will-be-deleted=\"true\"] {\n color: #666;\n}\n\n.neuroglancer-coordinate-space-transform-label {\n font-style: italic;\n color: #fcc;\n align-self: center;\n}\n\n.neuroglancer-coordinate-space-transform-input-lower-label {\n grid-row: sourceLower;\n grid-column: outputLabel / sourceDim 1;\n}\n\n.neuroglancer-coordinate-space-transform-translation-label {\n grid-row: sourceLabel / outputDim 1;\n grid-column: sourceDim -1;\n writing-mode: vertical-lr;\n text-orientation: mixed;\n align-self: end;\n justify-self: center;\n margin-bottom: 2px;\n}\n\n.neuroglancer-coordinate-space-transform-input-lower-label,\n.neuroglancer-coordinate-space-transform-input-upper-label,\n.neuroglancer-coordinate-space-transform-input-scale-label {\n text-align: right;\n margin-right: 4px;\n}\n\n.neuroglancer-coordinate-space-transform-input-upper-label {\n grid-row: sourceUpper;\n grid-column: headerStart / headerEnd;\n}\n\n.neuroglancer-coordinate-space-transform-input-scale-label {\n grid-row: 5;\n grid-column: headerStart / headerEnd;\n}\n\n.neuroglancer-coordinate-space-transform-source-label {\n grid-row: sourceLabel;\n grid-column: sourceDim 1 / sourceDim -1;\n text-align: center;\n}\n\n.neuroglancer-coordinate-space-transform-output-label {\n grid-row: outputDim 1 / outputDim -1;\n grid-column: outputLabel;\n writing-mode: vertical-lr;\n text-orientation: mixed;\n align-self: center;\n justify-self: end;\n margin-right: 2px;\n}\n\n.neuroglancer-coordinate-space-transform-input-name {\n text-align: center;\n}\n\n.neuroglancer-coordinate-space-transform-input-name,\ninput.neuroglancer-coordinate-space-transform-output-name {\n font-family: monospace;\n color: #ff6;\n}\n\n.neuroglancer-coordinate-space-transform-scale {\n text-align: right;\n}\n\n.neuroglancer-coordinate-space-transform-input-bounds,\n.neuroglancer-coordinate-space-transform-output-bounds {\n white-space: nowrap;\n font-family: monospace;\n font-size: small;\n text-align: right;\n padding-left: 2px;\n padding-right: 2px;\n color: #aff;\n}\n\n.neuroglancer-coordinate-space-transform-input-bounds.neuroglancer-coordinate-space-transform-singleton:not(\n *[data-will-be-deleted=\"true\"]\n ) {\n color: #fa6;\n}\n\n.neuroglancer-coordinate-space-transform-widget input[data-is-valid=\"false\"],\n.neuroglancer-coordinate-space-transform-widget\n input[data-is-valid=\"false\"]::placeholder {\n text-decoration: solid underline red;\n}\n\n.neuroglancer-coordinate-space-transform-output-extend {\n grid-row: outputDim -1;\n grid-column: outputNames;\n display: flex;\n flex-direction: column;\n}\n\n.neuroglancer-coordinate-space-transform-output-extend input {\n align-self: stretch;\n}\n\n.neuroglancer-coordinate-space-transform-output-extend[data-is-active=\"false\"]\n input {\n display: none;\n}\n\n.neuroglancer-coordinate-space-transform-output-extend[data-is-active=\"true\"]\n .neuroglancer-icon {\n display: none;\n}\n\n.neuroglancer-coordinate-space-transform-output-extend .neuroglancer-icon {\n align-self: start;\n}\n\n.neuroglancer-coordinate-space-transform-translation-coeff {\n margin-left: 3px;\n}\n\n.neuroglancer-coordinate-space-transform-output-scale-container {\n margin-right: 3px;\n}\n\n.neuroglancer-coordinate-space-transform-input-scale-container,\n.neuroglancer-coordinate-space-transform-input-scale-label {\n margin-bottom: 3px;\n}\n\n.neuroglancer-coordinate-space-transform-widget input,\n.neuroglancer-coordinate-space-transform-output-name-container,\n.neuroglancer-coordinate-space-transform-scale-container {\n border: 1px solid #333;\n}\n\n.neuroglancer-coordinate-space-transform-widget\n .neuroglancer-coordinate-space-transform-output-name,\n.neuroglancer-coordinate-space-transform-widget\n .neuroglancer-coordinate-space-transform-scale {\n border: 0px;\n}\n\n.neuroglancer-coordinate-space-transform-output-name-container {\n display: flex;\n flex-direction: column;\n align-items: stretch;\n margin-right: 3px;\n}\n\n.neuroglancer-coordinate-space-transform-scale-container {\n display: flex;\n flex-direction: column;\n align-items: stretch;\n}\n\n.neuroglancer-coordinate-space-transform-scale-suggestion {\n font-family: monospace;\n cursor: pointer;\n border-radius: 20%;\n border: 1px solid #333;\n align-self: flex-end;\n margin: 2px;\n color: #aaa;\n}\n\n.neuroglancer-coordinate-space-transform-scale-suggestion svg {\n width: 16px;\n height: 16px;\n fill: transparent;\n stroke: #aaa;\n stroke-width: 2;\n stroke-linecap: round;\n stroke-linejoin: round;\n}\n\n.neuroglancer-coordinate-space-transform-scale-suggestion:hover {\n background-color: #db4437;\n border: 1px solid transparent;\n color: white;\n}\n\n.neuroglancer-coordinate-space-transform-scale-suggestion:hover svg {\n stroke: white;\n}\n\n.neuroglancer-coordinate-space-transform-widget-reset-buttons {\n grid-row: outputDim -1;\n grid-column: headerEnd / -1;\n justify-self: start;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-multiline-autocomplete {\n margin-top: 2px;\n padding: 2px;\n position: relative;\n background-color: #222;\n}\n\n.neuroglancer-multiline-autocomplete-hint,\n.neuroglancer-multiline-autocomplete-input {\n font-family: monospace;\n color: #fff;\n word-wrap: break-word;\n}\n\n.neuroglancer-multiline-autocomplete-input:focus {\n outline: 0px;\n}\n\n.neuroglancer-multiline-autocomplete-input:not(:focus):empty::before {\n content: attr(data-placeholder);\n color: #aaa;\n}\n\n.neuroglancer-multiline-autocomplete-hint {\n color: #aaa;\n}\n\n.neuroglancer-multiline-autocomplete-hint,\n.neuroglancer-multiline-autocomplete-input,\n.neuroglancer-multiline-autocomplete-completion {\n font-family: monospace;\n font-size: medium;\n}\n\n.neuroglancer-multiline-autocomplete-dropdown {\n color: #fff;\n background-color: #181818;\n position: fixed;\n display: block;\n outline: 0;\n margin: 0;\n padding: 0;\n left: 0px;\n right: 0px;\n text-align: left;\n cursor: default;\n border-style: solid;\n border-width: 1px;\n border-color: #aaa;\n overflow-y: scroll;\n word-wrap: break-word;\n}\n\n.neuroglancer-multiline-autocomplete-completion:nth-child(even):not(\n .neuroglancer-multiline-autocomplete-completion-active\n ) {\n background-color: #2b2b2b;\n}\n\n.neuroglancer-multiline-autocomplete-completion:hover {\n outline: 1px solid #ddd;\n}\n\n.neuroglancer-multiline-autocomplete-completion-active {\n background-color: #666;\n}\n\n.neuroglancer-multiline-autocomplete-completion-with-description {\n}\n\n.neuroglancer-multiline-autocomplete-completion-description {\n font-style: italic;\n color: #f9f;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-image-dropdown {\n overflow-y: auto;\n display: flex;\n flex-direction: column;\n height: 0px;\n}\n\n.neuroglancer-image-dropdown .neuroglancer-shader-code-widget {\n flex-shrink: 0;\n height: 8em;\n border: 1px solid transparent;\n}\n\n.neuroglancer-image-dropdown-top-row {\n display: flex;\n flex-direction: row;\n align-items: center;\n}\n\n.neuroglancer-image-layer-shader-overlay .neuroglancer-shader-code-widget {\n width: 80vw;\n height: 80vh;\n}\n\n.neuroglancer-selection-details-value-grid {\n display: grid;\n grid-auto-rows: auto;\n font-family: monospace;\n font-size: medium;\n align-items: center;\n}\n\n.neuroglancer-selection-details-value-grid-dim {\n grid-column: dim;\n color: #ff6;\n}\n\n.neuroglancer-selection-details-value-grid-dim::after {\n content: \"=\";\n color: #aaa;\n}\n\n.neuroglancer-selection-details-value-grid-coord {\n grid-column: coord;\n color: #aaa;\n margin-right: 1ch;\n}\n\n.neuroglancer-selection-details-value-grid-value {\n grid-column: value;\n user-select: text;\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-channel-dimensions-widget-dim {\n display: contents;\n}\n\n.neuroglancer-channel-dimensions-widget {\n display: grid;\n grid-template-columns: [name] min-content [lower] min-content [upper] min-content;\n}\n\n.neuroglancer-channel-dimensions-widget-name-container {\n grid-column: name;\n}\n\n.neuroglancer-channel-dimensions-widget-name[data-is-valid=\"false\"],\n.neuroglancer-channel-dimensions-widget-name::placeholder {\n text-decoration: solid underline red;\n}\n\n.neuroglancer-channel-dimensions-widget-name {\n background-color: transparent;\n border-color: transparent;\n box-shadow: none;\n border: 0;\n margin: 0;\n font-family: monospace;\n font-size: medium;\n color: #ff6;\n}\n\n.neuroglancer-channel-dimensions-widget-name,\n.neuroglancer-channel-dimensions-widget-lower,\n.neuroglancer-channel-dimensions-widget-upper {\n font-family: monospace;\n}\n\n.neuroglancer-channel-dimensions-widget-lower {\n grid-column: lower;\n text-align: right;\n}\n\n.neuroglancer-channel-dimensions-widget-upper {\n grid-column: upper;\n text-align: right;\n}\n\n.neuroglancer-channel-dimensions-widget-lower,\n.neuroglancer-channel-dimensions-widget-upper {\n text-align: right;\n margin-left: 1ch;\n user-select: text;\n}\n\n.neuroglancer-channel-dimensions-widget-upper::after {\n content: \")\";\n}\n\n.neuroglancer-channel-dimensions-widget-lower::after {\n content: \",\";\n}\n\n.neuroglancer-channel-dimensions-widget-lower::before {\n content: \"[\";\n}\n\n.neuroglancer-channel-dimensions-widget-upper::after,\n.neuroglancer-channel-dimensions-widget-lower::before,\n.neuroglancer-channel-dimensions-widget-lower::after {\n color: #999;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-single-mesh-dropdown .neuroglancer-single-mesh-attribute-widget {\n max-height: 6em;\n margin-bottom: 8px;\n}\n\n.neuroglancer-single-mesh-dropdown .neuroglancer-shader-code-widget {\n height: 6em;\n width: 60ch;\n border: 1px solid transparent;\n}\n\n.neuroglancer-single-mesh-dropdown-top-row {\n display: flex;\n flex-direction: row;\n align-items: center;\n}\n\n.neuroglancer-single-mesh-shader-overlay .neuroglancer-shader-code-widget {\n width: 80vw;\n height: 80vh;\n}\n\n.neuroglancer-single-mesh-attribute-widget {\n word-wrap: break-word;\n overflow-y: auto;\n display: grid;\n grid-template-columns: [type] auto [name] auto [range] auto;\n}\n\n.neuroglancer-single-mesh-layer-shader-overlay\n .neuroglancer-single-mesh-attribute-widget {\n max-height: 20vh;\n}\n\n.neuroglancer-single-mesh-attribute {\n font-family: monospace;\n display: contents;\n}\n\n.neuroglancer-single-mesh-attribute-type {\n color: #c6c;\n grid-column: type;\n}\n\n.neuroglancer-single-mesh-attribute-name {\n margin-left: 1ch;\n color: white;\n grid-column: name;\n user-select: text;\n}\n\n.neuroglancer-single-mesh-attribute-range {\n grid-column: range;\n margin-left: 1ch;\n white-space: nowrap;\n color: #999;\n grid-column: range;\n}\n",".neuroglancer-graphene-tab .neuroglancer-annotation-toolbox {\n display: none;\n}\n\n.neuroglancer-graphene-tab\n div[data-color=\"#ff0000\"]\n > .neuroglancer-annotation-position {\n color: red;\n}\n\n.neuroglancer-graphene-tab\n div[data-color=\"#0000ff\"]\n > .neuroglancer-annotation-position {\n color: #4444ff;\n}\n\n.graphene-tool-status {\n display: flex;\n gap: 10px;\n}\n\n.graphene-multicut > .activeGroupIndicator {\n padding: 2px;\n margin: auto 0;\n background-color: red;\n font: 12px sans-serif;\n font-weight: 900;\n}\n\n.graphene-multicut > .activeGroupIndicator.blueGroup {\n background-color: blue;\n}\n\n.graphene-multicut > .activeGroupIndicator::after {\n content: \"Red\";\n}\n\n.graphene-multicut > .activeGroupIndicator.blueGroup::after {\n content: \"Blue\";\n}\n\n.graphene-merge-segments-merges {\n display: flex;\n flex-direction: column;\n}\n\n.graphene-merge-segments-submission {\n display: flex;\n gap: 10px;\n}\n\n.graphene-tool-status .neuroglancer-icon {\n height: 100%;\n}\n\n.graphene-merge-segments-status label {\n display: grid;\n grid-template-columns: min-content min-content;\n white-space: nowrap;\n justify-content: center;\n align-content: center;\n}\n\n.graphene-merge-segments-point {\n display: flex;\n align-items: center;\n gap: 10px;\n}\n\n.graphene-merge-segments-point\n .neuroglancer-segment-list-entry-visible-checkbox,\n.graphene-merge-segments-point .neuroglancer-segment-list-entry-copy-container {\n display: none;\n}\n\n.graphene-find-path > label {\n display: flex;\n}\n\n.graphene-find-path > label > span {\n display: flex;\n align-content: center;\n flex-wrap: wrap;\n}\n\n.find-path-annotations {\n display: flex;\n gap: 10px;\n}\n\n.find-path-annotations > .neuroglancer-annotation-list-entry {\n background-color: black;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nhtml,\nbody {\n margin: 0px;\n padding: 0px;\n overflow: hidden;\n width: 100vw;\n height: 100vh;\n background-color: black;\n color: white;\n}\n\nbody {\n position: relative;\n display: flex;\n flex-direction: column;\n}\n\n#neuroglancer-container {\n width: 100vw;\n overflow: hidden;\n flex: 1;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-viewer {\n outline: 0px;\n}\n\n.neuroglancer-viewer-top-row {\n display: flex;\n flex-direction: row;\n align-items: center;\n background-color: #222;\n margin-bottom: 3px;\n padding-right: 2px;\n}\n\n.neuroglancer-viewer-side-panel {\n display: flex;\n flex-direction: column;\n align-items: stretch;\n max-width: 80%;\n color: #fff;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-noselect {\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n -khtml-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n\n.neuroglancer-select-text {\n -webkit-touch-callout: default;\n -webkit-user-select: text;\n -khtml-user-select: text;\n -moz-user-select: text;\n -ms-user-select: text;\n user-select: text;\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-data-panel-layout-controls {\n position: absolute;\n top: 2px;\n right: 2px;\n display: flex;\n align-items: start;\n}\n\n.neuroglancer-data-panel-layout-controls > button {\n display: flex;\n margin: 2px;\n border: 0px;\n background-color: rgba(0, 0, 0, 0.5);\n flex-direction: row;\n align-self: top;\n align-items: center;\n justify-content: center;\n border: 1px solid white;\n font-size: 15px;\n width: 18px;\n height: 18px;\n color: white;\n}\n\n.neuroglancer-data-panel-layout-controls > button > div {\n display: inline-block;\n text-align: center;\n line-height: 12px;\n width: 15px;\n height: 15px;\n}\n\n.neuroglancer-data-panel-layout-controls > button:hover {\n color: #6ff;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nlabel.perspective-panel-show-slice-views {\n pointer-events: none;\n position: absolute;\n right: 2px;\n bottom: 2px;\n font-family: sans-serif;\n font-size: small;\n}\n\ninput.perspective-panel-show-slice-views {\n pointer-events: all;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-rendered-data-panel {\n cursor: crosshair;\n position: relative;\n outline: 0;\n touch-action: none;\n color: #fff;\n text-align: left;\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-display-dimensions-widget {\n position: absolute;\n cursor: default;\n top: 2px;\n left: 2px;\n background-color: rgba(0, 0, 0, 0.3);\n}\n\n.neuroglancer-display-dimensions-widget-dimension-grid {\n display: grid;\n grid-template-rows: 0fr 0fr 0fr 0fr;\n grid-template-columns: 0fr 0fr 0fr;\n}\n\n.neuroglancer-display-dimensions-widget input {\n outline: 0px;\n background-color: transparent;\n border-color: transparent;\n box-shadow: none;\n margin: 0;\n border: 0;\n padding: 2px;\n}\n\n.neuroglancer-display-dimensions-widget input,\n.neuroglancer-display-dimensions-widget {\n font-family: monospace;\n color: white;\n}\n\n.neuroglancer-display-dimensions-widget-dimension:hover {\n outline: 1px solid black;\n}\n\n.neuroglancer-display-dimensions-widget-name[data-is-valid=\"false\"] {\n text-decoration: solid underline red;\n}\n\n.neuroglancer-display-dimensions-widget-scale-factor {\n text-align: right;\n align-items: end;\n display: inline-block;\n white-space: nowrap;\n margin-left: 2px;\n}\n\n.neuroglancer-display-dimensions-widget-scale {\n display: inline-block;\n white-space: nowrap;\n padding-left: 10px;\n}\n\n.neuroglancer-display-dimensions-widget-scale:not(:empty)::before {\n content: \"(\";\n}\n\n.neuroglancer-display-dimensions-widget-scale:not(:empty)::after {\n content: \")\";\n}\n\n.neuroglancer-display-dimensions-widget-scale-factor::after {\n content: \"×\";\n}\n\n.neuroglancer-display-dimensions-widget-scale {\n text-align: right;\n margin-left: 5px;\n}\n\n.neuroglancer-display-dimensions-widget:not(:hover):not([data-active=\"true\"])\n .neuroglancer-display-dimensions-widget-scale-factor,\n.neuroglancer-display-dimensions-widget:not(:hover):not([data-active=\"true\"])\n .neuroglancer-display-dimensions-widget-scale,\n.neuroglancer-display-dimensions-widget:not(:hover):not([data-active=\"true\"])\n .neuroglancer-display-dimensions-widget-default,\n.neuroglancer-display-dimensions-widget:not(:hover):not([data-active=\"true\"])\n .neuroglancer-depth-range-widget-grid,\n.neuroglancer-display-dimensions-widget:not(:hover):not([data-active=\"true\"])\n .neuroglancer-depth-range-relative-checkbox-label {\n display: none;\n}\n\n.neuroglancer-display-dimensions-widget-dimension[data-is-modified=\"true\"]\n .neuroglancer-display-dimensions-widget-scale-factor,\n.neuroglancer-display-dimensions-widget-dimension[data-is-modified=\"true\"]\n .neuroglancer-display-dimensions-widget-scale {\n visibility: hidden;\n}\n\n.neuroglancer-display-dimensions-widget *:focus {\n outline: 0px;\n}\n\n.neuroglancer-display-dimensions-widget-default {\n grid-row: 4;\n grid-column-start: 1;\n grid-column-end: 3;\n display: inline-block;\n white-space: nowrap;\n}\n\n.neuroglancer-display-dimensions-widget-default input {\n margin-right: 3px;\n}\n\n.neuroglancer-depth-range-widget-grid {\n margin-top: 1em;\n display: grid;\n display: grid;\n grid-template-columns: 0fr 0fr 0fr;\n grid-auto-rows: 0fr;\n}\n\n.neuroglancer-depth-range-widget-dimension-names:not(:empty)::before {\n content: \"(\";\n}\n\n.neuroglancer-depth-range-widget-dimension-names:not(:empty)::after {\n content: \")\";\n}\n\n.neuroglancer-depth-range-widget-dimension-names {\n margin-left: 1ch;\n white-space: nowrap;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-help-body {\n flex-basis: 0px;\n flex: 1;\n height: 0px;\n min-height: 0px;\n font-family: sans-serif;\n display: flex;\n flex-direction: column;\n}\n\n.neuroglancer-help-scroll-container {\n flex: 1;\n flex-basis: 0px;\n position: relative;\n overflow: auto;\n}\n\n.neuroglancer-help-scroll-container div + h2 {\n margin-top: 1em;\n}\n\n.neuroglancer-help-scroll-container h2 {\n font-size: 10pt;\n padding: 4px;\n position: sticky;\n top: 0;\n background-color: #333;\n margin-top: 0px;\n}\n\n.neuroglancer-help-scroll-container .dt {\n font-family: monospace;\n font-weight: bold;\n color: yellow;\n}\n\n.neuroglancer-help-scroll-container .dd {\n font-size: 10pt;\n margin-left: 4ex;\n}\n\n.neuroglancer-build-info {\n font-size: 10pt;\n user-select: text;\n}\n\n.neuroglancer-build-info a {\n color: white;\n text-decoration: none;\n font-weight: bold;\n}\n\n.neuroglancer-build-info a:hover {\n background-color: #db4437;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-panel {\n flex: 1;\n}\n\n.neuroglancer-show-panel-borders .neuroglancer-panel {\n border-style: solid;\n border-color: black;\n border-width: 2px;\n}\n\n.neuroglancer-panel:focus-within {\n border-color: white;\n}\n\n.neuroglancer-layer-group-viewer {\n outline: 0px;\n}\n\n.neuroglancer-layer-group-viewer-context-menu {\n flex-direction: column;\n align-items: stretch;\n}\n\n.neuroglancer-layer-group-viewer-context-menu label {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n}\n\n.neuroglancer-layer-group-viewer-context-menu select::before {\n flex: 1;\n content: \" \";\n}\n\n.neuroglancer-layer-group-viewer-context-menu select {\n margin-left: 5px;\n}\n","/**\n * @license\n * Copyright 2017 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-context-menu {\n position: absolute;\n z-index: 100;\n border: 1px solid white;\n background-color: black;\n box-shadow: 5px 5px 2px 1px rgba(0, 0, 0, 0.5);\n font-family: sans-serif;\n font-size: 11pt;\n padding: 5px;\n color: white;\n outline: 0px;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n:root {\n --layer-number-color: #9a7518;\n}\n\n.neuroglancer-layer-panel {\n width: 100%;\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n align-items: stretch;\n margin-left: -5px;\n margin-top: -1px;\n z-index: -0.1;\n}\n\n.neuroglancer-layer-item {\n position: relative;\n display: flex;\n align-items: center;\n color: white;\n cursor: pointer;\n border-width: 1px;\n border-style: solid;\n border-color: #ccc;\n font-family: sans-serif;\n font-size: 10pt;\n background-color: black;\n padding: 1px;\n}\n\n.neuroglancer-layer-item,\n.neuroglancer-layer-add-button {\n margin: 1px;\n margin-left: 5px;\n}\n\n.neuroglancer-layer-item[data-selected=\"true\"] {\n border-color: #8c8;\n}\n\n.neuroglancer-layer-item[data-selected=\"true\"]:hover {\n border-color: #3c3;\n}\n\n.neuroglancer-layer-item:hover {\n border-color: #daa520;\n}\n\n.neuroglancer-layer-item[data-pick=\"true\"] .neuroglancer-layer-item-label {\n background-color: #939;\n}\n\n.neuroglancer-layer-item-label {\n display: inline-block;\n position: relative;\n background-color: #222;\n padding-right: 3px;\n}\n\n.neuroglancer-layer-item-number {\n display: inline-block;\n background-color: var(--layer-number-color);\n font-weight: bold;\n padding-left: 1px;\n padding-right: 1px;\n}\n\n.neuroglancer-layer-panel[data-show-hover-values=\"true\"]\n .neuroglancer-layer-item-value {\n display: inline-block;\n font-family: monospace;\n font-size: medium;\n max-width: 50ch;\n margin-left: 1ch;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipses;\n text-align: center;\n}\n\n.neuroglancer-layer-panel[data-show-hover-values=\"false\"]\n .neuroglancer-layer-item-value {\n display: none;\n}\n\n.neuroglancer-layer-item[data-visible=\"false\"] .neuroglancer-layer-item-label {\n text-decoration: line-through;\n}\n\n.neuroglancer-layer-item[data-visible=\"false\"] {\n color: #bbb;\n}\n\n.neuroglancer-layer-panel-drop-zone {\n display: inline-block;\n flex: 1;\n}\n\n.neuroglancer-layer-item-visible-progress,\n.neuroglancer-layer-item-prefetch-progress {\n position: absolute;\n left: 0px;\n height: 2px;\n background-color: #666;\n}\n\n.neuroglancer-layer-item-visible-progress {\n top: 0px;\n}\n\n.neuroglancer-layer-item-prefetch-progress {\n bottom: 0px;\n}\n\n.neuroglancer-layer-item-value-container {\n display: grid;\n grid-template-columns: min-content;\n align-items: center;\n}\n\n.neuroglancer-layer-item-value {\n grid-row: 1;\n grid-column: 1;\n visibility: visible;\n}\n\n.neuroglancer-layer-item-button-container {\n grid-row: 1;\n grid-column: 1;\n white-space: nowrap;\n display: flex;\n flex-direction: row;\n align-items: center;\n visibility: hidden;\n justify-self: right;\n}\n\n.neuroglancer-layer-panel:hover .neuroglancer-layer-item-value {\n visibility: hidden;\n}\n\n.neuroglancer-layer-panel:hover .neuroglancer-layer-item-button-container {\n visibility: visible;\n}\n","/**\n * @license\n * Copyright 2017 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-layout-split-drop-zone {\n position: absolute;\n z-index: 1000;\n}\n\n.neuroglancer-drag-over {\n background-color: rgba(0, 0, 255, 0.5);\n}\n\n.neuroglancer-stack-layout-row > .neuroglancer-stack-layout-drop-placeholder {\n padding-left: 4px;\n padding-right: 4px;\n width: 1px;\n cursor: col-resize;\n}\n\n.neuroglancer-stack-layout-column\n > .neuroglancer-stack-layout-drop-placeholder {\n padding-top: 4px;\n padding-bottom: 4px;\n height: 1px;\n cursor: row-resize;\n}\n\n.neuroglancer-stack-layout-drop-placeholder {\n background-clip: content-box;\n background-color: #666;\n z-index: 1;\n}\n\n.neuroglancer-stack-layout-drop-placeholder.neuroglancer-drag-over {\n background-clip: border-box;\n background-color: rgba(128, 128, 255, 0.5);\n}\n\n.neuroglancer-stack-layout-drop-placeholder:first-child,\n.neuroglancer-stack-layout-drop-placeholder:last-child {\n display: none;\n}\n",".neuroglancer-layer-list-panel-items {\n display: flex;\n flex-direction: column;\n flex: 1;\n overflow: auto;\n height: 0px;\n min-height: 0px;\n flex-basis: 0px;\n}\n\n.neuroglancer-layer-list-panel-item {\n display: flex;\n flex-direction: row;\n padding: 2px;\n border: 1px solid #aaa;\n margin: 2px;\n}\n\n.neuroglancer-layer-list-panel-item[data-selected=\"true\"] {\n border-color: #3c3;\n}\n\n.neuroglancer-layer-list-panel-item[data-archived=\"true\"] {\n border-color: #666;\n}\n\n.neuroglancer-layer-list-panel-item[data-archived=\"true\"]\n .neuroglancer-layer-side-panel-name,\n.neuroglancer-layer-list-panel-item[data-archived=\"true\"]\n .neuroglancer-icon\n svg {\n color: #999;\n stroke: #999;\n}\n\n.neuroglancer-layer-list-panel-item:hover {\n background-color: #333;\n}\n\n.neuroglancer-layer-list-panel-item-number {\n font-family: sans-serif;\n background-color: var(--layer-number-color);\n color: white;\n font-weight: bold;\n display: inline-block;\n}\n\n.neuroglancer-layer-list-panel-item:not(:hover)\n > .neuroglancer-layer-list-panel-item-delete {\n display: none;\n}\n\n.neuroglancer-layer-list-panel-item:not(:hover)\n > .neuroglancer-layer-list-panel-item-controls {\n display: none;\n}\n","/**\n * @license\n * Copyright 2018 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n[data-neuroglancer-layer-panel-pinned=\"false\"]\n .neuroglancer-side-panel-titlebar.neuroglancer-layer-side-panel-title {\n background-color: #393;\n}\n\n[data-neuroglancer-layer-visible=\"false\"]\n .neuroglancer-side-panel-titlebar.neuroglancer-layer-side-panel-title\n input {\n text-decoration: line-through;\n}\n\n.neuroglancer-layer-side-panel-name {\n flex: 1;\n background-color: transparent;\n border: 0px;\n color: white;\n outline: 0px;\n /* ensure if name gets too long it doesn't push buttons over */\n width: 0px;\n min-width: 0px;\n}\n\n.neuroglancer-layer-side-panel-tab-view {\n flex: 1;\n display: flex;\n flex-direction: column;\n font: 10pt sans-serif;\n}\n\n.neuroglancer-layer-side-panel-type-measure {\n position: absolute;\n visibility: hidden;\n top: 0px;\n height: auto;\n width: auto;\n white-space: nowrap;\n}\n\n.neuroglancer-layer-side-panel-type,\n.neuroglancer-layer-side-panel-type-measure {\n padding-left: 3px;\n padding-right: 3px;\n font-weight: bold;\n font-family: sans-serif;\n font-size: 10pt;\n box-sizing: border-box;\n}\n\n.neuroglancer-layer-side-panel-type {\n -webkit-appearance: none;\n color: white;\n cursor: pointer;\n background-color: rgba(0, 0, 0, 0.5);\n margin-right: 5px;\n border: 0px;\n outline: 0px;\n}\n\n.neuroglancer-layer-side-panel-type option {\n background-color: #000;\n}\n",".CodeMirror-foldmarker {\n color: blue;\n text-shadow: #b9f 1px 1px 2px, #b9f -1px -1px 2px, #b9f 1px -1px 2px, #b9f -1px 1px 2px;\n font-family: arial;\n line-height: .3;\n cursor: pointer;\n}\n.CodeMirror-foldgutter {\n width: .7em;\n}\n.CodeMirror-foldgutter-open,\n.CodeMirror-foldgutter-folded {\n cursor: pointer;\n}\n.CodeMirror-foldgutter-open:after {\n content: \"\\25BE\";\n}\n.CodeMirror-foldgutter-folded:after {\n content: \"\\25B8\";\n}\n","/**\n * @license\n * Copyright 2018 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-state-editor {\n width: 80%;\n}\n\n.close-button {\n position: absolute;\n right: 15px;\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-statistics-panel-body {\n flex: 1;\n flex-basis: 0px;\n min-width: 0px;\n display: flex;\n flex-direction: column;\n overflow-y: auto;\n font: 10pt sans-serif;\n}\n\n.neuroglancer-statistics-panel-body > table {\n position: relative;\n flex: 1;\n width: 100%;\n}\n\n.neuroglancer-statistics-panel-body > table > thead td {\n position: sticky;\n top: 0px;\n z-index: 2;\n background-color: #333;\n font-weight: bold;\n}\n\n.neuroglancer-statistics-panel-body > table > tbody tr:hover {\n background-color: #336;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-settings-body {\n flex-basis: 0px;\n flex: 1;\n height: 0px;\n min-height: 0px;\n font-family: sans-serif;\n display: flex;\n flex-direction: column;\n font-size: 10pt;\n}\n\n.neuroglancer-settings-body input[type=\"text\"],\n.neuroglancer-settings-body input[type=\"number\"] {\n background-color: #333;\n color: #fff;\n border: 0px;\n}\n\n.neuroglancer-settings-scroll-container {\n flex: 1;\n flex-basis: 0px;\n position: relative;\n overflow: auto;\n display: flex;\n flex-direction: column;\n}\n\n.neuroglancer-settings-scroll-container > * {\n margin-top: 3px;\n}\n\n.neuroglancer-settings-title {\n align-self: stretch;\n}\n\n.neuroglancer-settings-scroll-container > label {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n}\n\n.neuroglancer-settings-scroll-container > label > input::before {\n flex: 1;\n content: \" \";\n}\n\n.neuroglancer-settings-scroll-container > label > input {\n margin-left: 5px;\n width: 11ch;\n}\n\n.neuroglancer-settings-limit-widget > input {\n width: 11ch;\n}\n","/**\n * @license\n * Copyright 2018 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n.neuroglancer-annotation-tool-status {\n display: flex;\n flex-direction: row;\n align-items: center;\n overflow-x: scroll;\n scrollbar-width: none;\n}\n\n.neuroglancer-annotation-tool-status::-webkit-scrollbar {\n display: none;\n}\n\n.neuroglancer-annotation-tool-status-widget\n + .neuroglancer-annotation-tool-status-widget {\n margin-left: 3px;\n}\n\n.neuroglancer-annotation-tool-status-widget:hover {\n outline: 1px solid #fff;\n}\n\n.neuroglancer-annotation-tool-status-widget {\n display: flex;\n flex-direction: row;\n align-items: center;\n}\n\n.neuroglancer-annotation-tool-status-widget-layer-number {\n display: inline-block;\n font: 10pt sans-serif;\n font-weight: bold;\n background-color: #9a7518;\n}\n\n.neuroglancer-annotation-tool-status-widget-key {\n display: inline-block;\n font: 9pt monospace;\n color: #0ff;\n}\n\n.neuroglancer-annotation-tool-status-widget-key::before {\n content: \"[\";\n}\n\n.neuroglancer-annotation-tool-status-widget-key::after {\n content: \"]\";\n}\n\n.neuroglancer-annotation-tool-status-widget-key::before,\n.neuroglancer-annotation-tool-status-widget-key::after {\n color: #999;\n}\n\n.neuroglancer-annotation-tool-status-widget-description {\n display: inline-block;\n color: #3c3;\n font: 10pt sans-serif;\n white-space: nowrap;\n}\n\n.neuroglancer-annotation-tool-status-widget-delete {\n visibility: hidden;\n}\n\n.neuroglancer-annotation-tool-status-widget:hover\n > .neuroglancer-annotation-tool-status-widget-delete {\n visibility: inherit;\n}\n"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/neuvue_project/workspace/static/spelunker-workspace/main.cb26101b553ed6b82856.js b/neuvue_project/workspace/static/spelunker-workspace/main.cb26101b553ed6b82856.js new file mode 100644 index 0000000..c575aad --- /dev/null +++ b/neuvue_project/workspace/static/spelunker-workspace/main.cb26101b553ed6b82856.js @@ -0,0 +1,6132 @@ +var Wb={4242:(se,Ee,G)=>{G.d(Ee,{G1:()=>C,YR:()=>fe,y6:()=>F});var _=G(8796);/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */var F=(ye=>(ye[ye.MIN_REPRESENTATIVE=0]="MIN_REPRESENTATIVE",ye[ye.MAX_REPRESENTATIVE=1]="MAX_REPRESENTATIVE",ye[ye.REPRESENTATIVE_EXCLUDED=2]="REPRESENTATIVE_EXCLUDED",ye[ye.NONREPRESENTATIVE_EXCLUDED=4]="NONREPRESENTATIVE_EXCLUDED",ye))(F||{});function fe(ye){return!(ye.high>>>31)}const C=new _.R(4294967295,4294967295)},3206:(se,Ee,G)=>{G.d(Ee,{B0:()=>C,DN:()=>ye,DY:()=>J,Kk:()=>We,Uq:()=>Ie,W1:()=>R,XZ:()=>ne,_Y:()=>ze,aM:()=>q,no:()=>Be,ol:()=>ge,pz:()=>me,rG:()=>B,wP:()=>tt,ww:()=>Dt});var _=G(5716),F=G(2596),fe=G(4038);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class C{constructor(M){this.value_=M,this.changed=new fe.IY}get value(){return this.value_}set value(M){M!==this.value_&&(this.value_=M,this.changed.dispatch())}}class ye extends C{constructor(M,T,U=M){super(M),this.validator=T,this.defaultValue=U}toJSON(){const{value_:M}=this;if(M!==this.defaultValue)return this.value_}reset(){this.value=this.defaultValue}restoreState(M){if(M!==void 0){const{validator:T}=this;try{this.value=T(M);return}catch{}}this.value=this.defaultValue}}class Le extends F.O8{constructor(M,T){super(),this.changed=new fe.IY,this.f=M,this.ws=T;for(const U of T)this.registerDisposer(U.changed.add(this.changed.dispatch))}get value(){return this.f(...this.ws.map(M=>M.value))}}function We($,...M){return new Le($,M)}class Ve extends F.O8{constructor(M,T){super(),this.changed=new fe.IY,this.valueGeneration=-1,this.f=M,this.ws=T;for(const U of T)this.registerDisposer(U.changed.add(this.changed.dispatch))}get value(){const M=this.changed.count;return M!==this.valueGeneration&&(this.value_=this.f(...this.ws.map(T=>T.value)),this.valueGeneration=M),this.value_}}function ge($,...M){return new Ve($,M)}class me extends F.O8{constructor(M,T=(U,ee)=>U===ee){super(),this.changed=new fe.HN,this.value=M.value,this.registerDisposer(M.changed.add(()=>{const U=M.value;T(this.value,U)||(this.value=U,this.changed.dispatch())}))}}function Ie($,M,T){const U=new Le($,M),ee=new me(U,T);return ee.registerDisposer(U),ee}class tt extends F.O8{constructor(M){super(),this.changed=new fe.IY;const T=M(this),U=Object.keys(T),ee=()=>{const te=Array.isArray(T)?[]:{};for(const ve of U)te[ve]=T[ve].value;this.value=te,this.changed.dispatch()};ee();for(const te of U){const ve=T[te];this.registerDisposer(ve.changed.add(()=>ee()))}}}class Dt extends F.O8{constructor(M,...T){super(),this.f=M,this.changed=new fe.IY;for(const U of T)this.registerDisposer(U.add(this.changed.dispatch))}get value(){return this.f()}}class Ge extends F.O8{constructor(){super(...arguments),this.changed=new fe.IY}get value(){return this.value_}set value(M){const{value_:T}=this;if(this.value_=M,T!==void 0&&(T.dispose(),T.unregisterDisposer(this.valueHandler),this.valueHandler=void 0),M!==void 0){const U=this.valueHandler=()=>{this.value_===M&&(this.value_=void 0,this.changed.dispatch())};M.registerDisposer(U)}M!==T&&this.changed.dispatch()}reset(){this.value=void 0}disposed(){this.value_!==void 0&&(this.value_.unregisterDisposer(this.valueHandler),this.value_.dispose()),this.value_=void 0,super.disposed()}}class It extends Ge{constructor(M,T){super(),this.validator=M,this.jsonConverter=T}toJSON(){const{value:M}=this;return M&&this.jsonConverter(M)}restoreState(M){this.value=this.validator(M)}}class ze{constructor(M){this.changed=new fe.HN,M===void 0?this.values=new Set:this.values=new Set(M)}add(M){const{values:T}=this;return T.has(M)||(T.add(M),this.changed.dispatch(M,!0)),this}delete(M){const{values:T}=this;return T.delete(M)?(this.changed.dispatch(M,!1),!0):!1}has(M){return this.values.has(M)}get size(){return this.values.size}[Symbol.iterator](){return this.values[Symbol.iterator]()}clear(){const{values:M}=this;M.size>0&&(M.clear(),this.changed.dispatch(null,!1))}}function Be($,...M){const T=M.map(Xe=>Xe.value),U=M.length;let ee=new F.O8,te=$(ee,...T);const ve=(0,_.A)(()=>{let Xe=!1;for(let He=0;HeXe.changed.add(ve));return{flush(){ve.flush()},dispose(){ve.cancel(),(0,F.$F)(qe),ee.dispose()},get value(){return ve.flush(),te}}}function q($,...M){const T=M.map(Xe=>Xe.value),U=M.length;let ee=new F.O8,te=$(ee,...T);const ve=()=>{let Xe=!1;for(let He=0;HeXe.changed.add(ve));return{dispose(){(0,F.$F)(qe),ee.dispose()},get value(){return te}}}function ne($){return{changed:fe.$$,value:$}}function R($,M){return $(M.value),M.changed.add(()=>$(M.value))}function ae($,M){return M.value=$.value,$.changed.add(()=>{M.value=$.value})}class B{constructor(M,T){this.outer=M,this.getInner=T,this.changed=new fe.IY,this.update=()=>{const{disposer:U,outer:ee}=this;U!==void 0&&U();const te=this.inner=this.getInner(ee.value);this.disposer=te.changed.add(this.changed.dispatch),this.changed.dispatch()},M.changed.add(this.update),this.update()}dispose(){this.outer.changed.remove(this.update),this.disposer()}get value(){return this.inner.value}set value(M){this.inner.value=M}}class J extends B{reset(){this.inner.reset()}restoreState(M){this.inner.restoreState(M)}toJSON(){return this.inner.toJSON()}}},4037:(se,Ee,G)=>{G.d(Ee,{CS:()=>Le,El:()=>We,Lp:()=>Ve,NT:()=>ae,RO:()=>Be,U8:()=>F,ak:()=>R,b8:()=>ze,eL:()=>q,eN:()=>me,ep:()=>Ge,jx:()=>fe,lX:()=>ge,r1:()=>tt,wm:()=>Dt});/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function _(B,J,$,M){for(;J<$;){const T=B[J];if(M(T)){++J;continue}--$,B[J]=B[$],B[$]=T}return $}function F(B,J){const $=B.length;let M=0;for(let T=0;T<$;++T)J(B[T],T,B)&&(B[M]=B[T],++M);B.length=M}function fe(B,J){if(B.length===J)return B;const $=new B.constructor(J);return $.set(B),$}function C(B,J=1){const $=B.length,M=new Array($);let T=M[0]=J;for(let U=1;U<$;++U)T*=B[U-1],M[U]=T;return M}function ye(B,J,$){const M=new B.constructor(B.length);for(let T=0;T>1,ee=$(J,B[U]);if(ee>0)M=U+1;else if(ee<0)T=U;else return U}return~M}function Ve(B,J,$,M=0,T=B.length){let U=-1,ee=1/0;for(;M>1,ve=$(J,B[te]);if(ve>0)M=te+1;else if(ve<0)T=te;else return te;const qe=Math.abs(ve);qe0;){const T=Math.floor(M/2),U=B+T;$(U)?M=T:(B=U+1,M-=T+1)}return B}function me(B,J){const $=[];for(let M=0,T=B.length;MM===T){const M=B.length;if(J.length!==M)return!1;for(let T=0;T0){let He=1;for(;++U0;)++He;M.push({retainCount:0,deleteCount:0,insertCount:He})}}return(T0){if(T(te),++te===J)break}else if(U(ee,te),++ee,++te,ee===B||te===J)break}for(;ee{G.d(Ee,{Dq:()=>fe,Qi:()=>Le,fx:()=>ye,gI:()=>Ve,wS:()=>F,y3:()=>We});/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class _ extends Error{constructor(){super(...arguments),this.name="CancellationError",this.message="CANCELED"}toString(){return"CANCELED"}}const F=new _;function fe(ge){if(ge.isCanceled===!0)throw F}const C=()=>{},ye={isCanceled:!1,add:()=>C,remove:C};class Le{cancel(){const{handlers:me}=this;if(me!==null&&(this.handlers=null,me!==void 0))for(const Ie of me)Ie()}get isCanceled(){return this.handlers===null}add(me){let{handlers:Ie}=this;return Ie===null?(me(),C):(Ie===void 0&&(Ie=this.handlers=new Set),Ie.add(me),()=>{this.remove(me)})}remove(me){const{handlers:Ie}=this;Ie?.delete(me)}}class We extends Le{constructor(){super(...arguments),this.consumers=new Set}addConsumer(me=ye){const{consumers:Ie}=this;Ie.has(me)||me.isCanceled||(Ie.add(me),me.add(()=>{Ie.delete(me),Ie.size===0&&this.cancel()}))}}function Ve(ge,me){return new Promise((Ie,tt)=>{if(ge===ye){me(Ie,tt,ye);return}const Dt=new Le,Ge=ge.add(()=>{Dt.cancel()});me(It=>{Ge(),Ie(It)},It=>{Ge(),tt(It)},Dt)})}},2596:(se,Ee,G)=>{G.d(Ee,{$F:()=>fe,K6:()=>C,K9:()=>We,O8:()=>ye,fL:()=>Le});/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const _=!1;function F(Ve){typeof Ve=="object"?Ve.dispose():Ve()}function fe(Ve){for(let ge=Ve.length;ge>0;--ge)F(Ve[ge-1])}function C(Ve,ge,me,Ie){return Ve.addEventListener(ge,me,Ie),()=>Ve.removeEventListener(ge,me,Ie)}class ye{constructor(){this.refCount=1}addRef(){return++this.refCount,this}dispose(){_&&(this.disposedStacks=this.disposedStacks||[]).push(new Error().stack),--this.refCount===0&&this.refCountReachedZero()}refCountReachedZero(){this.disposed();const{disposers:ge}=this;ge!==void 0&&(fe(ge),this.disposers=void 0),this.wasDisposed=!0}disposed(){}registerDisposer(ge){const{disposers:me}=this;return me==null?this.disposers=[ge]:me.push(ge),ge}unregisterDisposer(ge){const{disposers:me}=this;if(me!=null){const Ie=me.indexOf(ge);Ie!==-1&&me.splice(Ie,1)}return ge}registerEventListener(ge,me,Ie,tt){this.registerDisposer(C(ge,me,Ie,tt))}registerCancellable(ge){return this.registerDisposer(()=>{ge.cancel()}),ge}}class Le extends ye{constructor(ge){super(),this.value=ge}}function We(Ve){return()=>{if(Ve!==void 0){const ge=Ve;Ve=void 0,F(ge)}}}},3038:(se,Ee,G)=>{G.d(Ee,{I1:()=>Vn,Jh:()=>He,Oi:()=>Dt,PC:()=>qe,Qi:()=>ii,T2:()=>me,T_:()=>te,Yu:()=>C,Zc:()=>We,_A:()=>U,_S:()=>ee,_q:()=>T,bS:()=>cs,eR:()=>F,ln:()=>fe,nL:()=>q,p9:()=>ge,pB:()=>_,qp:()=>ve,r3:()=>Ve,sJ:()=>Qt,uD:()=>J,vs:()=>B,w0:()=>Le,xK:()=>ze,yb:()=>tt});var _=G(7684),F=G(329),fe=G(4796),C=G(2221),ye=G(4037),Le=G(1409),We=G(842);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const Ve=_.create(),ge=["x","y","z"],me=[F.fromValues(1,0,0),F.fromValues(0,1,0),F.fromValues(0,0,1)],Ie=F.fromValues(0,0,0),tt=fe.fromValues(0,0,0,0),Dt=F.fromValues(1,1,1),Ge=F.fromValues(1/0,1/0,1/0),It=C.create();function ze(W){return W[0]*W[1]*W[2]}function Be(W){return W[0]*W[1]*W[2]*W[3]}function q(W){return`${W[0]},${W[1]},${W[2]}`}function ne(W,K){const ue=K[0],P=K[1],he=K[2],re=K[3];W[0]=re,W[1]=he,W[2]=-P,W[3]=-ue}function R(W,K){const ue=K[0],P=K[1],he=K[2],re=K[3];W[0]=-he,W[1]=re,W[2]=ue,W[3]=-P}function ae(W,K){const ue=K[0],P=K[1],he=K[2],re=K[3];W[0]=P,W[1]=-ue,W[2]=re,W[3]=-he}function B(W,K,ue){const P=K[0],he=K[1],re=K[2];return W[0]=ue[0]*P+ue[4]*he+ue[8]*re,W[1]=ue[1]*P+ue[5]*he+ue[9]*re,W[2]=ue[2]*P+ue[6]*he+ue[10]*re,W}function J(W,K,ue){const P=K[0],he=K[1],re=K[2];return W[0]=ue[0]*P+ue[1]*he+ue[2]*re,W[1]=ue[4]*P+ue[5]*he+ue[6]*re,W[2]=ue[8]*P+ue[9]*he+ue[10]*re,W}function $(W,K,ue,P,he){const re=W;return W[0]=P[0],W[1]=P[1],W[2]=P[2]*he,mat4.fromRotationTranslationScale(W,ue,K,re)}function M(W,K,ue){const P=ue.length;let he=0;for(let de=0;de-rt+Bn||ht<-rt-Bn)return!1}return!0}function qe(W,K,ue,P=!1){const he=ue.length,re=[],de=P?1:K+1,Pe=P?K+1:1;for(let Ze=0;Ze>>1&1)-1,f[2]=2*(ue>>>2&1)-1,F.transformMat4(f,f,W);for(let P=0;P<3;++P){const he=f[P];K[P]=Math.min(K[P],he),K[P+3]=Math.max(K[P+3],he)}}}},8626:()=>{if(typeof NEUROGLANCER_GOOGLE_TAG_MANAGER<"u"){const se="dataLayer",Ee=NEUROGLANCER_GOOGLE_TAG_MANAGER;window[se]=window[se]||[],window[se].push({"gtm.start":new Date().getTime(),event:"gtm.js"});const G=document.createElement("script");G.async=!0,G.src=`https://www.googletagmanager.com/gtm.js?id=${Ee}`,document.head.appendChild(G)}},9808:(se,Ee,G)=>{G.d(Ee,{Bk:()=>Ie,Dl:()=>Ge,El:()=>It,JZ:()=>We,Rc:()=>ge,cj:()=>me,j$:()=>fe,vd:()=>Ve});var _=G(4509),F=G(8796);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class fe extends Error{constructor(Be,q,ne,R){let ae=`Fetching ${JSON.stringify(Be)} resulted in HTTP error ${q}`;ne&&(ae+=`: ${ne}`),ae+=".",super(ae),this.name="HttpError",this.message=ae,this.url=Be,this.status=q,this.statusText=ne,R&&(this.response=R)}static fromResponse(Be){return new fe(Be.url,Be.status,Be.statusText,Be)}static fromRequestError(Be,q){if(q instanceof TypeError){let ne;return typeof Be=="string"?ne=Be:ne=Be.url,new fe(ne,0,"Network or CORS error")}return q}}const C=32,ye=500,Le=1e4;function We(ze){return Math.min(2**ze*ye,Le/2)*(1+Math.random())}async function Ve(ze,Be){for(let q=0;;){if(Be?.signal?.aborted)throw _.wS;let ne;try{ne=await fetch(ze,Be)}catch(R){throw fe.fromRequestError(ze,R)}if(!ne.ok){const{status:R}=ne;if((R===429||R===503||R===504)&&++q!==C){await new Promise(ae=>setTimeout(ae,We(q-1)));continue}throw fe.fromResponse(ne)}return ne}}function ge(ze){return ze.arrayBuffer()}function me(ze){return ze.json()}async function Ie(ze,Be,q,ne=_.fx){if(ne===_.fx){const B=await Ve(ze,Be);return await q(B)}const R=new AbortController,ae=ne.add(()=>R.abort());try{const B=await Ve(ze,{...Be,signal:R.signal});return await q(B)}finally{ae()}}const tt=new F.R;function Dt(ze,Be){let q;return typeof Be=="number"?q=`${Be-1}`:(Uint64.decrement(tt,Be),q=tt.toString()),{Range:`bytes=${ze}-${q}`}}function Ge(ze){const Be=/^([^:/]+):\/\/([^/]+)((?:\/.*)?)$/,q=ze.match(Be);if(q===null)throw new Error(`Invalid URL: ${JSON.stringify(ze)}`);return{protocol:q[1],host:q[2],path:q[3]}}function It(ze){return ze instanceof fe?ze.status===0||ze.status===403||ze.status===404:!1}},7900:(se,Ee,G)=>{G.d(Ee,{$v:()=>ve,B8:()=>Qt,DW:()=>We,J6:()=>te,JB:()=>me,JY:()=>Le,MM:()=>he,Mo:()=>ye,Rf:()=>Xe,Sf:()=>T,VH:()=>Bn,Vr:()=>Ve,We:()=>Vn,Xu:()=>qe,ZD:()=>Bt,Zu:()=>Lt,Zw:()=>C,_D:()=>F,aO:()=>ds,bL:()=>Pe,bX:()=>He,by:()=>rt,cQ:()=>P,f4:()=>st,gG:()=>ht,j3:()=>ii,pf:()=>qt,qi:()=>Ii,si:()=>Kt,sl:()=>et,uS:()=>K,uz:()=>Ze,vS:()=>re,vp:()=>ge,xU:()=>de,z$:()=>cs,zB:()=>W,zo:()=>fe,zr:()=>f});var _=G(3038);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function F(A){const H=typeof A;if(H==="number"||H==="string"){const ie=parseFloat(""+A);if(!Number.isNaN(ie))return ie}throw new Error(`Expected floating-point number, but received: ${JSON.stringify(A)}.`)}function fe(A){const H=F(A);if(Number.isFinite(H))return H;throw new Error(`Expected finite floating-point number, but received: ${H}.`)}function C(A){const H=F(A);if(Number.isFinite(H)&&H>=0)return H;throw new Error(`Expected finite non-negative floating-point number, but received: ${H}.`)}function ye(A){const H=fe(A);if(H>0)return H;throw new Error(`Expected positive finite floating-point number, but received: ${H}.`)}function Le(A,H){return ie=>{const le=F(ie);if(le>=A&&le<=H)return le;throw new Error(`Expected floating-point number in range [${A}, ${H}], but received: ${le}.`)}}function We(A,H,ie=F){Xe(H),A[0]=A[1]=A[2]=0;for(const le of Object.keys(H))switch(le){case"x":A[0]=ie(H[le]);break;case"y":A[1]=ie(H[le]);break;case"z":A[2]=ie(H[le]);break;default:throw new Error(`Expected object to have keys ['x', 'y', 'z'], but received: ${JSON.stringify(H)}.`)}return A}function Ve(A,H){const ie=A.length;if(!Array.isArray(H)||H.length!==ie)throw new Error("Incompatible sizes");for(let le=0;leH==='"'?"'":'"')}function tt(A){return Ie(JSON.stringify(Ie(A)))}const Dt="_";function Ge(A){if(typeof A=="object"){if(A===null)return"null";const H=A.toJSON;if(typeof H=="function")return Ge(H.call(A));if(Array.isArray(A)){let Te="[";const ot=A.length;let ut=0;if(ut=2&&A.charAt(0)===H&&A.charAt(A.length-1)===H){let Ce=A.substr(1,A.length-2),Te=ie;for(;Ce.length>0;){const ot=Ce.match(le);if(ot===null){Te+=Ce;break}Te+=ot[1],ot[2]===ie?(Te+="\\",Te+=ie):Te+=H,Ce=Ce.substr(ot.index+ot[0].length)}return Te+=ie,Te}return A}function B(A){return ae(A,"'",'"',ne)}function J(A,H,ie){const le=/[&_,]/g;let Ce,Te,ot;ie==='"'?(Ce="'",Te=ne,ot=Be):(Ce='"',Te=R,ot=q);let ut="";for(;A.length>0;){const j=A.match(ot);let Li,Re;if(j===null)Li=A,A="",Re="";else{Li=A.substr(0,j.index),A=A.substr(j.index+j[0].length);const Xt=j[1];Xt!==void 0?Re=ae(Xt,Ce,ie,Te):Re=j[2]}ut+=Li.replace(le,H),ut+=Re}return ut}function $(A){return J(A,",",'"')}function M(A){return J(A,"_","'")}function T(A){return JSON.parse($(A))}function U(A){let H="";for(;A.length>0;){const ie=A.match(Be);let le,Ce;if(ie===null)le=A,A="",Ce="";else{le=A.substr(0,ie.index),A=A.substr(ie.index+ie[0].length);const Te=ie[1];Te!==void 0?Ce=B(Te):Ce=ie[2]}H+=le.replace(/\(/g,"[").replace(/\)/g,"]").replace("True","true").replace("False","false").replace(/,\s*([}\]])/g,"$1"),H+=Ce}return H}function ee(A){return JSON.parse(U(A))}function te(A,H){if(!Array.isArray(A))throw new Error(`Expected array, but received: ${JSON.stringify(A)}.`);if(H!==void 0&&A.length!==H)throw new Error(`Expected array of length ${H}, but received: ${JSON.stringify(A)}.`);return A}function ve(A,H){if(!Array.isArray(A))throw new Error(`Expected array, but received: ${JSON.stringify(A)}.`);return A.map(H)}function qe(A,H,ie){const le=A.length;if(!Array.isArray(H)||H.length!==le)throw new Error(`Expected length ${le} array, but received: ${JSON.stringify(H)}.`);for(let Ce=0;CeCe===void 0?le:ie(Ce))}function re(A,H){Xe(A);const ie=new Map;for(const le of Object.keys(A))try{ie.set(le,H(A[le]))}catch(Ce){throw new Error(`Error parsing value associated with key ${JSON.stringify(le)}: ${Ce.message}`)}return ie}function de(A){if(typeof A!="number"||!Number.isFinite(A)||A<0||A>1)throw new Error(`Expected floating point number in [0,1], but received: ${JSON.stringify(A)}.`);return A}function Pe(A){if(A==="")return{};if(A.startsWith("{"))return T(A);const H={},ie=A.split(/[&;]/);for(const le of ie){const Ce=le.match(/^([^=&;]+)=([^&;]*)$/);if(Ce===null)throw new Error(`Invalid query string part: ${JSON.stringify(le)}.`);H[Ce[1]]=decodeURIComponent(Ce[2])}return H}function Ze(A){if(A===void 0)return"";const H=Object.keys(A);return H.length===0?"":H.some(ie=>typeof A[ie]!="string")?JSON.stringify(A):H.map(ie=>`${encodeURIComponent(ie)}=${encodeURIComponent(A[ie])}`).join("&")}function et(A,H,ie=/^[a-zA-Z]/){if(typeof A=="string"&&A.match(ie)!==null){const le=A.toUpperCase();if(Object.prototype.hasOwnProperty.call(H,le))return H[le]}throw new Error(`Invalid enum value: ${JSON.stringify(A)}.`)}function st(A){return qe(_.eR.create(),A,fe)}function rt(A){return qe(_.eR.create(),A,ye)}function ht(A){return qe(_.eR.create(),A,Vn)}function Kt(A){if(!Array.isArray(A))throw new Error(`Expected array, received: ${JSON.stringify(A)}.`);for(const H of A)if(typeof H!="string")throw new Error(`Expected string, received: ${JSON.stringify(H)}.`);return A}function Bn(A){if(!Array.isArray(A))throw new Error(`Expected array, received: ${JSON.stringify(A)}.`);for(const H of A)if(!Number.isInteger(H))throw new Error(`Expected integer, received: ${JSON.stringify(H)}.`);return A}function qt(A){if(!Array.isArray(A))throw new Error(`Expected array, received: ${JSON.stringify(A)}.`);for(const H of A)F(H);return A}function ds(A){if(typeof A!="boolean")throw new Error(`Expected boolean, received: ${JSON.stringify(A)}`);return A}function Lt(A){for(const H in A)return A}function Ii(A,H){if(A!==H)throw new Error(`Expected ${JSON.stringify(H)}, but received: ${JSON.stringify(A)}`);return H}function Bt(A,H){if(A===void 0){const ie=new Array(H);return ie.fill(null),ie}return qe(new Array(H),A,ie=>{if(ie!==null&&typeof ie!="string")throw new Error(`Expected string or null, but received: ${JSON.stringify(name)}`);return ie})}},147:(se,Ee,G)=>{G.d(Ee,{Aw:()=>Ve,C:()=>We,DA:()=>fe,DI:()=>Ie,LC:()=>tt,Lk:()=>Le,_U:()=>It,ay:()=>ze,lw:()=>_,nx:()=>C,u6:()=>ye,vo:()=>Ge});/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function _(q,ne,R,ae,B,J,$,M,T){for(let U=0;U<$;++U)for(let ee=0;eeU&&(U=te,$=ee)}}if(B!==$){ae*=-1;for(let U=0;U{G.d(Ee,{$$:()=>C,HN:()=>_,IY:()=>fe});/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class _{constructor(){this.handlers=new Set,this.count=0;const Le=this;this.dispatch=function(){++Le.count,Le.handlers.forEach(We=>{We.apply(this,arguments)})}}add(Le){return this.handlers.add(Le),()=>this.remove(Le)}remove(Le){return this.handlers.delete(Le)}dispose(){this.handlers=void 0}}function F(ye,...Le){ye();for(let We=0,Ve=Le.length;We{for(let We=0,Ve=Le.length;We{}},remove(ye){return!1}}},2974:(se,Ee,G)=>{se.exports=G.p+"bossauth.html"},3956:(se,Ee,G)=>{se.exports=G.p+"google_oauth2_redirect.html"},4320:(se,Ee,G)=>{var _=G(3206),F=G(4037),fe=G(8103),C=G(3038);/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function ye(i){return("0"+i.toString(16)).slice(-2)}function Le(i){return Array.prototype.map.call(i,ye).join("")}function We(i){if(!/^(?:[0-9a-fA-F]{2})*$/.test(i))throw new Error("Invalid hex-encoded string");const e=i.length/2,t=new Uint8Array(e);for(let n=0;n>>0)+Math.min(255,Math.max(0,Math.round(i[e-1-n]*255)));return t}function tt(i){return C.eR.fromValues((i>>>0&255)/255,(i>>>8&255)/255,(i>>>16&255)/255)}function Dt(i){return C.ln.fromValues((i>>>0&255)/255,(i>>>8&255)/255,(i>>>16&255)/255,(i>>>24&255)/255)}function Ge(i){if(i[3]===void 0||i[3]===1){let t="#";for(let n=0;n<3;++n)t+=ye(Math.min(255,Math.max(0,Math.round(i[n]*255))));return t}let e="rgba(";for(let t=0;t<3;++t)t!==0&&(e+=", "),e+=Math.min(255,Math.max(0,Math.round(i[t]*255)));return e+=`, ${(0,fe.K)(i[3])})`,e}function It(i){return i<=.03928?i/12.92:((i+.055)/1.055)**2.4}function ze(i){const[e,t,n]=i;return .2126*It(e)+.7152*It(t)+.0722*It(n)}function Be(i){return ze(i)<=.179}class q extends _.B0{constructor(e){super(C.eR.clone(e)),this.defaultValue=e}toString(){return Ge(this.value)}toJSON(){if(!C.eR.equals(this.value,this.defaultValue))return Ge(this.value)}reset(){this.value=C.eR.clone(this.defaultValue)}restoreState(e){if(e===void 0){this.reset();return}const{value:t}=this,n=me(e);C.eR.equals(t,n)||(this.value=n)}}class ne extends _.B0{constructor(){super(void 0)}toJSON(){const{value:e}=this;if(e!==void 0)return Ge(e)}reset(){this.value=void 0}restoreState(e){if(e===void 0){this.reset();return}const{value:t}=this,n=me(e);(t===void 0||!C.eR.equals(t,n))&&(this.value=n)}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */var R=(i=>(i[i.UINT8=0]="UINT8",i[i.INT8=1]="INT8",i[i.UINT16=2]="UINT16",i[i.INT16=3]="INT16",i[i.UINT32=4]="UINT32",i[i.INT32=5]="INT32",i[i.UINT64=6]="UINT64",i[i.FLOAT32=7]="FLOAT32",i))(R||{});const ae={0:!1,1:!0,2:!1,3:!0,4:!1,5:!0,6:!1,7:void 0},B={0:1,1:1,2:2,3:2,4:4,5:4,6:8,7:4},J={0:Uint8Array,1:Int8Array,2:Uint16Array,3:Int16Array,4:Uint32Array,5:Int32Array,6:Uint32Array,7:Float32Array},$={0:1,1:1,2:1,3:1,4:1,5:1,6:2,7:1};function M(i,e,t=0,n=e.byteLength){const s=B[i],r=$[i];return new J[i](e,t,n/s*r)}var T=G(2596);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */var U=(i=>(i[i.LITTLE=0]="LITTLE",i[i.BIG=1]="BIG",i))(U||{});function ee(){const i=Uint16Array.of(4386);return new Uint8Array(i.buffer)[0]===17?1:0}const te=ee();function ve(i){const e=new Uint8Array(i.buffer,i.byteOffset,i.byteLength);for(let t=0,n=e.length;ti==i>0?K[t]===4294967295?(K[t]=0,K[n]+=1):K[t]+=1:K[t]===0?(K[t]=4294967295,K[n]-=1):K[t]-=1,W[0]}var P=G(8796);/** + * @license + * Copyright 2021 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const he={[R.UINT8]:[0,255],[R.INT8]:[-128,127],[R.UINT16]:[0,65535],[R.INT16]:[-32768,32767],[R.UINT32]:[0,4294967295],[R.INT32]:[-2147483648,2147483647],[R.UINT64]:[P.R.ZERO,new P.R(4294967295,4294967295)],[R.FLOAT32]:[0,1]};function re(i,e){if(typeof e=="number"){const o=i[0],a=i[1];return(e-o)/(a-o)}const t=i[0],n=i[1];let s;P.R.compare(e,t)<0?s=-P.R.subtract(ht,t,e).toNumber():s=P.R.subtract(ht,e,t).toNumber();let r=P.R.absDifference(ht,n,t).toNumber();return P.R.compare(t,n)>0&&(r*=-1),s/r}function de(i,e,t){if(typeof i[0]=="number"){const a=i[0],l=i[1];let c=a*(1-t)+l*t;if(e!==R.FLOAT32){const d=he[e];c=Math.round(c),c=Math.max(d[0],c),c=Math.min(d[1],c)}return c}let n=i[0],s=i[1];P.R.compare(n,s)>0&&([n,s]=[s,n],t=1-t);const r=P.R.subtract(ht,s,n).toNumber(),o=new P.R;return t<=0?(ht.setFromNumber(r*-t),P.R.subtract(o,n,P.R.min(ht,n))):t>=1?(ht.setFromNumber(r*(t-1)),P.R.add(o,s,ht),P.R.less(o,s)&&(o.low=o.high=4294967295)):(ht.setFromNumber(r*t),P.R.add(o,n,ht),P.R.less(o,n)&&(o.low=o.high=4294967295)),o}function Pe(i,e){return typeof e=="number"?Math.min(Math.max(i[0],e),i[1]):P.R.min(P.R.max(i[0],e),i[1])}function Ze(i,e){return[Pe(i,e[0]),Pe(i,e[1])]}function et(i){if(rt(i[0],i[1])<=0)return i;throw new Error(`Invalid interval: [${i[0]}, ${i[1]}]`)}function st(i){return rt(i[0],i[1])<=0?i:[i[1],i[0]]}function rt(i,e){return typeof i=="number"?i-e:P.R.compare(i,e)}const ht=new P.R,Kt=new P.R;function Bn(i,e){return typeof e=="number"?Math.abs(e-i[0])s[1])throw new Error(`Invalid ${R[i].toLowerCase()} value: ${JSON.stringify(t)}`);return n}}}function ds(i){if(typeof i=="number")return i;if(typeof i=="string"){const e=new P.R,t=Number(i);if(e.tryParseString(i))return t.toString()===e.toString()?t:e;if(!Number.isFinite(t))throw new Error(`Invalid value: ${JSON.stringify(i)}`);return t}throw new Error(`Invalid value: ${JSON.stringify(i)}`)}function Lt(i,e){return(0,f.Xu)(new Array(2),i,t=>qt(e,t))}function Ii(i){return(0,f.Xu)(new Array(2),i,e=>ds(e))}function Bt(i,e,t){return i===R.UINT64?P.R.equal(e[0],t[0])&&P.R.equal(e[1],t[1]):e[0]===t[0]&&e[1]===t[1]}function A(i,e,t=he[e]){if(!Bt(e,i,t))return e===R.UINT64?[i[0].toString(),i[1].toString()]:i}function H(i,e,t){switch(i){case R.FLOAT32:return ue(e,t*(1/0));case R.UINT64:{const n=e;return t===-1?n.low===0&&n.high===0?n:P.R.decrement(new P.R,n):n.low===4294967295&&n.high===4294967295?n:P.R.increment(new P.R,n)}default:{const n=he[i];return Math.max(n[0],Math.min(n[1],e+t))}}}function ie(i,e){switch(i){case R.FLOAT32:return 0;case R.UINT64:return .5/P.R.absDifference(ht,e[0],e[1]).toNumber();default:return .5/Math.abs(e[0]-e[1])}}function le(i,e){switch(i){case R.FLOAT32:return 1;case R.UINT64:{const t=P.R.absDifference(ht,e[0],e[1]).toNumber();return t/(t+1)}default:{const t=Math.abs(e[0]-e[1]);return t/(t+1)}}}function Ce(i,e){if(i===void 0)return he[e];let[t,n]=i;if(e===R.UINT64)return typeof t=="number"&&(t=P.R.fromNumber(t)),typeof n=="number"&&(n=P.R.fromNumber(n)),[t,n];if(typeof t!="number"&&(t=t.toNumber()),typeof n!="number"&&(n=n.toNumber()),e!==R.FLOAT32){t=Math.round(t),n=Math.round(n);const s=he[e];Number.isFinite(t)?t=Math.min(Math.max(s[0],t),s[1]):t=s[0],Number.isFinite(n)?n=Math.min(Math.max(s[0],n),s[1]):n=s[1]}return[t,n]}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function Te(i=128){const e=Math.ceil(i/32),t=new Uint32Array(e);crypto.getRandomValues(t);let n="";for(let s=0;s(i[i.POINT=0]="POINT",i[i.LINE=1]="LINE",i[i.AXIS_ALIGNED_BOUNDING_BOX=2]="AXIS_ALIGNED_BOUNDING_BOX",i[i.ELLIPSOID=3]="ELLIPSOID",i))(Re||{});const Xt=[0,1,2,3],kl={float32:R.FLOAT32,uint32:R.UINT32,int32:R.INT32,uint16:R.UINT16,int16:R.INT16,uint8:R.UINT8,int8:R.INT8,rgb:void 0,rgba:void 0};function jb(i){return i.type!=="rgb"&&i.type!=="rgba"}function us(i){return i.type==="uint8"&&i.tag!==void 0}const si={rgb:{serializedBytes(){return 3},alignment(){return 1},serializeCode(i,e){return`dv.setUint16(${e}, ${i}, true);dv.setUint8(${e} + 2, ${i} >>> 16);`},deserializeCode(i,e){return`${i} = dv.getUint16(${e}, true) | (dv.getUint8(${e} + 2) << 16);`},deserializeJson(i){return Ie(me(i))},serializeJson(i){return Ge(tt(i))}},rgba:{serializedBytes(){return 4},alignment(){return 1},serializeCode(i,e){return`dv.setUint32(${e}, ${i}, true);`},deserializeCode(i,e){return`${i} = dv.getUint32(${e}, true);`},deserializeJson(i){return Ie(ge(i))},serializeJson(i){return Ge(Dt(i))}},float32:{serializedBytes(){return 4},alignment(){return 4},serializeCode(i,e){return`dv.setFloat32(${e}, ${i}, isLittleEndian);`},deserializeCode(i,e){return`${i} = dv.getFloat32(${e}, isLittleEndian);`},deserializeJson(i){return(0,f._D)(i)},serializeJson(i){return i}},uint32:{serializedBytes(){return 4},alignment(){return 4},serializeCode(i,e){return`dv.setUint32(${e}, ${i}, isLittleEndian);`},deserializeCode(i,e){return`${i} = dv.getUint32(${e}, isLittleEndian);`},deserializeJson(i){return(0,f.bX)(i)},serializeJson(i){return i}},int32:{serializedBytes(){return 4},alignment(){return 4},serializeCode(i,e){return`dv.setInt32(${e}, ${i}, isLittleEndian);`},deserializeCode(i,e){return`${i} = dv.getInt32(${e}, isLittleEndian);`},deserializeJson(i){return(0,f.bX)(i)},serializeJson(i){return i}},uint16:{serializedBytes(){return 2},alignment(){return 2},serializeCode(i,e){return`dv.setUint16(${e}, ${i}, isLittleEndian);`},deserializeCode(i,e){return`${i} = dv.getUint16(${e}, isLittleEndian);`},deserializeJson(i){return(0,f.bX)(i)},serializeJson(i){return i}},int16:{serializedBytes(){return 2},alignment(){return 2},serializeCode(i,e){return`dv.setInt16(${e}, ${i}, isLittleEndian);`},deserializeCode(i,e){return`${i} = dv.getInt16(${e}, isLittleEndian);`},deserializeJson(i){return(0,f.bX)(i)},serializeJson(i){return i}},uint8:{serializedBytes(){return 1},alignment(){return 1},serializeCode(i,e){return`dv.setUint8(${e}, ${i});`},deserializeCode(i,e){return`${i} = dv.getUint8(${e});`},deserializeJson(i){return(0,f.bX)(i)},serializeJson(i){return i}},int8:{serializedBytes(){return 2},alignment(){return 1},serializeCode(i,e){return`dv.setInt8(${e}, ${i});`},deserializeCode(i,e){return`${i} = dv.getInt8(${e});`},deserializeJson(i){return(0,f.bX)(i)},serializeJson(i){return i}}},Yb=255;function xh(i,e,t){let n=0;const s=t.length,r=new Array(s),o=[];for(let h=0;hsi[t[h].type].alignment(i);r.sort((h,p)=>a(p)-a(h));let l=0;const c=new Array(s);let d=e;const u=()=>{d+=(4-d%4)%4,n+=d,o[l]=d,d=0,++l};for(let h=0;h{},this.propertyGroupBytes=[t];return}const{serializedBytes:s,offsets:r,propertyGroupBytes:o}=xh(e,t,n);this.propertyGroupBytes=o;let a="let groupOffset0 = offset;";for(let u=1;usi[t].deserializeJson(l),0);let r,o,a;switch(t){case"rgb":case"rgba":break;default:{const l=R[t.toUpperCase()];r=(0,f.MM)(i,"enum_values",c=>(0,f.$v)(c,d=>qt(l,d))),r!==void 0&&(o=(0,f.cQ)(i,"enum_labels",c=>(0,f.Xu)(new Array(r.length),c,f.zr))),a=(0,f.MM)(i,"tag",f.zr)}}return{type:t,identifier:e,description:n,default:s,enumValues:r,enumLabels:o,tag:a}}function eC(i){const e=i.default,t=jb(i),n=t?i.tag:void 0,s=t?i.enumValues:void 0,r=t?i.enumLabels:void 0;return{id:i.identifier,description:i.description,type:i.type,tag:n,enum_values:s,enum_labels:r,default:e===0?void 0:si[i.type].serializeJson(e)}}function tC(i){if(!(i===void 0||i.length===0))return i.map(eC)}function Dh(i){if(i===void 0)return[];const e=(0,f.$v)(i,Zb);return Xb(e),e}function Al(i,e,t,n,s){for(let r=0;r(0,f.Xu)(new Float32Array(t),n,f.zo)),i.pointB=(0,f.cQ)(e,"pointB",n=>(0,f.Xu)(new Float32Array(t),n,f.zo))},serializedBytes(i){return 2*4*i},serialize(i,e,t,n,s){Ml(i,e,t,n,s.pointA,s.pointB)},deserialize:(i,e,t,n,s)=>{const r=new Float32Array(n),o=new Float32Array(n);return Ol(i,e,t,n,r,o),{type:1,pointA:r,pointB:o,id:s,properties:[]}},visitGeometry(i,e){e(i.pointA,!1),e(i.pointB,!1)}},0:{icon:"\u26AC",description:"Point",toJSON:i=>({point:Array.from(i.point)}),restoreState:(i,e,t)=>{i.point=(0,f.cQ)(e,"point",n=>(0,f.Xu)(new Float32Array(t),n,f.zo))},serializedBytes:i=>i*4,serialize:(i,e,t,n,s)=>{Al(i,e,t,n,s.point)},deserialize:(i,e,t,n,s)=>{const r=new Float32Array(n);return Nl(i,e,t,n,r),{type:0,point:r,id:s,properties:[]}},visitGeometry(i,e){e(i.point,!1)}},2:{icon:"\u2751",description:"Bounding Box",toJSON:i=>({pointA:Array.from(i.pointA),pointB:Array.from(i.pointB)}),restoreState:(i,e,t)=>{i.pointA=(0,f.cQ)(e,"pointA",n=>(0,f.Xu)(new Float32Array(t),n,f.zo)),i.pointB=(0,f.cQ)(e,"pointB",n=>(0,f.Xu)(new Float32Array(t),n,f.zo))},serializedBytes:i=>2*4*i,serialize(i,e,t,n,s){Ml(i,e,t,n,s.pointA,s.pointB)},deserialize:(i,e,t,n,s)=>{const r=new Float32Array(n),o=new Float32Array(n);return Ol(i,e,t,n,r,o),{type:2,pointA:r,pointB:o,id:s,properties:[]}},visitGeometry(i,e){e(i.pointA,!1),e(i.pointB,!1)}},3:{icon:"\u25CE",description:"Ellipsoid",toJSON:i=>({center:Array.from(i.center),radii:Array.from(i.radii)}),restoreState:(i,e,t)=>{i.center=(0,f.cQ)(e,"center",n=>(0,f.Xu)(new Float32Array(t),n,f.zo)),i.radii=(0,f.cQ)(e,"radii",n=>(0,f.Xu)(new Float32Array(t),n,f.Zw))},serializedBytes:i=>2*4*i,serialize(i,e,t,n,s){Ml(i,e,t,n,s.center,s.radii)},deserialize:(i,e,t,n,s)=>{const r=new Float32Array(n),o=new Float32Array(n);return Ol(i,e,t,n,r,o),{type:3,center:r,radii:o,id:s,properties:[]}},visitGeometry(i,e){e(i.center,!1),e(i.radii,!0)}}};function _l(i,e){const t=Ft[i.type].toJSON(i,e.rank);t.type=Re[i.type].toLowerCase(),t.id=i.id,t.description=i.description||void 0;const{relatedSegments:n}=i;n?.some(r=>r.length!==0)&&(t.segments=n.map(r=>r.map(o=>o.toString())));const s=e.properties.value;return s.length!==0&&(t.props=i.properties.map((r,o)=>si[s[o].type].serializeJson(r))),t}function nC(i,e,t=!1){(0,f.Rf)(i);const n=(0,f.cQ)(i,"type",l=>(0,f.sl)(l,Re)),s=(0,f.cQ)(i,"id",t?f.z$:f.zr)||Vl(),r=(0,f.cQ)(i,"segments",l=>{if(l===void 0)return e.relationships.map(()=>[]);const c=(0,f.J6)(l);return c.length===0?e.relationships.map(()=>[]):e.relationships.length===1&&!Array.isArray(c[0])?[(0,f.$v)(c,d=>P.R.parseString(d))]:(0,f.$v)((0,f.J6)(l,e.relationships.length),d=>(0,f.$v)(d,u=>P.R.parseString(u)))}),o=(0,f.cQ)(i,"props",l=>{const c=e.properties.value;return l===void 0?c.map(d=>d.default):(0,f.$v)((0,f.J6)(l,c.length),(d,u)=>si[c[u].type].deserializeJson(d))}),a={id:s,description:(0,f.cQ)(i,"description",f.z$),relatedSegments:r,properties:o,type:n};return Ft[n].restoreState(a,i,e.rank),a}class hs extends T.O8{constructor(e,t=[],n=new _.B0([])){super(),this.relationships=t,this.properties=n,this.annotationMap=new Map,this.changed=new j.IY,this.readonly=!1,this.childAdded=new j.HN,this.childUpdated=new j.HN,this.childCommitted=new j.HN,this.childDeleted=new j.HN,this.pending=new Set,this.references=new Map,this.rank_=e,this.annotationPropertySerializers=Pl(e,n.value)}get rank(){return this.rank_}hasNonSerializedProperties(){return!0}add(e,t=!0){if(this.ensureUpdated(),!e.id)e.id=Vl();else if(this.annotationMap.has(e.id))throw new Error(`Annotation id already exists: ${JSON.stringify(e.id)}.`);return this.annotationMap.set(e.id,e),t||this.pending.add(e.id),this.changed.dispatch(),this.childAdded.dispatch(e),t&&this.childCommitted.dispatch(e.id),this.getReference(e.id)}commit(e){this.ensureUpdated();const t=e.id;this.pending.delete(t),this.changed.dispatch(),this.childCommitted.dispatch(t)}update(e,t){if(this.ensureUpdated(),e.value===null)throw new Error("Annotation already deleted.");e.value=t,this.annotationMap.set(t.id,t),e.changed.dispatch(),this.changed.dispatch(),this.childUpdated.dispatch(t)}[Symbol.iterator](){return this.ensureUpdated(),this.annotationMap.values()}get(e){return this.ensureUpdated(),this.annotationMap.get(e)}delete(e){e.value!==null&&(e.value=null,this.annotationMap.delete(e.id),this.pending.delete(e.id),e.changed.dispatch(),this.changed.dispatch(),this.childDeleted.dispatch(e.id))}getReference(e){let t=this.references.get(e);return t!==void 0?t.addRef():(t=new Li(e),t.value=this.annotationMap.get(e)||null,this.references.set(e,t),t.registerDisposer(()=>{this.references.delete(e)}),t)}ensureUpdated(){}toJSON(){this.ensureUpdated();const e=[],{pending:t}=this;for(const n of this)t.has(n.id)||e.push(_l(n,this));return e}clear(){this.annotationMap.clear(),this.pending.clear(),this.changed.dispatch()}restoreState(e){this.ensureUpdated();const{annotationMap:t}=this;t.clear(),this.pending.clear(),e!==void 0&&(0,f.$v)(e,n=>{const s=nC(n,this);t.set(s.id,s)});for(const n of this.references.values()){const{id:s}=n,r=t.get(s);n.value=r||null,n.changed.dispatch()}this.changed.dispatch()}reset(){this.clear()}}class Ih extends hs{constructor(e,t=new _.B0([]),n){super(e.value.sourceRank,n,t),this.watchableTransform=e,this.properties=t,this.getTagProperties=()=>{const{properties:s}=this;return s.value.filter(us)},this.curCoordinateTransform=e.value,this.registerDisposer(e.changed.add(()=>this.ensureUpdated())),this.registerDisposer(t.changed.add(()=>{this.updateAnnotationPropertySerializers(),this.changed.dispatch()}))}get rank(){return this.ensureUpdated(),this.rank_}updateAnnotationPropertySerializers(){this.annotationPropertySerializers=Pl(this.rank_,this.properties.value)}addProperty(e){this.properties.value.push(e);for(const t of this)t.properties.push(e.default);this.properties.changed.dispatch()}removeProperty(e){const t=this.properties.value.findIndex(n=>n.identifier===e);this.properties.value.splice(t,1);for(const n of this)n.properties.splice(t,1);this.properties.changed.dispatch()}ensureUpdated(){const e=this.watchableTransform.value,{curCoordinateTransform:t}=this;if(e===t)return;this.curCoordinateTransform=e;const n=e.sourceRank,s=t.sourceRank;if(s===n&&(t.inputSpace===e.inputSpace||(0,F.r1)(t.inputSpace.ids.slice(0,n),e.inputSpace.ids.slice(0,n))))return;const{ids:r}=e.inputSpace,o=t.inputSpace.ids,a=[];for(let c=0;c=s&&(d=-1),a.push(d)}const l=c=>{const d=new Float32Array(n);for(let u=0;uS.id),r[c]=new Map(p.map((S,w)=>[S.id,w]));const g=Ft[c].serialize,v=n[c],y=d.propertyGroupBytes[0];for(let S=0,w=p.length;Snew P.R(r.low,r.high)))}return i}var De=G(147);/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const lo=[{prefix:"Y",exponent:24,longPrefix:"yotta"},{prefix:"Z",exponent:21,longPrefix:"zetta"},{prefix:"E",exponent:18,longPrefix:"exa"},{prefix:"P",exponent:15,longPrefix:"peta"},{prefix:"T",exponent:12,longPrefix:"tera"},{prefix:"G",exponent:9,longPrefix:"giga"},{prefix:"M",exponent:6,longPrefix:"mega"},{prefix:"k",exponent:3,longPrefix:"kilo"},{prefix:"",exponent:0,longPrefix:""},{prefix:"m",exponent:-3,longPrefix:"milli"},{prefix:"\xB5",exponent:-6,longPrefix:"micro"},{prefix:"n",exponent:-9,longPrefix:"nano"},{prefix:"p",exponent:-12,longPrefix:"pico"},{prefix:"f",exponent:-15,longPrefix:"femto"},{prefix:"a",exponent:-18,longPrefix:"atto"},{prefix:"z",exponent:-21,longPrefix:"zepto"},{prefix:"y",exponent:-24,longPrefix:"yocto"}],Bl=[...lo,{prefix:"h",exponent:2,longPrefix:"hecto"},{prefix:"da",exponent:1,longPrefix:"deca"},{prefix:"d",exponent:-1,longPrefix:"deci"},{prefix:"c",exponent:-2,longPrefix:"centi"}],aC=[{prefix:"u",exponent:-6},...Bl],ir=new Map;ir.set("",{unit:"",exponent:0});const lC=new Map;for(const{prefix:i,exponent:e}of aC){lC.set(e,i);for(const t of["m","s","Hz","rad/s"])ir.set(`${i}${t}`,{unit:t,exponent:e})}function Rh(i){const e=Math.log10(i),t=lo.length,n=(0,F.lX)(0,t,s=>lo[s].exponent<=e);return lo[Math.min(n,t-1)]}function kh(i,e,t={}){const{precision:n=6,elide1:s=!0}=t;let r=i,o="";if(e!==""){const l=Rh(i);o=l.prefix,r=Fl(i,-l.exponent)}if(s&&r===1)return{scale:"",unit:e,prefix:o};let a;if(n!==0){r<1||r>=1e3?a=r.toPrecision(n):a=r.toFixed(n);const l=a.indexOf("e");let c,d;l!==-1?(c=a.substring(0,l),d=a.substring(l)):(c=a,d="");const u=c.match(/.*\.(?:[0-9]*[1-9])?(0+)$/);u!==null&&(c=c.substring(0,c.length-u[1].length),c.endsWith(".")&&(c=c.substring(0,c.length-1)),a=c+d)}else a=r.toString();return{scale:a,unit:e,prefix:o}}function Ri(i,e,t){const{scale:n,unit:s,prefix:r}=kh(i,e,t);return`${n}${r}${s}`}function sr(i){if(i==="")return{scale:1,unit:""};const e=i.match(/^((?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?)?([µa-zA-Z]+)?$/);if(e===null)return;const t=e[1];let n=t===void 0?1:Number(t);if(Number.isNaN(n))return;let s="";if(e[2]!==void 0){const r=ir.get(e[2]);if(r===void 0)return;s=r.unit,r.exponent>0?n*=10**r.exponent:n/=10**-r.exponent}if(!(n<=0||!Number.isFinite(n)))return{scale:n,unit:s}}function Ph(i){const e=ir.get(i);if(e===void 0)throw new Error(`Invalid unit: ${JSON.stringify(i)}`);return e}function Fl(i,e){return e>=0?i*10**e:i/10**-e}/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function yV(i,e){const t=i.length;for(let n=0;nn-s),e=Array.from(i,n=>t.get(n)),{coordinates:i,labels:e}}function Nh(i){if(i.length===1)return i[0];const e=new Map;let t=!1;for(const r of i){r.explicit&&(t=!0);const{coordinates:o,labels:a}=r;for(let l=0,c=o.length;lr-o);const s=Array.from(n,r=>e.get(r));return{explicit:t,coordinates:n,labels:s}}function Oh(i){if(i=i.filter(e=>e!==void 0),i.length!==0)return Nh(i)}function mC(i,e){return(0,F.r1)(i.transform,e.transform)&&pC(i.box,e.box)}function co(i,e){return i.valid===e.valid&&i.rank===e.rank&&(0,F.r1)(i.names,e.names)&&(0,F.r1)(i.ids,e.ids)&&(0,F.r1)(i.timestamps,e.timestamps)&&(0,F.r1)(i.units,e.units)&&(0,F.r1)(i.scales,e.scales)&&(0,F.wm)(i.boundingBoxes,e.boundingBoxes,mC)&&(0,F.wm)(i.coordinateArrays,e.coordinateArrays,fC)}function xV(i,e,t){parseFixedLengthArray(i,t,(n,s)=>{const r=unitFromJson(n);return e[s]=r.exponent,r.unit})}function Oe(i){const{names:e,units:t,scales:n}=i,{valid:s=!0,rank:r=e.length,timestamps:o=e.map(()=>Number.NEGATIVE_INFINITY),ids:a=e.map((u,h)=>-h),boundingBoxes:l=[]}=i,{coordinateArrays:c=new Array(r)}=i,{bounds:d=CC(l,r)}=i;return{valid:s,rank:r,names:e,timestamps:o,ids:a,units:t,scales:n,boundingBoxes:l,bounds:d,coordinateArrays:c}}const Fn=Oe({valid:!1,names:[],units:[],scales:Mh,boundingBoxes:[]}),ki=Oe({valid:!0,names:[],units:[],scales:Mh,boundingBoxes:[]});function vC(i){const[e,t]=(0,f.J6)(i,2),n=(0,f.Mo)(e),s=(0,f.zr)(t),r=ir.get(s);if(r===void 0)throw new Error(`Invalid unit: ${JSON.stringify(s)}`);return{unit:r.unit,scale:Fl(n,r.exponent)}}function uo(i,e=!1){if(i===void 0)return Fn;(0,f.Rf)(i);const t=Yl(Object.keys(i),e),n=t.length,s=new Array(n),r=new Float64Array(n),o=new Array(n);for(let a=0;a{if(Array.isArray(l)){const{unit:c,scale:d}=vC(l);s[a]=c,r[a]=d}else{(0,f.Rf)(l);const c=(0,f.cQ)(l,"coordinates",f.VH),d=(0,f.cQ)(l,"labels",f.si),u=c.length;if(u!==d.length)throw new Error(`Length of coordinates array (${u}) does not match length of labels array (${d.length})`);s[a]="",r[a]=1,o[a]={explicit:!0,...gC(c,d)}}});return Oe({valid:!1,names:t,units:s,scales:r,coordinateArrays:o})}function Gl(i){const{rank:e}=i;if(e===0)return;const{names:t,units:n,scales:s,coordinateArrays:r}=i,o={};for(let a=0;as[l]>0&&a===0);return{lowerBounds:t,upperBounds:n,voxelCenterAtIntegerCoordinates:o}}function wC(i,e,t){const{transform:n,box:s}=i,r=t.length,o=s.lowerBounds.length,a=new Float64Array((o+1)*e);for(let l=0;lEC(n,e,i.scales,t))}function Hl(i,e,t){const n=Oe({valid:i.valid,rank:t.rank,ids:t.ids,names:t.names,timestamps:t.timestamps,scales:t.scales,units:t.units,boundingBoxes:$h(i,e,t.scales),coordinateArrays:t.coordinateArrays});return co(n,t)?t:n}function Jl(i,e=!1){if(e){const t=Number(i);if(Number.isInteger(t)&&t>=0)return!0}return i.match(/^[a-zA-Z][a-zA-Z_0-9]*['^]?$/)!==null}function ho(i,e=!1){const t=new Set;for(const n of i){if(!Jl(n,e)||t.has(n))return!1;t.add(n)}return!0}function jl(i){const e=i.length,t=new Array(e);t.fill(!0);for(let n=0;n{const Q=s.indexOf(z);return Q!==-1?d[Q]=!1:u.push(Y),Q}),{outputSpace:p}=i,{names:m,units:g,scales:v,ids:y,timestamps:S,coordinateArrays:w}=p,b=d,x=[],E=[],D=new Float64Array(o),I=[],L=[],N=new Array(o);let k=0;const O=new Float64Array((o+1)**2);O[O.length-1]=1;for(let z=0;z`${Y}`),units:k.units,scales:k.scales,coordinateArrays:k.coordinateArrays});this.value={rank:O,transform:e.transform||De.DA(Float64Array,O+1),sourceRank:e.sourceRank,outputSpace:e.outputSpace,inputSpace:V};return}const{inputSpace:t,sourceRank:n,outputSpace:s,transform:r,rank:o}=this.defaultTransform,{inputSpace:a,sourceRank:l,outputSpace:c,transform:d}=e,u=e.outputSpace.rank,h=t.names,p=a!==void 0?a.names:h,m=new Array(n);for(let k=0;k=l&&(O=-1),m[k]=O}const g=u-l+n;for(let k=l;k=n?V=0:V=r[o*(o+1)+k]*(s.scales[k]/D[k]):V=d[u*(u+1)+O],L[g*(g+1)+k]=V;for(let z=0;z=n||Y>=n?Q=O===Y?1:0:Q=r[z*(o+1)+k]:Q=d[Y*(u+1)+O],L[z*(g+1)+k]=Q}}const N=t.boundingBoxes.map(k=>Uh(k,o,g));for(let k=n;kkC(n,e));if(!ho(t,e))throw new Error(`Invalid dimensions: ${JSON.stringify(t)}`);return t}class Ql{constructor(e,t){this.combined=e,this.bindings=new Set,this.retainCount=0,this.prevCombined=this.combined.value,this.dimensionRefCounts=new Map,this.handleCombinedChanged=()=>{this.combined.value!==this.prevCombined&&this.update()},this.includeDimensionPredicate_=t}getRenameValidity(e){const t=this.combined.value.names,n=jl(e),s=e.length;for(let r=0;r0?1:0;if(t.size===0&&!n){e.value=Fn;return}const s=this.includeDimensionPredicate_,r=e.value;let o=Array.from(r.names),a=Array.from(r.units),l=Array.from(r.scales),c=Array.from(r.ids),d=Array.from(r.timestamps),u=r.names.map(()=>n?1:0);const h=[];let p=!1;for(const x of t){const{space:{value:E},prevValue:D,mappedDimensionIds:I}=x;p=p||E.valid;const{names:L,units:N,scales:k,ids:O,timestamps:V}=E,z=[],Y=[];h.push(Y),x.mappedDimensionIds=z,x.prevValue=E;const Q=L.length;for(let X=0;Xu[D]!==0;o=o.filter(x),a=a.filter(x),l=l.filter(x),c=c.filter(x),d=d.filter(x),u=u.filter(x),v=o.length}const y=[],S=new Array(v);for(let x=0,E=r.rank;xo.indexOf(k));for(const k of I)y.push(wC(k,v,N));for(let k=0;k{--this.retainCount===0&&this.update()}}bind(e){const t={space:e,mappedDimensionIds:[],prevValue:void 0},{bindings:n}=this;n.size===0&&this.combined.changed.add(this.handleCombinedChanged),n.add(t);const s=e.changed.add(()=>{e.value!==t.prevValue&&this.update()}),r=()=>{s();const{bindings:o}=this;o.delete(t),o.size===0&&this.combined.changed.remove(this.handleCombinedChanged),this.update()};return this.update(),r}}function Jh(i,e,t,n,s){const r=s.length,o=new i((r+1)**2);o[o.length-1]=1;for(let a=0;a{(0,f.Vr)(t,o),C.Yu.normalize(t,t)}),(0,f.MM)(i,"translation",o=>{(0,f.Vr)(n,o)}),(0,f.MM)(i,"scale",o=>{(0,f.Vr)(s,o)});const r=C.pB.create();C.pB.fromRotationTranslationScale(r,t,n,s),e.set(r)}return{sourceRank:3,transform:e,outputSpace:Oe({valid:!0,names:["x","y","z"],units:["m","m","m"],scales:Float64Array.of(1e-9,1e-9,1e-9)}),inputSpace:void 0}}function jh(i){if(i===void 0)return;const e=(0,f.Rf)(i),t=(0,f.cQ)(e,"outputDimensions",uo),n=t.rank,s=(0,f.cQ)(e,"sourceRank",a=>{if(a===void 0)return n;if(!Number.isInteger(a)||a<0||a>n)throw new Error(`Expected integer in range [0, ${n}] but received: ${JSON.stringify(a)}`);return a}),r=(0,f.MM)(e,"inputDimensions",a=>{const l=uo(a,!0);if(l.rank!==n)throw new Error(`Expected rank of ${n}, but received rank of: ${l.rank}`);return l});return{transform:(0,f.MM)(e,"matrix",a=>{const l=new Float64Array((n+1)**2),c=(0,f.J6)(a,n);l[l.length-1]=1;for(let d=0;dl===0))return{transform:a,box:n}}function Kl(i,e){const{ids:t,names:n,scales:s,units:r,timestamps:o,coordinateArrays:a}=i;return Oe({rank:e.length,valid:i.valid,ids:e.map(l=>t[l]),names:e.map(l=>n[l]),timestamps:e.map(l=>o[l]),scales:Float64Array.from(e,l=>s[l]),units:e.map(l=>r[l]),coordinateArrays:e.map(l=>a[l]),boundingBoxes:i.boundingBoxes.map(l=>AC(l,e,i.rank)).filter(l=>l!==void 0)})}function Qh(i,e,t){return e===t?i:Kl(i,(0,F.ep)(i.rank,t,e))}function Kh(i,e){const{transform:t,rank:n}=i,s=(0,C.PC)(t,n,[e]);if(s.length!==1)return;const[r]=s,o=Math.abs(t[(n+1)*r+e]),{inputSpace:a}=i;return{scale:a.scales[r]*o,unit:a.units[r]}}function qh(i,e){const{scales:t,units:n}=i.defaultInputSpace;return ea!==0))throw new Error("Lower bounds of channel coordinate space must all be 0");if(n.some(a=>!Number.isInteger(a)||a<=0||a>=4294967296))throw new Error("Upper bounds of channel coordinate space must all be positive integers");const s=new Uint32Array(n),r=$l(s),o=new Uint32Array(r*e);for(let a=0;ad[V]||`${V}`),y=m.map(V=>u[V]);if(g!==m.length)return{error:"Rank mismatch between model subspace dimensions ("+v.join(", ")+") and corresponding layer/global dimensions ("+y.join(", ")+")"};let S=Jh(Float32Array,c,o,m,h);const w=m.map(V=>u[V]),b=e.names.map(V=>w.indexOf(V)),x=i.names.map(V=>w.indexOf(V));ql(S,g,r,h,i,x),ql(S,g,r,h,e,b);const E=s.names.map(V=>w.indexOf(V));ql(S,g,r,h,s,E);const D=[],I=s.rank;if(n!==void 0){let{subsourceToModelSubspaceTransform:V}=n;p!==g&&(V=De.Aw(new Float32Array((g+1)**2),g,V,p)),S=De.lw(new Float32Array((g+1)**2),g+1,S,g+1,V,g+1,g+1,g+1,g+1)}const L=new Uint32Array(I),{lowerBounds:N,upperBounds:k,voxelCenterAtIntegerCoordinates:O}=s.bounds;for(let V=0;V=4294967296)return{error:`Channel dimension ${s.names[V]} must have lower bound of 0 and positive integer upper bound; current bounds are [${z}, ${Y}]`};L[V]=Y;const Q=E[V];let X=-1;if(Q!==-1)for(let ce=0;ceNC(r,o,a,n,l),[i,e,t,s===void 0?(0,_.XZ)(void 0):s],OC)}function _C(i,e,t,n){const{globalToRenderLayerDimensions:s}=t;for(let r=0;r<3;++r){let o=0;const a=n[r];if(a!==-1){const l=s[a];l!==-1&&(o=e[l])}i[r]=o}}function VC(i,e,t,n){const{globalToRenderLayerDimensions:s}=t;for(let r=0;r<3;++r){const o=n[r];if(o!==-1){const a=s[o];a!==-1&&(i[a]=e[r])}}}function TV(i,e,t,n){const{globalToRenderLayerDimensions:s}=t.modelTransform,{layerRank:r,chunkToLayerTransform:o}=t,a=r+1;for(let l=0;l<3;++l){let c=0;const d=n[l];if(d!==-1){const u=s[d];if(u!==-1){c=o[a*r+u];for(let h=0;hh[p]).join(",\xA0")}) and corresponding chunk dimensions (${Array.from(l,p=>u[p]).join(",\xA0")})`)}const c=C.pB.create();for(let u=0;u<3;++u){const h=o[u];if(h!==-1){for(let p=0;p=1)&&(l=!1)}return l}function DV(i,e,t,n){return scatterUpdate(i,e,n.globalToRenderLayerDimensions),scatterUpdate(i,t,n.localToRenderLayerDimensions),i}function BC(i,e,t){i.fill(0),i[15]=1;let n=!0;const{displayDimensionIndices:s}=e,{globalToRenderLayerDimensions:r,modelToRenderLayerTransform:o}=t,a=t.rank;for(let l=0;l<3;++l){const c=s[l];if(c===-1){n=!1;continue}const d=r[c];if(d===-1){n=!1;continue}i[l+12]=o[d+a*(a+1)];for(let u=0;u<3;++u)i[l+4*u]=o[d+(a+1)*u]}if(!n){const{globalDimensionNames:l}=e,c=Array.from(s.filter(d=>d!==-1),d=>l[d]).join(",\xA0");throw new Error(`Transform from model dimensions (${t.modelDimensionNames.join(",\xA0")}) to display dimensions (${c}) does not have full rank`)}}var Fe=G(5716);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */var Ue=(i=>(i[i.GPU_MEMORY=0]="GPU_MEMORY",i[i.SYSTEM_MEMORY=1]="SYSTEM_MEMORY",i[i.SYSTEM_MEMORY_WORKER=2]="SYSTEM_MEMORY_WORKER",i[i.DOWNLOADING=3]="DOWNLOADING",i[i.QUEUED=4]="QUEUED",i[i.NEW=5]="NEW",i[i.FAILED=6]="FAILED",i[i.EXPIRED=7]="EXPIRED",i))(Ue||{});const Xl=8;var ri=(i=>(i[i.FIRST_TIER=0]="FIRST_TIER",i[i.FIRST_ORDERED_TIER=0]="FIRST_ORDERED_TIER",i[i.VISIBLE=0]="VISIBLE",i[i.PREFETCH=1]="PREFETCH",i[i.LAST_ORDERED_TIER=1]="LAST_ORDERED_TIER",i[i.RECENT=2]="RECENT",i[i.LAST_TIER=2]="LAST_TIER",i))(ri||{});const Zl=3;var ec=(i=>(i[i.totalTime=0]="totalTime",i[i.totalChunks=1]="totalChunks",i))(ec||{}),oi=(i=>(i[i.numChunks=0]="numChunks",i[i.systemMemoryBytes=1]="systemMemoryBytes",i[i.gpuMemoryBytes=2]="gpuMemoryBytes",i))(oi||{});const Un=3,LV=Xl*Zl*Un+2;function Pi(i,e){return i*Zl+e}function tp(i){return Xl*Zl*Un+i}const RV=1e13,FC="ChunkQueueManager",UC="ChunkManager",$C="ChunkSource.invalidate",GC="ChunkQueueManager.requestChunkStatistics",zC="ChunkManager.chunkLayerStatistics";class fo{constructor(){this.numVisibleChunksNeeded=0,this.numVisibleChunksAvailable=0,this.numPrefetchChunksNeeded=0,this.numPrefetchChunksAvailable=0}}var Qe=G(4104);/** + * @license + * Copyright 2024 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */var np=(i=>(i[i.MEDIAN=0]="MEDIAN",i[i.MEAN=1]="MEAN",i[i.MAX=2]="MAX",i))(np||{});class WC{constructor(e=10,t=10){if(this.numStoredTimes=e,this.queryPoolSize=t,this.timeElapsedQueries=[],this.warnedAboutMissingExtension=!1,this.storedTimeDeltas=[],this.queryPoolSize<1)throw new Error(`Query pool size must be at least 1, but got ${t}.`)}getTimingExtension(e){const t=e.getExtension("EXT_disjoint_timer_query_webgl2");return t===null&&!this.warnedAboutMissingExtension&&(console.log("EXT_disjoint_timer_query_webgl2 extension not available. Cannot measure frame time."),this.warnedAboutMissingExtension=!0),t}startFrameTimeQuery(e,t){if(t===null)return null;const n=e.createQuery();return n!==null&&e.beginQuery(t.TIME_ELAPSED_EXT,n),n}endFrameTimeQuery(e,t,n){if(t!==null&&n!==null&&e.endQuery(t.TIME_ELAPSED_EXT),this.timeElapsedQueries.length>=this.queryPoolSize){const s=this.timeElapsedQueries.shift();s!=null&&e.deleteQuery(s)}this.timeElapsedQueries.push(n)}grabAnyFinishedQueryResults(e){const t=[];for(let n=0;n=0;n--)this.timeElapsedQueries.splice(n,1);this.storedTimeDeltas.length>this.numStoredTimes&&(this.storedTimeDeltas=this.storedTimeDeltas.slice(-this.numStoredTimes))}getLastFrameTimesInMs(e=10){return this.storedTimeDeltas.slice(-e)}getQueries(){return this.timeElapsedQueries}}class HC{constructor(e=10,t=8,n=16.666666666666668,s=15){this.numberOfStoredFrameDeltas=e,this.maxDownsamplingFactor=t,this.desiredFrameTimingMs=n,this.downsamplingPersistenceDurationInFrames=s,this.lastFrameTime=null,this.frameDeltas=[],this.downsamplingRates=new Map,this.frameCount=0,this.validateConstructorArguments();for(let r=1;r<=this.maxDownsamplingFactor;r*=2)this.downsamplingRates.set(r,-1/0)}validateConstructorArguments(){this.numberOfStoredFrameDeltas=Math.max(1,Math.round(this.numberOfStoredFrameDeltas)),this.maxDownsamplingFactor=Math.max(2,Math.round(this.maxDownsamplingFactor))}storeFrameDelta(e){this.frameDeltas.push(e),this.frameDeltas.length>this.numberOfStoredFrameDeltas&&this.frameDeltas.shift()}calculateMeanFrameTime(){return this.frameDeltas.reduce((e,t)=>e+t,0)/this.frameDeltas.length}calculateMedianFrameTime(){const e=this.frameDeltas.slice().sort((n,s)=>n-s),t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}calculateMaxFrameTime(){return Math.max(...this.frameDeltas)}updateMaxTrackedDownsamplingRate(e){this.downsamplingRates.set(e,this.frameCount);let t=1;for(const[n,s]of this.downsamplingRates)this.frameCount-s<=this.downsamplingPersistenceDurationInFrames&&(t=n);return t}resetForNewFrameSet(){this.lastFrameTime=null,this.frameCount=0,this.downsamplingRates.forEach((e,t)=>{this.downsamplingRates.set(t,-1/0)})}addFrame(e=Date.now()){if(this.lastFrameTime!==null){const t=e-this.lastFrameTime;t>0&&this.storeFrameDelta(t)}this.lastFrameTime=e,this.frameCount++}calculateFrameTimeInMs(e=2){if(this.frameDeltas.length===0)return 0;switch(e){case 0:return this.calculateMedianFrameTime();case 1:return this.calculateMeanFrameTime();case 2:return this.calculateMaxFrameTime()}}calculateDownsamplingRate(e=1){const t=this.calculateFrameTimeInMs(e);if(t===0)return Math.min(4,this.maxDownsamplingFactor);let n=Math.max(t/this.desiredFrameTimingMs,1);return n=Math.min(Math.pow(2,Math.round(Math.log2(n))),this.maxDownsamplingFactor),this.updateMaxTrackedDownsamplingRate(n)}getFrameDeltas(){return this.frameDeltas}getFrameCount(){return this.frameCount}getDownsamplingRates(){return this.downsamplingRates}setFrameDeltas(e,t=!0){this.frameDeltas=e.slice(-this.numberOfStoredFrameDeltas),t&&this.frameCount++}}var JC=G(310);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const jC=300;class tc{constructor(){this.width=0,this.height=0,this.logicalWidth=0,this.logicalHeight=0,this.visibleLeftFraction=0,this.visibleTopFraction=0,this.visibleWidthFraction=0,this.visibleHeightFraction=0}}function ip(i,e){const t=1/i.visibleWidthFraction,n=1/i.visibleHeightFraction,s=-1-(-1+2*i.visibleLeftFraction)*t;let r=-1-(-1+2*i.visibleTopFraction)*n;r=-r,e[0]=e[0]*t+e[3]*s,e[4]=e[4]*t+e[7]*s,e[8]=e[8]*t+e[11]*s,e[12]=e[12]*t+e[15]*s,e[1]=e[1]*n+e[3]*r,e[5]=e[5]*n+e[7]*r,e[9]=e[9]*n+e[11]*r,e[13]=e[13]*n+e[15]*r}function sp(i,e){return i.width===e.width&&i.height===e.height&&i.logicalWidth===e.logicalWidth&&i.logicalHeight===e.logicalHeight&&i.visibleLeftFraction===e.visibleLeftFraction&&i.visibleTopFraction===e.visibleTopFraction}class rp extends T.O8{constructor(e,t,n){super(),this.context=e,this.element=t,this.visibility=n,this.boundsGeneration=-1,this.canvasRelativeClippedLeft=0,this.canvasRelativeClippedTop=0,this.canvasRelativeLogicalLeft=0,this.canvasRelativeLogicalTop=0,this.renderViewport=new tc,this.monitorState={},this.gl=e.gl,e.addPanel(this)}scheduleRedraw(){this.visible&&this.context.scheduleRedraw()}ensureBoundsUpdated(){const{context:e}=this;e.ensureBoundsUpdated();const{boundsGeneration:t}=e;if(t===this.boundsGeneration)return;this.boundsGeneration=t;const{element:n}=this,s=n.getBoundingClientRect();e.ensureMonitorPanel(n,this.monitorState,s);const r=e.container,o=e.canvasRect,{canvas:a}=e,{width:l,height:c}=a,d=l/o.width,u=c/o.height,h=o.left,p=o.top,m=this.canvasRelativeLogicalLeft=Math.round((s.left-h)*d+n.clientLeft),g=this.canvasRelativeLogicalTop=Math.round((s.top-p)*u+n.clientTop),v=n.clientWidth,y=n.clientHeight,S=m+v,w=g+y;let b=g,x=m,E=S,D=w;for(let k=n.parentElement;k!==null&&k!==r;k=k.parentElement){const O=k.getBoundingClientRect();O.x===0&&O.y===0&&O.width===0&&O.height===0||(x=Math.max(x,(O.left-h)*d),b=Math.max(b,(O.top-p)*u),E=Math.min(E,(O.right-h)*d),D=Math.min(D,(O.bottom-p)*u))}b=this.canvasRelativeClippedTop=Math.round(Math.max(b,0)),x=this.canvasRelativeClippedLeft=Math.round(Math.max(x,0)),E=Math.round(Math.min(E,l)),D=Math.round(Math.min(D,c));const I=this.renderViewport,L=I.width=Math.max(0,E-x),N=I.height=Math.max(0,D-b);I.logicalWidth=v,I.logicalHeight=y,I.visibleLeftFraction=(x-m)/v,I.visibleTopFraction=(b-g)/y,I.visibleWidthFraction=L/v,I.visibleHeightFraction=N/y}setGLClippedViewport(){const{gl:e,canvasRelativeClippedTop:t,canvasRelativeClippedLeft:n,renderViewport:{width:s,height:r}}=this,o=t+r;e.enable(WebGL2RenderingContext.SCISSOR_TEST);const a=this.context.canvas.height-o;e.viewport(n,a,s,r),e.scissor(n,a,s,r)}setGLLogicalViewport(){const{gl:e,renderViewport:{width:t,height:n,logicalWidth:s,logicalHeight:r}}=this,o=this.context.canvas.height;e.enable(WebGL2RenderingContext.SCISSOR_TEST),e.viewport(this.canvasRelativeLogicalLeft,o-(this.canvasRelativeLogicalTop+r),s,r),e.scissor(this.canvasRelativeClippedLeft,o-(this.canvasRelativeClippedTop+n),t,n)}disposed(){this.context.unmonitorPanel(this.element,this.monitorState),this.context.removePanel(this),super.disposed()}get visible(){return this.visibility.visible}getDepthArray(){}get shouldDraw(){if(!this.visible)return!1;const{element:e}=this;return!(e.clientWidth===0||e.clientHeight===0||e.offsetWidth===0||e.offsetHeight===0)}get drawOrder(){return 0}}class nc extends rp{constructor(e,t,n){super(e,t,n),this.canvas=document.createElement("canvas"),this.canvasRenderingContext=this.canvas.getContext("2d");const{canvas:s}=this;t.appendChild(s),t.style.position="relative",s.style.position="absolute",s.style.left="0",s.style.right="0",s.style.top="0",s.style.bottom="0"}draw(){this.drawIndirect();const{renderViewport:e,canvas:t}=this,{logicalWidth:n,logicalHeight:s}=e;t.width=n,t.height=s;const{canvasRenderingContext:r}=this;r?.drawImage(this.context.canvas,this.canvasRelativeLogicalLeft,this.canvasRelativeLogicalTop,n,s,0,0,n,s)}}class YC extends _.DN{constructor(){super(Float64Array.of(0,0,1,1),e=>(0,f.Xu)(new Float64Array(4),e,f.xU))}toJSON(){const{value:e}=this,[t,n,s,r]=e;if(!(t===0&&n===0&&s===1&&r===1))return Array.from(e)}}class QC extends T.O8{constructor(e){super(),this.container=e,this.canvas=document.createElement("canvas"),this.updateStarted=new j.IY,this.updateFinished=new j.IY,this.continuousCameraMotionStarted=new j.IY,this.continuousCameraMotionFinished=new j.IY,this.changed=this.updateFinished,this.panels=new Set,this.resizeGeneration=0,this.boundsGeneration=-1,this.framerateMonitor=new WC,this.continuousCameraMotionInProgress=!1,this.orderedPanels=[],this.frameNumber=0,this.resizeCallback=()=>{++this.resizeGeneration,this.scheduleRedraw()},this.resizeObserver=new ResizeObserver(this.resizeCallback),this.debouncedEndContinuousCameraMotion=this.registerCancellable((0,Fe.A)(()=>{this.continuousCameraMotionInProgress=!1,this.continuousCameraMotionFinished.dispatch()},jC)),this.scheduleRedraw=this.registerCancellable((0,Qe.t)(()=>this.draw()));const{canvas:t,resizeObserver:n}=this;e.style.position="relative",t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.style.width="100%",t.style.height="100%",t.style.zIndex="0",n.observe(t),e.appendChild(t),this.registerEventListener(t,"webglcontextlost",s=>{console.log(`Lost WebGL context: ${s.statusMessage}`),s.preventDefault()}),this.registerEventListener(t,"webglcontextrestored",()=>{console.log("WebGL context restored"),window.location.reload()}),this.gl=(0,JC.y)(t)}ensureMonitorPanel(e,t,n){t.addedToResizeObserver||(this.resizeObserver.observe(e),t.addedToResizeObserver=!0);const s=this.rootRect,r=s.top-n.top,o=s.left-n.left,a=n.right-s.right,l=n.bottom-s.bottom,c=`${r}px ${a}px ${l}px ${o}px`;t.intersectionObserverMargin!==c&&(t.intersectionObserverMargin=c,t.intersectionObserver?.disconnect(),(t.intersectionObserver=new IntersectionObserver(this.resizeCallback,{root:this.container,rootMargin:c,threshold:[.93,.94,.95,.96,.97,.98,.99,1]})).observe(e))}unmonitorPanel(e,t){t.addedToResizeObserver&&this.resizeObserver.unobserve(e),t.intersectionObserver?.disconnect()}flagContinuousCameraMotion(){this.continuousCameraMotionInProgress||this.continuousCameraMotionStarted.dispatch(),this.continuousCameraMotionInProgress=!0,this.debouncedEndContinuousCameraMotion()}get isContinuousCameraMotionInProgress(){return this.continuousCameraMotionInProgress}applyWindowedViewportToElement(e,t){const[n,s,r,o]=t,a=1/r,l=1/o;e.style.position="absolute",e.style.top=`${-l*s*100}%`,e.style.left=`${-a*n*100}%`,e.style.width=`${a*100}%`,e.style.height=`${l*100}%`,++this.resizeGeneration,this.scheduleRedraw()}isReady(){for(const e of this.panels)if(e.visible&&!e.isReady())return!1;return!0}makeCanvasOverlayElement(){const e=document.createElement("div");return e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.width="100%",e.style.height="100%",e.style.zIndex="2",this.container.appendChild(e),e}disposed(){this.orderedPanels.length=0,this.resizeObserver.disconnect()}addPanel(e){this.panels.add(e),this.orderedPanels.length=0,++this.resizeGeneration,this.scheduleRedraw()}removePanel(e){this.panels.delete(e),this.orderedPanels.length=0,++this.resizeGeneration,this.scheduleRedraw()}ensureBoundsUpdated(){const{resizeGeneration:e}=this;if(this.boundsGeneration===e)return;const{canvas:t}=this;t.width=t.offsetWidth,t.height=t.offsetHeight,this.canvasRect=t.getBoundingClientRect(),this.rootRect=this.container.getBoundingClientRect(),this.boundsGeneration=e}draw(){++this.frameNumber,this.updateStarted.dispatch();const e=this.gl,t=this.framerateMonitor.getTimingExtension(e),n=this.framerateMonitor.startFrameTimeQuery(e,t);this.ensureBoundsUpdated(),this.gl.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT);const{orderedPanels:s,panels:r}=this;s.length!==r.size&&(s.push(...r),s.sort((o,a)=>o.drawOrder-a.drawOrder));for(const o of s){if(!o.shouldDraw)continue;o.ensureBoundsUpdated();const{renderViewport:a}=o;a.width===0||a.height===0||o.draw()}e.disable(e.SCISSOR_TEST),this.gl.clearColor(1,1,1,1),this.gl.colorMask(!1,!1,!1,!0),e.clear(e.COLOR_BUFFER_BIT),this.gl.colorMask(!0,!0,!0,!0),this.updateFinished.dispatch(),this.framerateMonitor.endFrameTimeQuery(e,t,n),this.framerateMonitor.grabAnyFinishedQueryResults(e)}getDepthArray(){const{width:e,height:t}=this.canvas,n=new Float32Array(e*t);for(const s of this.panels){if(!s.shouldDraw)continue;const r=s.getDepthArray();if(r===void 0)continue;const{canvasRelativeClippedTop:o,canvasRelativeClippedLeft:a,renderViewport:{width:l,height:c}}=s;for(let d=0;d(i[i.info=0]="info",i[i.warning=1]="warning",i[i.error=2]="error",i))(Tn||{});class kV{}class ai{constructor(){this.changed=new j.IY,this.messages=[],this.children=[]}addMessage(e){this.messages.push(e),this.changed.dispatch()}clearMessages(){const{messages:e}=this;e.length!==0&&(e.length=0,this.changed.dispatch())}isEmpty(){return this.messages.length===0&&!this.children.some(e=>!e.isEmpty())}addChild(e){return this.children.push(e),e.changed.add(this.changed.dispatch),e.isEmpty()||this.changed.dispatch(),()=>{const{children:t}=this;t.splice(t.indexOf(e),1),e.changed.remove(this.changed.dispatch),e.isEmpty()||this.changed.dispatch()}}*[Symbol.iterator](){yield*this.messages;for(const e of this.children)yield*e}}var Je=G(4509);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const mo=!(typeof Window<"u"&&self instanceof Window),lp=!1,cp=!1,ic="rpc.promise.response",dp="rpc.promise.cancel",up="rpc.ready",hp=new Map;function pt(i,e){hp.set(i,e)}class qC extends Error{constructor(e,t){super(t),this.name=e,this.message=t}}function pp(i,e){pt(i,function(t){const n=t.id,s=new Je.Qi,r=e.call(this,t,s);this.set(n,{promise:r,cancellationToken:s}),r.then(({value:o,transfers:a})=>{this.delete(n),this.invoke(ic,{id:n,value:o},a)},o=>{this.delete(n),this.invoke(ic,{id:n,error:o.message,errorName:o.name})})})}pt(dp,function(i){const e=i.id,t=this.get(e);if(t!==void 0){const{cancellationToken:n}=t;n.cancel()}}),pt(ic,function(i){const e=i.id,{resolve:t,reject:n}=this.get(e);this.delete(e),Object.prototype.hasOwnProperty.call(i,"value")?t(i.value):i.errorName===Je.wS.name?n(Je.wS):n(new qC(i.errorName,i.error))}),pt(up,function(i){this.onPeerReady()});const XC=mo?-1:0;class ZC{constructor(e,t){this.target=e,this.objects=new Map,this.nextId=XC,t&&(this.queue=[]),e.onmessage=n=>{const s=n.data;cp&&console.log("Received message",s),hp.get(s.functionName).call(this,s)}}sendReady(){this.invoke(up,{})}onPeerReady(){const{queue:e}=this;if(e!==void 0){this.queue=void 0;for(const{data:t,transfers:n}of e)this.target.postMessage(t,n)}}get numObjects(){return this.objects.size}set(e,t){this.objects.set(e,t)}delete(e){this.objects.delete(e)}get(e){return this.objects.get(e)}getRef(e){const t=e.id,n=this.get(t);return n.referencedGeneration=e.gen,n.addRef(),n}getOptionalRef(e){if(e===void 0)return;const t=e.id,n=this.get(t);return n.referencedGeneration=e.gen,n.addRef(),n}invoke(e,t,n){t.functionName=e,cp&&console.trace("Sending message",t);const{queue:s}=this;if(s!==void 0){s.push({data:t,transfers:n});return}this.target.postMessage(t,n)}promiseInvoke(e,t,n=Je.fx,s){return(0,Je.gI)(n,(r,o,a)=>{const l=t.id=this.newId();this.set(l,{resolve:r,reject:o}),this.invoke(e,t,s),a.add(()=>{this.invoke(dp,{id:l})})})}newId(){return mo?this.nextId--:this.nextId++}}class hn extends T.O8{constructor(){super(...arguments),this.rpc=null,this.rpcId=null}initializeSharedObject(e,t=e.newId()){this.rpc=e,this.rpcId=t,this.isOwner=!1,e.set(t,this)}initializeCounterpart(e,t={}){this.initializeSharedObject(e),this.unreferencedGeneration=0,this.referencedGeneration=0,this.isOwner=!0,t.id=this.rpcId,t.type=this.RPC_TYPE_ID,e.invoke("SharedObject.new",t)}dispose(){super.dispose()}addCounterpartRef(){return{id:this.rpcId,gen:++this.referencedGeneration}}refCountReachedZero(){this.isOwner===!0?this.referencedGeneration===this.unreferencedGeneration&&this.ownerDispose():this.isOwner===!1?this.rpc.invoke("SharedObject.refCountReachedZero",{id:this.rpcId,gen:this.referencedGeneration}):super.refCountReachedZero()}ownerDispose(){lp&&console.log(`[${mo}] #rpc object = ${this.rpc.numObjects}`);const{rpc:e,rpcId:t}=this;super.refCountReachedZero(),e.delete(t),e.invoke("SharedObject.dispose",{id:t})}counterpartRefCountReachedZero(e){this.unreferencedGeneration=e,this.refCount===0&&e===this.referencedGeneration&&this.ownerDispose()}}function ew(i,e,t={}){e!=null&&i.initializeSharedObject(e,t.id)}class vo extends hn{constructor(e,t={}){super(),ew(this,e,t)}}pt("SharedObject.dispose",function(i){const e=this.get(i.id);if(e.refCount!==0)throw new Error("Attempted to dispose object with non-zero reference count.");lp&&console.log(`[${mo}] #rpc objects: ${this.numObjects}`),e.disposed(),this.delete(e.rpcId),e.rpcId=null,e.rpc=null}),pt("SharedObject.refCountReachedZero",function(i){const e=this.get(i.id),t=i.gen;e.counterpartRefCountReachedZero(t)});const fp=new Map;function Zt(i){return e=>{e.prototype.RPC_TYPE_ID=i}}function yo(i){return e=>{if(i!==void 0)e.prototype.RPC_TYPE_ID=i;else if(i=e.prototype.RPC_TYPE_ID,i===void 0)throw new Error("RPC_TYPE_ID should have already been defined");fp.set(i,e)}}pt("SharedObject.new",function(i){const e=this,t=i.type,n=fp.get(t),s=new n(e,i);--s.refCount});var tw=Object.defineProperty,nw=Object.getOwnPropertyDescriptor,iw=(i,e,t,n)=>{for(var s=n>1?void 0:n?nw(e,t):e,r=i.length-1,o;r>=0;r--)(o=i[r])&&(s=(n?o(e,t,s):o(s))||s);return n&&s&&tw(e,t,s),s};/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const gp="SharedWatchableValue.changed";let ft=class extends vo{constructor(i,e={}){super(i,e),this.updatingValue_=!1,i!==void 0&&(this.base=new _.B0(e.value),this.setupChangedHandler())}initializeCounterpart(i,e={}){e.value=this.value,super.initializeCounterpart(i,e)}setupChangedHandler(){this.registerDisposer(this.base.changed.add(()=>{if(this.updatingValue_)this.updatingValue_=!1;else{const{rpc:i}=this;i!==null&&i.invoke(gp,{id:this.rpcId,value:this.value})}}))}static makeFromExisting(i,e){const t=new ft;return t.base=e,t.setupChangedHandler(),t.initializeCounterpart(i),t}static make(i,e){return ft.makeFromExisting(i,new _.B0(e))}get value(){return this.base.value}set value(i){this.base.value=i}get changed(){return this.base.changed}};ft=iw([yo("SharedWatchableValue")],ft),pt(gp,function(i){const e=this.get(i.id);e.updatingValue_=!0,e.base.value=i.value,e.updatingValue_=!1});/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class vt extends _.B0{constructor(e=Number.NEGATIVE_INFINITY){super(e)}get visible(){return this.value===Number.POSITIVE_INFINITY}get ignored(){return this.value===Number.NEGATIVE_INFINITY}}vt.VISIBLE=Number.POSITIVE_INFINITY,vt.IGNORED=Number.NEGATIVE_INFINITY;class or extends vt{constructor(){super(...arguments),this.contributors=new Map}add(e){const{contributors:t}=this,n=e.changed.add(()=>{this.update()}),s=()=>{t.delete(s),n(),this.update()};return t.set(s,e),this.update(),s}update(){let e=Number.NEGATIVE_INFINITY;for(const t of this.contributors.values())e=Math.max(e,t.value);this.value=e}}function ar(i){return class extends i{constructor(){super(...arguments),this.visibility=new or}initializeCounterpart(e,t={}){t.visibility=this.registerDisposer(ft.makeFromExisting(e,this.visibility)).rpcId,super.initializeCounterpart(e,t)}}}var sw=Object.defineProperty,rw=Object.getOwnPropertyDescriptor,ow=(i,e,t,n)=>{for(var s=n>1?void 0:n?rw(e,t):e,r=i.length-1,o;r>=0;r--)(o=i[r])&&(s=(n?o(e,t,s):o(s))||s);return n&&s&&sw(e,t,s),s};/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */var li=(i=>(i[i.DATA=0]="DATA",i[i.ANNOTATION=1]="ANNOTATION",i[i.DEFAULT_ANNOTATION=2]="DEFAULT_ANNOTATION",i))(li||{});function aw(){return new _._Y([0,1,2])}class mp extends T.O8{constructor(){super(...arguments),this.role=0,this.messages=new ai,this.layerChanged=new j.IY,this.redrawNeeded=new j.IY,this.layerChunkProgressInfo=new fo}handleAction(e){}getValueAt(e){}transformPickedValue(e){return e.pickedValue}updateMouseState(e,t,n,s){}}class vp extends mp{constructor(){super(...arguments),this.visibility=new or}attach(e){}}function lr(i,e,t){let{state:n}=t;if(n===void 0||n.transform!==i||n.displayDimensionRenderInfo!==e){if(t.messages.clearMessages(),n=t.state={transform:i,displayDimensionRenderInfo:e,modelTransform:void 0},i.error!==void 0){t.messages.addMessage({severity:Tn.error,message:i.error});return}try{const s=C.pB.create();BC(s,e,i),n.modelTransform=s}catch(s){t.messages.addMessage({severity:Tn.error,message:s.message})}}return n.modelTransform}class yp extends T.O8{constructor(e){super(),this.renderViewport=new tc,this.changed=new j.HN;const{parametersConstructor:t=op,navigationState:n,update:s,isEqual:r=KC}=e;this.oldValue_=new t,this.value_=new t;const o=()=>{const{oldValue_:l,value_:c}=this;l.displayDimensionRenderInfo=n.displayDimensionRenderInfo.value,Object.assign(l,this.renderViewport);let{globalPosition:d}=l;const u=n.position.value,h=u.length;d.length!==h&&(l.globalPosition=d=new Float32Array(h)),d.set(u),s(l,n),!r(l,c)&&(this.value_=l,this.oldValue_=c,this.changed.dispatch(c,l))},a=this.update=this.registerCancellable((0,Fe.A)(o,0));this.registerDisposer(n.changed.add(a)),o()}setViewport(e){sp(e,this.renderViewport)||(Object.assign(this.renderViewport,e),this.update())}get value(){return this.update.flush(),this.value_}}let So=class extends hn{constructor(i,e,t=10){super(),this.base=e,this.updateInterval=t,this.prevDisplayDimensionRenderInfo=void 0,this.update=this.registerCancellable((0,Fe.A)((n,s)=>{let r;if(s.displayDimensionRenderInfo!==this.prevDisplayDimensionRenderInfo)r=s,this.prevDisplayDimensionRenderInfo=s.displayDimensionRenderInfo;else{const{displayDimensionRenderInfo:o,...a}=s;r=a}this.rpc.invoke(go.kg,{id:this.rpcId,value:r})},this.updateInterval)),this.initializeCounterpart(i,{value:e.value}),this.registerDisposer(e.changed.add(this.update))}flush(){this.update.flush()}};So=ow([Zt(go.Bh)],So);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class nt{constructor(e,t=e){this.value_=e,this.defaultValue=t,this.changed=new j.IY}get value(){return this.value_}set value(e){e!==this.value_&&(this.value_=e,this.changed.dispatch())}toggle(){this.value=!this.value}toJSON(){const{value_:e}=this;if(e!==this.defaultValue)return this.value_}restoreState(e){if(e===!0||e===!1){this.value=e;return}this.value=this.defaultValue}reset(){this.value=this.defaultValue}}class pn extends T.O8{constructor(e,t={}){super(),this.model=e,this.element=document.createElement("input");const{element:n}=this;n.type="checkbox";const s=()=>{const r=this.model.value;this.element.checked=r,(t.enableTitle!==void 0||t.disableTitle!==void 0)&&(this.element.title=(r?t.enableTitle:t.disableTitle)??"")};this.registerDisposer(e.changed.add(s)),s(),this.registerEventListener(n,"change",function(r){e.value=this.checked}),n.addEventListener("mousedown",r=>{r.preventDefault()})}disposed(){const{element:e}=this,{parentElement:t}=e;t&&t.removeChild(e),super.disposed()}}class en extends T.O8{constructor(e,t){super(),this.model=e,this.element=t,this.initialDisplay=this.element.style.display,this.updateVisibility(),this.registerDisposer(e.changed.add(this.registerCancellable((0,Fe.A)(()=>this.updateVisibility(),0))))}updateVisibility(){this.element.style.display=this.model.value?this.initialDisplay:"none"}}/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function bo(i){try{return i()}catch(e){return{error:e.message}}}function sc(i){if(i.error!==void 0)throw new Error(i.error);return i}/** + * @license + * Copyright 2018 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class rc extends T.O8{constructor(e,t){if(super(),this.register=e,this.changed=new j.IY,this.disposerMap=new Map,t===void 0)this.map=new Map;else{const n=this.map=new Map(t),{disposerMap:s}=this;for(const[r,o]of n){const a=new T.O8;s.set(r,a),e(a,o,r)}}}get value(){return this.map}set(e,t){const{map:n,disposerMap:s}=this;let r=s.get(e);return r!==void 0&&r.dispose(),r=new T.O8,s.set(e,r),n.set(e,t),this.register(r,t,e),this.changed.dispatch(),this}delete(e){const{map:t,disposerMap:n}=this,s=n.get(e);return s!==void 0?(s.dispose(),n.delete(e),t.delete(e),this.changed.dispatch(),!0):!1}get(e){return this.map.get(e)}has(e){return this.map.has(e)}get size(){return this.map.size}[Symbol.iterator](){return this.map[Symbol.iterator]()}clear(){const{map:e,disposerMap:t}=this;if(e.size>0){for(const n of t.values())n.dispose();e.clear(),t.clear(),this.changed.dispatch()}}values(){return this.map.values()}keys(){return this.map.keys()}disposed(){const{map:e,disposerMap:t}=this;for(const n of t.values())n.dispose();e.clear(),t.clear(),super.disposed()}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const Sp=Symbol("objectId");let lw=0;function xt(i){if(i instanceof Object){let e=i[Sp];return e===void 0&&(e=i[Sp]=lw++),`o${e}`}return""+JSON.stringify(i)}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const oc=!1;var bp=(i=>(i[i.VERTEX=WebGL2RenderingContext.VERTEX_SHADER]="VERTEX",i[i.FRAGMENT=WebGL2RenderingContext.FRAGMENT_SHADER]="FRAGMENT",i))(bp||{});function cw(i){i=i.replace("\0","");const e=[];for(let t of i.split(` +`)){let n=t.match(/^ERROR:\s*(\d+):(\d+)\s*(.+)$/);n!==null?e.push({message:n[3].trim(),file:parseInt(n[1],10),line:parseInt(n[2],10)}):(n=t.match(/^ERROR:\s*(.+)$/),n!==null?e.push({message:n[1]}):(t=t.trim(),t&&e.push({message:t})))}return e}class dw extends Error{constructor(e,t,n,s){const r=`Error compiling ${bp[e].toLowerCase()} shader: ${n}`;super(r),this.name="ShaderCompilationError",this.log=n,this.message=r,this.shaderType=e,this.source=t,this.errorMessages=s}}class uw extends Error{constructor(e,t,n){const s=`Error linking shader: ${n}`;super(s),this.name="ShaderLinkError",this.log=n,this.message=s,this.vertexSource=e,this.fragmentSource=t}}function Cp(i,e,t){const n=i.createShader(t);if(i.shaderSource(n,e),i.compileShader(n),!i.getShaderParameter(n,i.COMPILE_STATUS)){const s=i.getShaderInfoLog(n)||"";if(oc){const r=e.replace("<","<").replace(">",">").split(` +`);let o="
";o+=s.replace("<","<").replace(">",">")+`
+`,r.forEach((l,c)=>{o+=`${c+1}: ${l}
+`}),o+=`
+
`,console.log(o);const a=window.open("about:blank","_blank");if(a!==null)try{a.document.write(o)}catch{}}throw new dw(t,e,s,cw(s))}return n}let ac;class hw extends T.O8{constructor(e,t,n,s,r,o){super(),this.gl=e,this.vertexSource=t,this.fragmentSource=n,this.attributes=new Map,this.uniforms=new Map,this.vertexShaderInputBinders={},this.transferFunctionTextures=new Map;const a=this.vertexShader=Cp(e,t,e.VERTEX_SHADER),l=this.fragmentShader=Cp(e,n,e.FRAGMENT_SHADER),c=e.createProgram();if(e.attachShader(c,a),e.attachShader(c,l),oc&&o?.length&&(e.transformFeedbackVaryings(c,o.map(h=>h.name),WebGL2RenderingContext.INTERLEAVED_ATTRIBS),this.vertexDebugOutputs=o),e.linkProgram(c),!e.getProgramParameter(c,e.LINK_STATUS)){const h=e.getProgramInfoLog(c)||"";throw new uw(t,n,h)}this.program=c;const{uniforms:d,attributes:u}=this;if(s)for(const h of s)d.set(h,e.getUniformLocation(c,h));if(r)for(const h of r)u.set(h,e.getAttribLocation(c,h))}uniform(e){return this.uniforms.get(e)}attribute(e){return this.attributes.get(e)}textureUnit(e){return this.textureUnits.get(e)}bind(){ac=this,this.gl.useProgram(this.program)}bindAndUpdateTransferFunctionTexture(e,t,n,s){const r=this.textureUnits.get(e);if(r===void 0)throw new Error(`Invalid texture unit symbol: ${e.toString()}`);const o=this.transferFunctionTextures.get(e);if(o===void 0)throw new Error(`Invalid transfer function texture symbol: ${e.toString()}`);return o.updateAndActivate({textureUnit:r,sortedControlPoints:t,dataType:n,lookupTableSize:s})}unbindTransferFunctionTextures(){const e=this.gl;for(const t of this.transferFunctionTextures.keys()){const n=this.textureUnits.get(t);n!==void 0&&(this.gl.activeTexture(e.TEXTURE0+n),this.gl.bindTexture(e.TEXTURE_2D,null))}}disposed(){const{gl:e}=this;e.deleteShader(this.vertexShader),this.vertexShader=void 0,e.deleteShader(this.fragmentShader),this.fragmentShader=void 0,e.deleteProgram(this.program),this.program=void 0,this.gl=void 0,this.attributes=void 0,this.uniforms=void 0,this.transferFunctionTextures=void 0}}function pw(i,e,t,n,s){if(i.drawArraysInstanced(e,t,n,s),!oc||!ac?.vertexDebugOutputs)return;const{vertexDebugOutputs:r}=ac;let o=0;for(const h of r)o+=fw[h.typeName];const a=i.createBuffer(),l=o*n*s;i.bindBuffer(WebGL2RenderingContext.ARRAY_BUFFER,a),i.bufferData(WebGL2RenderingContext.ARRAY_BUFFER,l,WebGL2RenderingContext.DYNAMIC_DRAW),i.bindBuffer(WebGL2RenderingContext.ARRAY_BUFFER,null),i.bindBufferBase(WebGL2RenderingContext.TRANSFORM_FEEDBACK_BUFFER,0,a),i.beginTransformFeedback(WebGL2RenderingContext.POINTS),i.enable(WebGL2RenderingContext.RASTERIZER_DISCARD),i.drawArraysInstanced(WebGL2RenderingContext.POINTS,t,n,s),i.disable(WebGL2RenderingContext.RASTERIZER_DISCARD),i.endTransformFeedback(),i.bindBufferBase(WebGL2RenderingContext.TRANSFORM_FEEDBACK_BUFFER,0,null),i.bindBuffer(WebGL2RenderingContext.ARRAY_BUFFER,a);const c=new Uint8Array(l);i.getBufferSubData(WebGL2RenderingContext.ARRAY_BUFFER,0,c,0,l),i.bindBuffer(WebGL2RenderingContext.ARRAY_BUFFER,null),i.deleteBuffer(a);let d=0;const u=new Float32Array(c.buffer);for(let h=0;h{if(s){const a=new Int32Array(s);for(let l=0;l0){n.bind();for(const r of s)r(n)}return n}}function PV(i,e){const t=new Set;for(const n of e){const s=new RegExp(`(?:^|[^a-zA-Z0-9_])${n}[^a-zA-Z0-9_])`);i.match(s)!==null&&t.add(n)}return t}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function dr(){return new _.B0(void 0)}function Co(i){return new _.DN(i,f.zr)}function wo(i,e,t){const n=new Map,{parameters:s,fallbackParameters:r,shaderError:o,encodeParameters:a=v=>v,extraParameters:l=(0,_.XZ)(void 0),encodeExtraParameters:c=v=>v,getContextKey:d,defineShader:u}=t;o!==void 0&&(o.value=void 0);const{encodeContext:h=d}=t,p=(0,f.JB)(t.memoizeKey);function m(v,y,S){const w=JSON.stringify({id:p,context:h(v),parameters:a(y),extraParameters:c(S)});return e.memoize.get(w,()=>{const b=new fn(e);return u(b,v,y,S),b.build()})}function g(v){const y=d(v);let S=n.get(y);S===void 0&&(S={parametersGeneration:-1,extraParametersGeneration:-1,shader:null,fallback:!1,parameters:s.value,extraParameters:l.value},n.set(y,S));const w=s.changed.count,b=l.changed.count;if(w===S.parametersGeneration&&b===S.extraParametersGeneration)return S;const x=S.parameters=s.value,E=S.extraParameters=l.value,D=S.shader;S.parametersGeneration=w,S.extraParametersGeneration=b;let I=null;try{I=m(v,x,E),S.fallback=!1,r!==void 0&&(r.value=x),o!==void 0&&(o.value=null)}catch(L){if(o!==void 0&&(o.value=L),r!==void 0)try{const N=r.value;I=m(v,N,E),S.parameters=N,S.fallback=!0}catch{}}return D!==null&&D.dispose(),S.shader=I,S}return i.registerDisposer(()=>{for(const v of n.values()){const{shader:y}=v;y!==null&&y.dispose()}}),g}function Ai(i,e,t){return wo(i,e,{...t,getContextKey:n=>n,encodeContext:n=>xt(n),defineShader:(n,s,r,o)=>(n.require(s),t.defineShader(n,r,o))})}function ms(i,e=1,t=0){return` +#line ${t} ${e} +`+i}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class At{constructor(e,t=WebGL2RenderingContext.ARRAY_BUFFER){this.gl=e,this.bufferType=t,this.gl=e,this.buffer=e.createBuffer()}bind(){this.gl.bindBuffer(this.bufferType,this.buffer)}bindToVertexAttrib(e,t,n=WebGL2RenderingContext.FLOAT,s=!1,r=0,o=0){this.bind(),this.gl.enableVertexAttribArray(e),this.gl.vertexAttribPointer(e,t,n,s,r,o)}bindToVertexAttribI(e,t,n=WebGL2RenderingContext.UNSIGNED_INT,s=0,r=0){this.bind(),this.gl.enableVertexAttribArray(e),this.gl.vertexAttribIPointer(e,t,n,s,r)}setData(e,t=WebGL2RenderingContext.STATIC_DRAW){const n=this.gl;this.bind(),n.bufferData(this.bufferType,e,t)}dispose(){this.gl.deleteBuffer(this.buffer),this.buffer=void 0,this.gl=void 0}static fromData(e,t,n,s){const r=new At(e,n);return r.setData(t,s),r}}function ci(i,e,t,...n){return i.memoize.get((0,f.JB)({id:"getMemoizedBuffer",getter:xt(t),args:n}),()=>{const s=new T.fL(At.fromData(i,t(...n),e,WebGL2RenderingContext.STATIC_DRAW));return s.registerDisposer(s.value),s})}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function gw(i=-1,e=-1,t=1,n=1,s=1,r=1){return(0,F.CS)(new Float32Array([i,e,i,n,t,n,t,e]),2,s,r)}function AV(i=-1,e=-1,t=-1,n=1,s=1,r=1,o=1,a=1){return tile2dArray(new Float32Array([i,e,t,n,e,t,i,s,t,n,s,t,i,e,r,n,e,r,i,s,r,n,s,r]),3,o,a)}function ur(i,e=-1,t=-1,n=1,s=1,r=1,o=1){return ci(i,WebGL2RenderingContext.ARRAY_BUFFER,gw,e,t,n,s,r,o).value}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function di(i){i.texParameteri(WebGL2RenderingContext.TEXTURE_2D,WebGL2RenderingContext.TEXTURE_MIN_FILTER,WebGL2RenderingContext.NEAREST),i.texParameteri(WebGL2RenderingContext.TEXTURE_2D,WebGL2RenderingContext.TEXTURE_MAG_FILTER,WebGL2RenderingContext.NEAREST),i.texParameteri(WebGL2RenderingContext.TEXTURE_2D,WebGL2RenderingContext.TEXTURE_WRAP_S,WebGL2RenderingContext.CLAMP_TO_EDGE),i.texParameteri(WebGL2RenderingContext.TEXTURE_2D,WebGL2RenderingContext.TEXTURE_WRAP_T,WebGL2RenderingContext.CLAMP_TO_EDGE)}function mw(i){i.texParameteri(WebGL2RenderingContext.TEXTURE_3D,WebGL2RenderingContext.TEXTURE_MIN_FILTER,WebGL2RenderingContext.NEAREST),i.texParameteri(WebGL2RenderingContext.TEXTURE_3D,WebGL2RenderingContext.TEXTURE_MAG_FILTER,WebGL2RenderingContext.NEAREST),i.texParameteri(WebGL2RenderingContext.TEXTURE_3D,WebGL2RenderingContext.TEXTURE_WRAP_S,WebGL2RenderingContext.CLAMP_TO_EDGE),i.texParameteri(WebGL2RenderingContext.TEXTURE_3D,WebGL2RenderingContext.TEXTURE_WRAP_T,WebGL2RenderingContext.CLAMP_TO_EDGE),i.texParameteri(WebGL2RenderingContext.TEXTURE_3D,WebGL2RenderingContext.TEXTURE_WRAP_R,WebGL2RenderingContext.CLAMP_TO_EDGE)}function vw(i,e,t,n,s=WebGL2RenderingContext.RGBA8,r=WebGL2RenderingContext.RGBA,o=WebGL2RenderingContext.UNSIGNED_BYTE){i.activeTexture(WebGL2RenderingContext.TEXTURE0+i.tempTextureUnit),i.bindTexture(WebGL2RenderingContext.TEXTURE_2D,e),di(i),i.texImage2D(WebGL2RenderingContext.TEXTURE_2D,0,s,t,n,0,r,o,null),i.bindTexture(WebGL2RenderingContext.TEXTURE_2D,null)}function yw(i,e,t){i.activeTexture(WebGL2RenderingContext.TEXTURE0+i.tempTextureUnit),i.bindTexture(WebGL2RenderingContext.TEXTURE_2D,e),i.texParameteri(WebGL2RenderingContext.TEXTURE_2D,WebGL2RenderingContext.TEXTURE_MIN_FILTER,WebGL2RenderingContext.LINEAR),i.texParameteri(WebGL2RenderingContext.TEXTURE_2D,WebGL2RenderingContext.TEXTURE_MAG_FILTER,WebGL2RenderingContext.LINEAR),i.texParameteri(WebGL2RenderingContext.TEXTURE_2D,WebGL2RenderingContext.TEXTURE_WRAP_S,WebGL2RenderingContext.CLAMP_TO_EDGE),i.texParameteri(WebGL2RenderingContext.TEXTURE_2D,WebGL2RenderingContext.TEXTURE_WRAP_T,WebGL2RenderingContext.CLAMP_TO_EDGE),i.pixelStorei(WebGL2RenderingContext.UNPACK_FLIP_Y_WEBGL,1),i.pixelStorei(WebGL2RenderingContext.UNPACK_ALIGNMENT,4),i.texImage2D(WebGL2RenderingContext.TEXTURE_2D,0,WebGL2RenderingContext.RGBA8,WebGL2RenderingContext.RGBA,WebGL2RenderingContext.UNSIGNED_BYTE,t),i.pixelStorei(WebGL2RenderingContext.UNPACK_FLIP_Y_WEBGL,0),i.bindTexture(WebGL2RenderingContext.TEXTURE_2D,null)}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function lc(i){i.addOutputBuffer("vec4","v4f_fragColor",null),i.setFragmentMain("v4f_fragColor = getValue0();")}function xp(i,e=lc,t=1){return i.memoize.get(`elementWiseTextureShader:${t}:${xt(e)}`,()=>{const n=new fn(i);n.addVarying("vec2","vTexCoord"),n.addUniform("sampler2D","uSampler",t),n.addInitializer(s=>{const r=[];for(let o=0;o{const e=new fn(i);return e.addVarying("vec4","vColor"),e.addOutputBuffer("vec4","v4f_fragColor",null),e.setFragmentMain("v4f_fragColor = vColor;"),e.addAttribute("vec4","aVertexPosition"),e.addAttribute("vec4","aColor"),e.addUniform("mat4","uProjectionMatrix"),e.setVertexMain("vColor = aColor; gl_Position = uProjectionMatrix * aVertexPosition;"),e.build()})}function NV(i){return i.memoize.get("trivialUniformColorShader",()=>{const e=new ShaderBuilder(i);return e.addUniform("mat4","uProjectionMatrix"),e.addAttribute("vec4","aVertexPosition"),e.addUniform("vec4","uColor"),e.addOutputBuffer("vec4","v4f_fragColor",null),e.setFragmentMain("v4f_fragColor = uColor;"),e.setVertexMain("gl_Position = uProjectionMatrix * aVertexPosition;"),e.build()})}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class Ep extends T.O8{constructor(){super(...arguments),this.width=Number.NaN,this.height=Number.NaN}hasSize(e,t){return this.width===e&&this.height===t}resize(e,t){this.hasSize(e,t)||(this.width=e,this.height=t,this.performResize())}}class bw extends Ep{constructor(e,t){super(),this.gl=e,this.internalformat=t,this.renderbuffer=null,this.renderbuffer=e.createRenderbuffer()}performResize(){const{gl:e}=this;e.bindRenderbuffer(e.RENDERBUFFER,this.renderbuffer),e.renderbufferStorage(e.RENDERBUFFER,this.internalformat,this.width,this.height),e.bindRenderbuffer(e.RENDERBUFFER,null)}disposed(){this.gl.deleteRenderbuffer(this.renderbuffer)}attachToFramebuffer(e){const{gl:t}=this;t.framebufferRenderbuffer(t.FRAMEBUFFER,e,t.RENDERBUFFER,this.renderbuffer)}}class Cw extends bw{constructor(e,t=!1){super(e,t?e.DEPTH_STENCIL:e.DEPTH_COMPONENT16),this.gl=e,this.includeStencilBuffer=t}attachToFramebuffer(){const{gl:e}=this;super.attachToFramebuffer(this.includeStencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT)}}class xo extends Cw{constructor(e){super(e,!0)}}const OV=null;class ww extends T.O8{constructor(e){super(),this.gl=e,this.framebuffer=this.gl.createFramebuffer()}disposed(){const{gl:e}=this;e.deleteFramebuffer(this.framebuffer)}bind(){const{gl:e}=this;e.bindFramebuffer(e.FRAMEBUFFER,this.framebuffer)}unbind(){const{gl:e}=this;e.bindFramebuffer(e.FRAMEBUFFER,null)}}class gn extends Ep{constructor(e,t,n,s){super(),this.gl=e,this.internalFormat=t,this.format=n,this.dataType=s,this.texture=e.createTexture()}performResize(){vw(this.gl,this.texture,this.width,this.height,this.internalFormat,this.format,this.dataType)}disposed(){this.gl.deleteTexture(this.texture)}attachToFramebuffer(e){const{gl:t}=this;t.framebufferTexture2D(t.FRAMEBUFFER,e,t.TEXTURE_2D,this.texture,0)}}class xw extends gn{constructor(e,t=WebGL2RenderingContext.DEPTH_COMPONENT16,n=WebGL2RenderingContext.DEPTH_COMPONENT,s=WebGL2RenderingContext.UNSIGNED_SHORT){super(e,t,n,s)}attachToFramebuffer(){super.attachToFramebuffer(this.format===WebGL2RenderingContext.DEPTH_COMPONENT?WebGL2RenderingContext.DEPTH_ATTACHMENT:WebGL2RenderingContext.DEPTH_STENCIL_ATTACHMENT)}}function vs(i,e,t=WebGL2RenderingContext.RGBA8,n=WebGL2RenderingContext.RGBA,s=WebGL2RenderingContext.UNSIGNED_BYTE){const r=new Array;for(let o=0;o{this.registerDisposer(a),o[l]=e.COLOR_ATTACHMENT0+l})}hasSize(e,t){return this.width===e&&this.height===t}bind(e,t){this.width=e,this.height=t,this.framebuffer.bind();const{gl:n,depthBuffer:s}=this;s!==void 0?(s.resize(e,t),s.attachToFramebuffer()):n.framebufferRenderbuffer(WebGL2RenderingContext.FRAMEBUFFER,WebGL2RenderingContext.DEPTH_STENCIL_ATTACHMENT,WebGL2RenderingContext.RENDERBUFFER,null),this.colorBuffers.forEach((r,o)=>{r.resize(e,t),r.attachToFramebuffer(n.COLOR_ATTACHMENT0+o)}),n.drawBuffers(this.fullAttachmentList),this.verifyAttachment(),n.viewport(0,0,e,t)}bindSingle(e){const{gl:t}=this;this.framebuffer.bind(),e!==0&&t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0),t.bindTexture(t.TEXTURE_2D,null),this.colorBuffers[e].attachToFramebuffer(t.COLOR_ATTACHMENT0),t.drawBuffers(this.singleAttachmentList)}unbind(){this.framebuffer.unbind()}readPixelFloat32IntoBuffer(e,t,n,s,r=1,o=1){const{gl:a}=this;try{this.bindSingle(e),a.readPixels(t,n,r,o,WebGL2RenderingContext.RGBA,WebGL2RenderingContext.FLOAT,s)}finally{this.framebuffer.unbind()}}verifyAttachment(){if(this.attachmentVerified)return;const{gl:e}=this,t=e.checkFramebufferStatus(e.FRAMEBUFFER);if(t!==e.FRAMEBUFFER_COMPLETE)throw new Error(`Framebuffer configuration not supported: ${t}`);this.attachmentVerified=!0}}class Dn extends T.O8{constructor(e,t){super(),this.gl=e,this.shader=t,this.copyVertexPositionsBuffer=ur(this.gl),this.copyTexCoordsBuffer=ur(this.gl,0,0,1,1),this.registerDisposer(t)}draw(...e){const{gl:t,shader:n}=this;n.bind();const s=e.length;for(let a=0;anew Dn(e,xp(e,t,n)))}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const Ew=` +float mixLinear(float x, float y, float a) { return mix(x, y, a); } +`,Tw=` +vec3 hueToRgb(float hue) { + float hue6 = hue * 6.0; + float r = abs(hue6 - 3.0) - 1.0; + float g = 2.0 - abs(hue6 - 2.0); + float b = 2.0 - abs(hue6 - 4.0); + return clamp(vec3(r, g, b), 0.0, 1.0); +} +vec3 hsvToRgb(vec3 c) { + vec3 hueRgb = hueToRgb(c.x); + return c.z * ((hueRgb - 1.0) * c.y + 1.0); +} +`,gt=` +struct uint64_t { + highp uvec2 value; +}; +struct uint64x2_t { + highp uvec4 value; +}; +uint64_t mixLinear(uint64_t x, uint64_t y, float a) { + return x; +} +uint64_t toUint64(uint64_t x) { return x; } +`,Dw=[gt,` +uint64_t unpackUint64leFromUint32(highp uvec2 x) { + uint64_t result; + result.value = x; + return result; +} +uint64x2_t unpackUint64leFromUint32(highp uvec4 x) { + uint64x2_t result; + result.value = x; + return result; +} +`],Tp=[gt,` +bool equals(uint64_t a, uint64_t b) { + return a.value == b.value; +} +`],Eo=[gt,` +bool compareLessThan(uint64_t a, uint64_t b) { + return (a.value[1] < b.value[1])|| + (a.value[1] == b.value[1] && a.value[0] < b.value[0]); +} +`],Dp=[gt,` +uint64_t subtract(uint64_t a, uint64_t b) { + if (a.value[0] < b.value[0]) { + --a.value[1]; + } + a.value -= b.value; + return a; +} +`],Iw=[[gt,` +uint64_t add(uint64_t a, uint64_t b) { + a.value[0] += b.value[0]; + if (a.value[0] < b.value[0]) { + ++a.value[1]; + } + a.value[1] += b.value[1]; + return a; +} +`],Eo,` +uint64_t addSaturate(uint64_t a, uint64_t b) { + a = add(a, b); + if (compareLessThan(a, b)) { + a.value = uvec2(0xffffffffu, 0xffffffffu); + } + return a; +} +`],Lw=[Dp,Eo,` +uint64_t subtractSaturate(uint64_t a, uint64_t b) { + b = subtract(a, b); + if (compareLessThan(a, b)) { + b.value = uvec2(0u, 0u); + } + return b; +} +`],Ip=[gt,` +uint64_t shiftRight(uint64_t a, int shift) { + if (shift >= 32) { + return uint64_t(uvec2(a.value[1] >> (shift - 32), 0u)); + } else if (shift == 0) { + return a; + } else { + return uint64_t(uvec2((a.value[0] >> shift) | (a.value[1] << (32 - shift)), a.value[1] >> shift)); + } +} +`],Rw=[gt,` +uint64_t shiftLeft(uint64_t a, int shift) { + if (shift >= 32) { + return uint64_t(uvec2(0u, a.value[0] << (shift - 32))); + } else if (shift == 0) { + return a; + } else { + return uint64_t(uvec2(a.value[0] << shift, (a.value[1] << shift) | (a.value[0] >> (32 - shift)))); + } +} +`],Lp=[gt,` +struct uint8_t { + highp uint value; +}; +struct uint8x2_t { + highp uvec2 value; +}; +struct uint8x3_t { + highp uvec3 value; +}; +struct uint8x4_t { + highp uvec4 value; +}; +uint8_t mixLinear(uint8_t x, uint8_t y, highp float a) { + return uint8_t(uint(round(mix(float(x.value), float(y.value), a)))); +} +highp uint toRaw(uint8_t x) { return x.value; } +highp float toNormalized(uint8_t x) { return float(x.value) / 255.0; } +highp uvec2 toRaw(uint8x2_t x) { return x.value; } +highp vec2 toNormalized(uint8x2_t x) { return vec2(x.value) / 255.0; } +highp uvec3 toRaw(uint8x3_t x) { return x.value; } +vec3 toNormalized(uint8x3_t x) { return vec3(x.value) / 255.0; } +highp uvec4 toRaw(uint8x4_t x) { return x.value; } +vec4 toNormalized(uint8x4_t x) { return vec4(x.value) / 255.0; } +uint64_t toUint64(uint8_t x) { + uint64_t result; + result.value[0] = x.value; + result.value[1] = 0u; + return result; +} +uint8_t uint8FromFloat(highp float x) { + return uint8_t(uint(clamp(x, 0.0, 255.0))); +} +`],Rp=[gt,` +struct int8_t { + highp int value; +}; +struct int8x2_t { + highp ivec2 value; +}; +struct int8x3_t { + highp ivec3 value; +}; +struct int8x4_t { + highp ivec4 value; +}; +int8_t mixLinear(int8_t x, int8_t y, highp float a) { + return int8_t(int(round(mix(float(x.value), float(y.value), a)))); +} +highp int toRaw(int8_t x) { return x.value; } +highp ivec2 toRaw(int8x2_t x) { return x.value; } +highp ivec3 toRaw(int8x3_t x) { return x.value; } +highp ivec4 toRaw(int8x4_t x) { return x.value; } +uint64_t toUint64(int8_t x) { + uint64_t result; + result.value[0] = uint(x.value); + result.value[1] = uint(x.value >> 31); + return result; +} +int8_t int8FromFloat(highp float x) { + return int8_t(int(clamp(x, -128.0, 127.0))); +} +`],cc=` +highp float toRaw(highp float x) { return x; } +highp float toNormalized(highp float x) { return x; } +vec2 toRaw(vec2 x) { return x; } +vec2 toNormalized(vec2 x) { return x; } +vec3 toRaw(vec3 x) { return x; } +vec3 toNormalized(vec3 x) { return x; } +vec4 toRaw(vec4 x) { return x; } +vec4 toNormalized(vec4 x) { return x; } +`,kp=[gt,` +struct uint16_t { + highp uint value; +}; +struct uint16x2_t { + highp uvec2 value; +}; +uint16_t mixLinear(uint16_t x, uint16_t y, highp float a) { + return uint16_t(uint(round(mix(float(x.value), float(y.value), a)))); +} +highp uint toRaw(uint16_t x) { return x.value; } +highp float toNormalized(uint16_t x) { return float(toRaw(x)) / 65535.0; } +highp uvec2 toRaw(uint16x2_t x) { return x.value; } +highp vec2 toNormalized(uint16x2_t x) { return vec2(toRaw(x)) / 65535.0; } +uint64_t toUint64(uint16_t x) { + uint64_t result; + result.value[0] = x.value; + result.value[1] = 0u; + return result; +} +uint16_t uint16FromFloat(highp float x) { + return uint16_t(uint(clamp(x, 0.0, 65535.0))); +} +`],Pp=[gt,` +struct int16_t { + highp int value; +}; +struct int16x2_t { + highp ivec2 value; +}; +int16_t mixLinear(int16_t x, int16_t y, highp float a) { + return int16_t(int(round(mix(float(x.value), float(y.value), a)))); +} +highp int toRaw(int16_t x) { return x.value; } +highp ivec2 toRaw(int16x2_t x) { return x.value; } +uint64_t toUint64(int16_t x) { + uint64_t result; + result.value[0] = uint(x.value); + result.value[1] = uint(x.value >> 31); + return result; +} +int16_t int16FromFloat(highp float x) { + return int16_t(int(clamp(x, -32768.0, 32767.0))); +} +`],To=[gt,` +struct uint32_t { + highp uint value; +}; +uint32_t mixLinear(uint32_t x, uint32_t y, highp float a) { + return uint32_t(uint(round(mix(float(x.value), float(y.value), a)))); +} +highp float toNormalized(uint32_t x) { return float(x.value) / 4294967295.0; } +highp uint toRaw(uint32_t x) { return x.value; } +uint64_t toUint64(uint32_t x) { + uint64_t result; + result.value[0] = x.value; + result.value[1] = 0u; + return result; +} +uint32_t uint32FromFloat(highp float x) { + return uint32_t(uint(clamp(x, 0.0, 4294967295.0))); +} +`],Ap=[gt,` +struct int32_t { + highp int value; +}; +int32_t mixLinear(int32_t x, int32_t y, highp float a) { + return int32_t(int(round(mix(float(x.value), float(y.value), a)))); +} +highp int toRaw(int32_t x) { return x.value; } +uint64_t toUint64(int32_t x) { + uint64_t result; + result.value[0] = uint(x.value); + result.value[1] = uint(x.value >> 31); + return result; +} +int32_t int32FromFloat(highp float x) { + return int32_t(int(clamp(x, 2147483648.0, 2147483647.0))); +} +`],kw=` +highp int getFortranOrderIndex(ivec3 subscripts, ivec3 size) { + return subscripts.x + size.x * (subscripts.y + size.y * subscripts.z); +} +`,Pw=` +highp uint log2Exact(highp uint i) { + highp uint r; + r = uint((i & 0xAAAAAAAAu) != 0u); + r |= uint((i & 0xFFFF0000u) != 0u) << 4; + r |= uint((i & 0xFF00FF00u) != 0u) << 3; + r |= uint((i & 0xF0F0F0F0u) != 0u) << 2; + r |= uint((i & 0xCCCCCCCCu) != 0u) << 1; + return r; +} +`,Aw=` +bool clipLineToDepthRange(inout highp vec4 a, inout highp vec4 b) { + highp float tmin = 0.0, tmax = 1.0; + highp float k1 = b.w - a.w + a.z - b.z; + highp float k2 = a.w - b.w + a.z - b.z; + highp float q1 = (a.z - a.w) / k1; + highp float q2 = (a.z + a.w) / k2; + if (k1 > 0.0) tmin = max(tmin, q1); + else if (k1 < 0.0) tmax = min(tmax, q1); + if (k2 > 0.0) tmax = min(tmax, q2); + else if (k2 < 0.0) tmin = max(tmin, q2); + if (tmin <= tmax) { + highp vec4 tempA = a; + highp vec4 tempB = b; + a = mix(tempA, tempB, tmin); + b = mix(tempA, tempB, tmax); + return true; + } + return false; +} +`,Mp=` +highp float simpleFloatHash(highp vec2 co) { + return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); +} +`,Mw=` +highp uint shiftLeftSaturate(highp uint x, int shiftAmount) { + highp uint result = x << shiftAmount; + if ((result >> shiftAmount) != x) return 0xffffffffu; + return result; +} +`,dc=` +highp uint addSaturate(highp uint x, highp uint y) { + highp uint result = x + y; + if (result < x) return 0xffffffffu; + return result; +} +`,Nw=` +highp uint subtractSaturate(highp uint x, highp uint y) { + highp uint result = x - y; + if (result > x) return 0u; + return result; +} +`,Ow=[dc,` +highp int addSaturate(highp int x, highp uint y) { + if (x >= 0) { + return int(min(addSaturate(y, uint(x)), 0x7fffffffu)); + } else if (y >= uint(-x)) { + return int(min(y - uint(-x), 0x7fffffffu)); + } else { + return -int(min(uint(-x) - y, 0x80000000u)); + } +} +`],_w=[dc,` +highp int subtractSaturate(highp int x, highp uint y) { + if (x < 0) { + return -int(min(addSaturate(uint(-x), uint(y)), 0x80000000u)); + } else if (uint(x) >= y) { + return x - int(y); + } else { + return -int(min(y - uint(x), 0x80000000u)); + } +} +`];function yt(i,e=1){switch(i){case R.FLOAT32:if(e===1)return"float";if(e>1&&e<=4)return`vec${e}`;break;case R.UINT8:case R.INT8:case R.UINT16:case R.INT16:case R.UINT32:case R.INT32:case R.UINT64:{const t=ae[i]?"":"u",n=B[i]*8;if(e===1)return`${t}int${n}_t`;if(e>1&&e*n<=32)return`${t}int${n}x${e}_t`;break}}throw new Error(`No shader type for ${R[i]}[${e}].`)}const ys={[R.UINT8]:Lp,[R.INT8]:Rp,[R.UINT16]:kp,[R.INT16]:Pp,[R.UINT32]:To,[R.INT32]:Ap,[R.UINT64]:gt,[R.FLOAT32]:cc};function Vw(i,e){return e===1?i:i==="float"?`vec${e}`:`${i[0]}vec${e}`}const Bw={[WebGL2RenderingContext.UNSIGNED_BYTE]:1,[WebGL2RenderingContext.BYTE]:1,[WebGL2RenderingContext.UNSIGNED_SHORT]:2,[WebGL2RenderingContext.SHORT]:2,[WebGL2RenderingContext.FLOAT]:4,[WebGL2RenderingContext.INT]:4,[WebGL2RenderingContext.UNSIGNED_INT]:4};function Do(i,e,t,n,s,r,o=1){let a=0,l=r*o;for(;l>0;){const u=Math.min(4,l),h=Vw(e,u);l-=u,i.addAttribute("highp "+h,`a${s}${a}`),++a}l=r*o;let c="";for(let u=0;u{const h=[];for(let p=0;p{const t=new fn(this.gl);return t.addOutputBuffer("vec4","outputValue",0),t.addAttribute("float","aInput1"),t.addTextureSampler("sampler2D","uDataSampler",Op),t.addTextureSampler("sampler2D","uDepthSampler",_p),t.addVertexCode(Mp),t.setVertexMain(` +float uRandomSeed = 0.0; +vec2 p = vec2(simpleFloatHash(vec2(aInput1 + float(gl_VertexID), uRandomSeed + float(gl_InstanceID))), + simpleFloatHash(vec2(aInput1 + float(gl_VertexID) + 10.0, 5.0 + uRandomSeed + float(gl_InstanceID)))); +float dataValue = texture(uDataSampler, p).x; +float stencilValue = texture(uDepthSampler, p).x; +if (stencilValue == 1.0) { + gl_Position = vec4(2.0, 2.0, 2.0, 1.0); +} else { + gl_Position = vec4(2.0 * (dataValue * 255.0 + 0.5) / 256.0 - 1.0, 0.0, 0.0, 1.0); +} +gl_PointSize = 1.0; +`),t.setFragmentMain(` +outputValue = vec4(1.0, 1.0, 1.0, 1.0); +`),t.build()})()),this.inputIndexBuffer=this.registerDisposer(ci(this.gl,WebGL2RenderingContext.ARRAY_BUFFER,()=>new Uint8Array(uc)))}static get(e){return e.memoize.get("textureHistogramGeneration",()=>new hc(e))}compute(e,t,n,s,r){const{gl:o}=this,{shader:a}=this,l=s.getFramebuffers(o);a.bind(),o.enable(WebGL2RenderingContext.BLEND),o.disable(WebGL2RenderingContext.SCISSOR_TEST),o.disable(WebGL2RenderingContext.DEPTH_TEST),o.blendFunc(WebGL2RenderingContext.ONE,WebGL2RenderingContext.ONE),this.inputIndexBuffer.value.bindToVertexAttrib(a.attribute("aInput1"),1,WebGL2RenderingContext.UNSIGNED_BYTE,!0);const c=a.textureUnit(Op),d=a.textureUnit(_p);o.activeTexture(WebGL2RenderingContext.TEXTURE0+d),o.bindTexture(WebGL2RenderingContext.TEXTURE_2D,t),di(o),o.activeTexture(WebGL2RenderingContext.TEXTURE0+c);const u=s.frameNumber;s.frameNumber=r;for(let h=0;h= p.offset) { + x = uint(v - p.offset); + } else { + x = uint(p.offset - v); + p.multiplier = -p.multiplier; + } + x >>= p.shift; + return float(x) * p.multiplier; +} +float computeInvlerp(${e} inputValue, ${n} p) { + return computeInvlerp(toRaw(inputValue), p); +} +`]}const $w={[R.UINT8]:Io(R.UINT8),[R.INT8]:Io(R.INT8),[R.UINT16]:Io(R.UINT16),[R.INT16]:Io(R.INT16),[R.FLOAT32]:Vp,[R.UINT32]:Bp(R.UINT32),[R.INT32]:Bp(R.INT32),[R.UINT64]:[gt,Eo,Dp,Ip,hr[R.UINT64],` +float computeInvlerp(uint64_t inputValue, Uint64LerpParameters p) { + if (compareLessThan(inputValue, p.offset)) { + inputValue = subtract(p.offset, inputValue); + p.multiplier = -p.multiplier; + } else { + inputValue = subtract(inputValue, p.offset); + } + uint shifted = shiftRight(inputValue, p.shift).value[0]; + return float(shifted) * p.multiplier; +} +`]};function pr(i){let t=` +${yt(i)} computeLerp(float inputValue, vec2 p) { + inputValue = inputValue / p[1] + p[0]; +`;return i===R.FLOAT32?t+=`return inputValue; +`:t+=`return ${R[i].toLowerCase()}FromFloat(round(inputValue)); +`,t+=` +} +`,[ys[i],t]}function Fp(i){const e=yt(i),t=pc[i];return[ys[i],hr[i],Mw,i===R.UINT32?dc:Ow,i===R.UINT32?Nw:_w,` +${e} computeLerp(float inputValue, ${t} p) { + inputValue = inputValue / p.multiplier; + uint x = uint(clamp(round(abs(inputValue)), 0.0, 4294967295.0)); + uint xShifted = shiftLeftSaturate(x, p.shift); + if (inputValue >= 0.0) { + return ${e}(addSaturate(p.offset, xShifted)); + } else { + return ${e}(subtractSaturate(p.offset, xShifted)); + } +} +`]}const Gw={[R.UINT8]:pr(R.UINT8),[R.INT8]:pr(R.INT8),[R.UINT16]:pr(R.UINT16),[R.INT16]:pr(R.INT16),[R.FLOAT32]:pr(R.FLOAT32),[R.UINT32]:Fp(R.UINT32),[R.INT32]:Fp(R.INT32),[R.UINT64]:[gt,Eo,Tp,Iw,Lw,Ip,Rw,hr[R.UINT64],` +uint64_t computeLerp(float inputValue, Uint64LerpParameters p) { + inputValue = inputValue / p.multiplier; + uint64_t x = uint64_t(uvec2(uint(clamp(round(abs(inputValue)), 0.0, 4294967295.0)), 0u)); + uint64_t shifted = shiftLeft(x, p.shift); + if (!equals(shiftRight(shifted, p.shift), x)) { + return uint64_t(uvec2(0xffffffffu, 0xffffffffu)); + } + if (inputValue >= 0.0) { + return addSaturate(p.offset, shifted); + } else { + return subtractSaturate(p.offset, shifted); + } +} +`]};function Up(i,e,t){const n=`uLerpParams_${e}`,s=`uLerpBounds_${e}`,r=`uLerpScalar_${e}`;let o="";switch(t){case R.INT8:case R.UINT8:case R.INT16:case R.UINT16:case R.FLOAT32:i.addUniform("vec2",n);break;case R.INT32:case R.UINT32:{const a=pc[t];i.addUniform(`${t===R.INT32?"i":"u"}vec2`,s),i.addUniform("float",r),o+=` +#define ${n} ${a}(${s}[0], int(${s}[1]), ${r}) +`;break}case R.UINT64:{i.addUniform("uvec3",s),i.addUniform("float",r),o+=` +#define ${n} Uint64LerpParameters(uint64_t(${s}.xy), int(${s}[2]), ${r}) +`;break}}return[hr[t],o]}function Ss(i,e,t,n=!1){const s=yt(t);let r=` +float ${e}(${s} inputValue) { + float v = computeInvlerp(inputValue, uLerpParams_${e}); + ${n?"v = clamp(v, 0.0, 1.0);":""} + defaultMaxProjectionIntensity = v; + return v; +} +`;if(t!==R.UINT64&&t!==R.FLOAT32){const o=ae[t]?"int":"uint";r+=` +float ${e}(${o} inputValue) { + return ${e}(${s}(inputValue)); +} +`}return[ys[t],Up(i,e,t),$w[t],r]}function zw(i,e,t){return[ys[t],Up(i,e,t),Gw[t],` +${yt(t)} ${e}(float inputValue) { + return computeLerp(inputValue, uLerpParams_${e}); +} +`]}const Mi=new P.R;function Ni(i,e,t,n){const{gl:s}=i;switch(t){case R.INT8:case R.UINT8:case R.INT16:case R.UINT16:case R.FLOAT32:s.uniform2f(i.uniform(`uLerpParams_${e}`),n[0],1/(n[1]-n[0]));break;case R.INT32:case R.UINT32:{const r=n[0],o=n[1]-r,a=Math.max(0,Math.ceil(Math.log2(Math.abs(o)))-24),l=2**a/o,c=i.uniform(`uLerpBounds_${e}`);t===R.UINT32?s.uniform2ui(c,r,a):s.uniform2i(c,r,a),s.uniform1f(i.uniform(`uLerpScalar_${e}`),l);break}case R.UINT64:{const r=n[0],o=n[1];P.R.absDifference(Mi,o,r);const a=Mi.high>0?32+Math.ceil(Math.log2(Mi.high)):Math.ceil(Math.log2(Mi.low)),l=Math.max(0,a-24);P.R.rshift(Mi,Mi,l);let c=1/Mi.low;P.R.compare(r,o)>0&&(c*=-1);const d=i.uniform(`uLerpBounds_${e}`);s.uniform3ui(d,r.low,r.high,l),s.uniform1f(i.uniform(`uLerpScalar_${e}`),c)}}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function Mt(i,e,t){(0,f.MM)(i,e,n=>t.restoreState(n))}class fr extends T.O8{constructor(){super(...arguments),this.children=new Map,this.changed=new j.IY}add(e,t){const{children:n}=this;if(n.has(e))throw new Error(`Key ${JSON.stringify(e)} already registered.`);return this.children.set(e,t),t.changed.add(this.changed.dispatch),this.changed.dispatch(),()=>{this.remove(e)}}remove(e){const{children:t}=this;if(t.has(e))throw new Error(`Key ${JSON.stringify(e)} not registered.`);const n=t.get(e);this.children.delete(e),n.changed.remove(this.changed.dispatch),this.changed.dispatch()}disposed(){const{changed:e}=this;for(const t of this.children.values())t.changed.remove(e.dispatch);this.children=void 0,super.disposed()}toJSON(){const e=this.baseJSON();for(const[t,n]of this.children)e[t]=n.toJSON();return e}baseJSON(){return{}}reset(){for(const e of this.children.values())e.reset()}restoreState(e){(0,f.Rf)(e);for(const[t,n]of this.children)try{if(Object.prototype.hasOwnProperty.call(e,t)){const s=e[t];if(s===void 0)continue;n.restoreState(s)}}catch(s){throw new Error(`Error restoring property ${JSON.stringify(t)}: ${s.message}`)}}}class VV extends fr{constructor(){super(...arguments),this.lastState={}}restoreState(e){(0,f.Rf)(e),this.lastState=e,super.restoreState(e)}reset(){this.lastState={},super.reset()}baseJSON(){const e=Object.assign(super.baseJSON(),this.lastState);for(const t of this.children.keys())delete e[t];return e}toJSON(){const e=super.toJSON();return this.lastState=e,e}add(e,t){const n=super.add(e,t),s=this.lastState[e];return s!==void 0&&(t.reset(),t.restoreState(s)),n}}const $p=new WeakMap;function Lo(i){let e=$p.get(i);const t=i.changed.count;if(e!==void 0&&e.generation===t)return e;let n;if(i instanceof fr){n=i.baseJSON();for(const[s,r]of i.children)n[s]=Lo(r).value}else n=i.toJSON();return e===void 0?(e={generation:t,value:n},$p.set(i,e)):(e.generation=t,e.value=n),e}var Oi=G(6703);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */var Ro=(i=>(i[i.LINKED=0]="LINKED",i[i.RELATIVE=1]="RELATIVE",i[i.UNLINKED=2]="UNLINKED",i))(Ro||{}),Gp=(i=>(i[i.LINKED=0]="LINKED",i[i.UNLINKED=2]="UNLINKED",i))(Gp||{});class Ww extends Oi.F{constructor(e=0){super(Ro,e)}}class BV extends Oi.F{constructor(e=0){super(Gp,e)}}const ko=C.eR.create(),zp=C.Yu.create();function gr(i,e,t,n){let s=!1;const r=!1;let o;i.registerDisposer(e);const a=()=>{if(!r){switch(s=!0,t.value){case 2:if(n.isValid(i))break;case 0:n.assign(i,e);break;case 1:n.add(i,e,o);break}s=!1}},l=()=>{if(!s)switch(t.value){case 2:break;case 0:n.assign(e,i);break;case 1:n.subtract(e,i,o);break}};let c=2;const d=()=>{const u=t.value;if(u!==c)switch(u){case 2:o=void 0;break;case 0:o=void 0,n.assign(i,e);break;case 1:o=n.difference(i,e);break}c=u,i.changed.dispatch()};return i.registerDisposer(i.changed.add(l)),i.registerDisposer(e.changed.add(a)),i.registerDisposer(t.changed.add(d)),d(),i}function Wp(i,e,t,n){return gr(i,e,t,n)}class ui extends T.O8{constructor(e){super(),this.coordinateSpace=e,this.coordinates_=ps,this.changed=new j.IY,this.registerDisposer(e.changed.add(()=>{this.handleCoordinateSpaceChanged()}))}get valid(){return this.coordinateSpace.value.valid}get value(){return this.handleCoordinateSpaceChanged(),this.coordinates_}reset(){this.curCoordinateSpace=void 0,this.coordinates_=ps,this.changed.dispatch()}set value(e){const{curCoordinateSpace:t}=this;if(t===void 0||!t.valid||t.rank!==e.length)return;const{coordinates_:n}=this;n.set(e),this.changed.dispatch()}handleCoordinateSpaceChanged(){const e=this.coordinateSpace.value,t=this.curCoordinateSpace;if(e===t)return;this.curCoordinateSpace=e;const{rank:n}=e;if(!e.valid)return;if(t===void 0||!t.valid){let{coordinates_:d}=this;if(!(d!==void 0&&d.length===n)){d=this.coordinates_=new Float32Array(n),bC(d,e.bounds);const{voxelCenterAtIntegerCoordinates:u}=e.bounds;for(let h=0;h(i[i.STOP=0]="STOP",i[i.LOOP=1]="LOOP",i[i.REVERSE=2]="REVERSE",i))(Gn||{});const Hp=10;class fc{constructor(){this.velocity=Hp,this.atBoundary=2,this.paused=!0}}function Hw(i,e){return i.velocity===e.velocity&&i.atBoundary===e.atBoundary&&i.paused===e.paused}function Jw(i){return(0,f.Rf)(i),{velocity:(0,f.MM)(i,"velocity",f.zo,Hp),atBoundary:(0,f.MM)(i,"atBoundary",e=>(0,f.sl)(e,Gn),0),paused:(0,f.MM)(i,"paused",f.aO,!0)}}function jw(i){const{velocity:e,atBoundary:t,paused:n}=i;return{velocity:e,atBoundary:t===0?void 0:Gn[t].toLowerCase(),paused:n?void 0:!1}}class gc extends T.O8{constructor(e){super(),this.coordinateSpace=e,this.changed=new j.IY,this.registerDisposer(e.changed.add(()=>{this.handleCoordinateSpaceChanged()})),this.curCoordinateSpace=e.value,this.velocities_=new Array(this.curCoordinateSpace?.rank??0)}get valid(){return this.coordinateSpace.value.valid}get value(){return this.handleCoordinateSpaceChanged(),this.velocities_}set value(e){const{curCoordinateSpace:t}=this;t===void 0||t.rank!==e.length||(this.velocities_=e,this.changed.dispatch())}get(e){const t=this.coordinateSpace.value?.ids;if(t===void 0)return;const n=t.indexOf(e);return n===-1?void 0:this.value[n]}dimensionVelocity(e,t){const n=new j.IY;let s=-1;const r=()=>{const c=this.coordinateSpace.value?.ids;c===void 0?s=-1:(s===-1||c[s]!==t)&&(s=c.indexOf(t))},o=()=>{if(r(),s!==-1)return this.value[s]},a=c=>{if(r(),s===-1)return;const d=this.value;d[s]!==c&&(d[s]=c,this.changed.dispatch())},l=o();return e.registerDisposer(this.changed.add(()=>{o()!==l&&n.dispatch()})),{get value(){return o()},set value(c){a(c)},changed:n}}modifyDimension(e,t){const n=this.coordinateSpace.value?.ids;if(n===void 0)return;const s=n.indexOf(e);if(s===-1)return;const r=this.value,o=r[s],a=t(o);o!==a&&(r[s]=a,this.changed.dispatch())}togglePlayback(e,t=void 0){this.modifyDimension(e,(n=new fc)=>({...n,paused:t??!n.paused}))}playbackEnabled(e){const t=this;return{changed:this.changed,get value(){return t.get(e)!==void 0},set value(n){t.modifyDimension(e,s=>n?s??new fc:void 0)}}}multiplyVelocity(e,t){this.modifyDimension(e,(n=new fc)=>{let s=Math.round(n.velocity*t);return s===0&&(s=Math.sign(n.velocity)||1),{...n,velocity:s}})}handleCoordinateSpaceChanged(){const e=this.coordinateSpace.value,t=this.curCoordinateSpace;if(e===t)return;this.curCoordinateSpace=e;const{rank:n}=e;if(!e.valid)return;if(t===void 0){let{velocities_:l}=this;l.length===n||(l=new Array(n)),this.changed.dispatch();return}const s=new Array(n),r=this.velocities_,{ids:o}=e,{ids:a}=t;for(let l=0;lo!==void 0))return;const n={},{names:s,rank:r}=t;for(let o=0;o{this.positionLink.value===2?this.changed.dispatch():this.peer.assign(this.velocity)});const n=()=>{this.positionLink.value!==2&&this.velocity.assign(this.peer)};this.registerDisposer(e.changed.add(n)),n()}toJSON(){if(this.positionLink.value===2)return this.velocity.toJSON()}reset(){this.positionLink.value===2&&this.velocity.reset()}restoreState(e){this.positionLink.value===2&&this.velocity.restoreState(e)}copyToPeer(){this.positionLink.value===2&&this.peer.assign(this.velocity)}}class mc extends T.O8{constructor(e,t,n){super(),this.display=e,this.position=t,this.velocity=n,this.dimensionStates=new Map,this.lastUpdateGeneration=0,this.handleVelocityChanged(),this.registerDisposer(n.changed.add(()=>this.handleVelocityChanged()))}disposed(){this.unregisterUpdateStartedCallback?.(),super.disposed()}handleVelocityChanged(){const{dimensionStates:e}=this,t=this.position.coordinateSpace.value?.ids??[],n=t.length,s=this.velocity.value,r=++this.lastUpdateGeneration,o=this.position.value,a=Date.now();for(let l=0;lthis.updateStarted()),this.display.scheduleRedraw())}updateStarted(){const e=this.position.coordinateSpace.value;if(e===void 0)return;const t=e.ids,n=this.position.value;let s=!1,r=!1;const o=Date.now(),a=this.velocity.value,{bounds:{lowerBounds:l,upperBounds:c}}=e;for(const[d,u]of this.dimensionStates){const{dimensionIndex:h}=u;if(t[h]!==d)continue;const p=a[h];if(Math.floor(n[h])!==Math.floor(u.prevCoordinate)){p?.paused===!1&&(a[h]={...p,paused:!0},r=!0);continue}const m=o-u.prevTime,g=p?.velocity??0,v=m*g/1e3;if(v===0)continue;let y=n[h]+v;const S=l[h],w=Math.ceil(c[h]-1),b=v>0?w:S,x=v>0?S:w,E=Math.sign(v);if(Number.isFinite(b)&&y*E>=b*E)switch(p.atBoundary){case 1:if(Number.isFinite(x)){y=x;break}case 0:a[h]={...p,paused:!0},r=!0,y=b;break;case 2:a[h]={...p,velocity:-g},r=!0,y=b;break}n[h]=y,u.prevCoordinate=n[h],u.prevTime=o,s=!0}s&&this.position.changed.dispatch(),r&&this.velocity.changed.dispatch(),this.display.scheduleRedraw()}}function Jp(i,e,t){if(t===void 0||Object.keys(t).length===0){i.value=0;return}(0,f.Rf)(t),i.value=2,(0,f.cQ)(t,"value",n=>{n!==void 0&&e.restoreState(n)}),(0,f.cQ)(t,"link",n=>i.restoreState(n))}class mr{constructor(e,t=new Ww){this.peer=e,this.link=t}get changed(){return this.value.changed}toJSON(){const{link:e}=this;if(e.value!==0)return{link:e.toJSON(),value:this.getValueJson()}}getValueJson(){return this.value.toJSON()}reset(){this.link.value=0}restoreState(e){Jp(this.link,this.value,e)}copyToPeer(){this.link.value!==0&&(this.link.value=2,this.peer.assign(this.value),this.link.value=0)}}class jp extends mr{}class Yp extends mr{constructor(){super(...arguments),this.value=gr(new ui(this.peer.coordinateSpace),this.peer,this.link,{assign:(e,t)=>e.assign(t),isValid:e=>e.valid,difference:ui.getOffset,add:ui.addOffset,subtract:(e,t,n)=>{ui.addOffset(e,t,n,-1)}})}}function Qw(i){return i[0]===0&&i[1]===0&&i[2]===0&&i[3]===1}class bs extends T.O8{constructor(e){super(),this.changed=new j.IY,e==null&&(e=C.Yu.create()),this.orientation=e}toJSON(){const{orientation:e}=this;if(C.Yu.normalize(this.orientation,this.orientation),!Qw(e))return Array.prototype.slice.call(this.orientation)}restoreState(e){try{(0,f.Vr)(this.orientation,e),C.Yu.normalize(this.orientation,this.orientation)}catch{C.Yu.identity(this.orientation)}this.changed.dispatch()}reset(){C.Yu.identity(this.orientation),this.changed.dispatch()}snap(){const e=C.w0.create();C.w0.fromQuat(e,this.orientation);const t=[!1,!1,!1];for(let n=0;n<3;++n){let s=0,r=0;for(let o=0;o<3;++o){const a=e[n*3+o];e[n*3+o]=0,!t[o]&&Math.abs(a)>Math.abs(s)&&(s=a,r=o)}e[n*3+r]=Math.sign(s),t[r]=!0}C.Yu.fromMat3(this.orientation,e),this.changed.dispatch()}static makeRelative(e,t){const n=new bs(C.Yu.multiply(C.Yu.create(),e.orientation,t));let s=!1;n.registerDisposer(e.changed.add(()=>{s||(r=!0,C.Yu.multiply(n.orientation,e.orientation,t),n.changed.dispatch(),r=!1)}));let r=!1;const o=C.Yu.invert(C.Yu.create(),t);return n.registerDisposer(n.changed.add(()=>{r||(s=!0,C.Yu.multiply(e.orientation,n.orientation,o),e.changed.dispatch(),s=!1)})),n}assign(e){C.Yu.copy(this.orientation,e.orientation),this.changed.dispatch()}}class vc extends mr{constructor(){super(...arguments),this.value=gr(new bs,this.peer,this.link,{assign:(e,t)=>e.assign(t),isValid:()=>!0,difference:(e,t)=>{const n=C.Yu.create();return C.Yu.multiply(n,C.Yu.invert(n,t.orientation),e.orientation)},add:(e,t,n)=>{C.Yu.multiply(e.orientation,t.orientation,n),e.changed.dispatch()},subtract:(e,t,n)=>{C.Yu.multiply(e.orientation,t.orientation,C.Yu.invert(zp,n)),e.changed.dispatch()}})}}class Qp extends T.O8{constructor(e){super(),this.coordinateSpace=e,this.changed=new j.IY,this.curCoordinateSpace=Fn,this.value_={factors:new Float64Array(0)},this.registerDisposer(e.changed.add(()=>this.update())),this.update()}get value(){return this.update()}reset(){this.value_={factors:new Float64Array(0)},this.curCoordinateSpace=Fn,this.changed.dispatch()}toJSON(){const e={};let t=!1;const{value:n}=this,{factors:s}=n,{names:r,rank:o}=this.curCoordinateSpace;for(let a=0;al===void 0?1:(0,f.Mo)(l))}this.value_={factors:r},this.curCoordinateSpace=t,this.changed.dispatch()}setFactors(e){const{coordinateSpace:{value:t}}=this;e.length===t.rank&&(this.value_={factors:e},this.curCoordinateSpace=t,this.changed.dispatch())}update(){const{coordinateSpace:{value:e}}=this;let t=this.value_;const{curCoordinateSpace:n}=this;if(n===e)return t;const{ids:s}=n,{ids:r,rank:o}=e,a=t.factors,l=new Float64Array(o);l.fill(1);for(let c=0;ce.assign(t),difference:(e,t)=>{const{factors:n}=e.value,s=e.coordinateSpace.value,r=t.value.factors;return{coordinateSpace:s,offsets:Ul(new Float64Array(n.length),n,r)}},add:(e,t,n)=>{const s=Kp(Float64Array,n.offsets,n.coordinateSpace,e.coordinateSpace.value,()=>0);e.setFactors(Ah(new Float64Array(s.length),s,t.value.factors))},subtract:(e,t,n)=>{const s=Kp(Float64Array,n.offsets,n.coordinateSpace,e.coordinateSpace.value,()=>0);e.setFactors(Ul(new Float64Array(s.length),t.value.factors,s))},isValid:()=>!0})}}function qp(i,e,t){const{rank:n,names:s,units:r}=i,{displayRank:o,displayDimensionIndices:a}=e,l=new Float64Array(3),c=new Float64Array(3);let d;const{factors:u}=t,h=new Array(3),p=new Float64Array(3);if(l.fill(1),c.fill(1),p.fill(1),h.fill(""),o===0)d=1;else{d=Number.POSITIVE_INFINITY;const{scales:m}=i;for(let g=0;g{this.value};this.registerDisposer(e.changed.add(n)),this.registerDisposer(t.changed.add(n))}get value(){const{relativeDisplayScales:{value:e,coordinateSpace:{value:t}},displayDimensions:{value:n},curRelativeDisplayScales:s,curDisplayDimensions:r,curCoordinateSpace:o}=this;let a=this.value_;if(s!==e||r!==n||o!==t){this.curRelativeDisplayScales=e,this.curDisplayDimensions=n,this.curCoordinateSpace=t;const l=qp(t,n,e);Xp(a,l)||(this.value_=a=l,this.changed.dispatch())}return a}}class ef extends T.O8{constructor(e){super(),this.coordinateSpace=e,this.changed=new j.IY,this.default_=!0,this.value_=void 0,this.registerDisposer(this.coordinateSpace.changed.add(this.changed.dispatch)),this.update()}get value(){return this.update(),this.value_}update(){const{coordinateSpace:{value:e}}=this,t=this.value_;if(t!==void 0&&t.coordinateSpace===e)return;if(t===void 0||this.default_){this.setToDefault(e);return}const n=new Int32Array(3),{ids:s}=t.coordinateSpace,{ids:r}=e,o=t.displayDimensionIndices,a=t.displayRank;let l=0;for(let c=0;c3)throw new Error("Number of spatial dimensions must be <= 3");const{coordinateSpace:{value:n}}=this,s=new Int32Array(3);s.fill(-1);const{names:r}=n;let o=0;for(const a of t){const l=r.indexOf(a);l!==-1&&(s[o++]=l)}if(o===0){this.reset();return}this.default_=!1,this.assignValue(n,o,s)}get default(){return this.update(),this.default_}set default(e){this.default_!==e&&(e?(this.default_=!0,this.setToDefault(this.coordinateSpace.value)):(this.default_=!1,this.changed.dispatch()))}setDimensionIndices(e,t){this.default_=!1,this.assignValue(this.coordinateSpace.value,e,t)}toJSON(){if(this.default_)return;const{value:e}=this,t=[],{displayRank:n,displayDimensionIndices:s,coordinateSpace:{names:r}}=e;if(n!==0){for(let o=0;oe.assign(t),isValid:()=>!0})}}class Cs extends T.O8{constructor(e,t,n){super(),this.position=e,this.displayDimensionRenderInfo=t,this.orientation=n,this.changed=new j.IY,this.registerDisposer(e),this.registerDisposer(n),this.registerDisposer(t),this.registerDisposer(e.changed.add(this.changed.dispatch)),this.registerDisposer(n.changed.add(this.changed.dispatch)),this.registerDisposer(t.changed.add(this.changed.dispatch))}get displayDimensions(){return this.displayDimensionRenderInfo.displayDimensions}get relativeDisplayScales(){return this.displayDimensionRenderInfo.relativeDisplayScales}get valid(){return this.position.valid}reset(){this.position.reset(),this.orientation.reset(),this.displayDimensions.reset()}updateDisplayPosition(e,t=ko){const{coordinateSpace:{value:n},value:s}=this.position,{displayDimensionIndices:r,displayRank:o}=this.displayDimensions.value;if(n===void 0)return!1;t.fill(0);for(let a=0;a{const n=new e.constructor(t),s=(c,d)=>{c.assign(d)},r=(c,d)=>c.value/d.value*(c.canonicalVoxelPhysicalSize/d.canonicalVoxelPhysicalSize),o=(c,d,u)=>{c.setPhysicalScale(d.value*u,d.canonicalVoxelPhysicalSize)},a=(c,d,u)=>{c.setPhysicalScale(d.value/u,d.canonicalVoxelPhysicalSize)},l=c=>c.coordinateSpaceValue.valid&&c.canonicalVoxelPhysicalSize!==0;return gr(n,this.peer,this.link,{assign:s,isValid:l,difference:r,add:o,subtract:a}),n})()}}function vr(i){return{changed:i.changed,toJSON(){return i.toJSON()},restoreState(e){Jp(i.link,i.value.legacyJsonView,e)},reset(){i.reset()}}}class tf extends T.O8{constructor(e){super(),this.displayDimensionRenderInfo=e,this.changed=new j.IY,this.curCanonicalVoxelPhysicalSize=0,this.value_=Number.NaN,this.legacyValue_=Number.NaN,this.registerDisposer(e),this.registerDisposer(e.changed.add(()=>this.handleCoordinateSpaceChanged())),this.registerDisposer(e.relativeDisplayScales.coordinateSpace.changed.add(()=>this.handleCoordinateSpaceChanged())),this.handleCoordinateSpaceChanged()}get value(){return this.handleCoordinateSpaceChanged(),this.value_}set value(e){const{canonicalVoxelPhysicalSize:t}=this;Object.is(e,this.value_)&&t===this.curCanonicalVoxelPhysicalSize||(this.curCanonicalVoxelPhysicalSize=t,this.legacyValue_=Number.NaN,this.value_=e,this.changed.dispatch())}get canonicalVoxelPhysicalSize(){return this.displayDimensionRenderInfo.value.canonicalVoxelPhysicalSize}get coordinateSpaceValue(){return this.displayDimensionRenderInfo.relativeDisplayScales.coordinateSpace.value}set legacyValue(e){Object.is(e,this.legacyValue_)||(this.value_=Number.NaN,this.legacyValue_=e,this.curCanonicalVoxelPhysicalSize=0,this.changed.dispatch())}get legacyValue(){return this.legacyValue_}handleCoordinateSpaceChanged(){const{value_:e}=this,{displayDimensionRenderInfo:{value:{canonicalVoxelPhysicalSize:t},relativeDisplayScales:{coordinateSpace:{value:n}}}}=this,{curCanonicalVoxelPhysicalSize:s}=this;if(!(!Number.isNaN(e)&&t===s)){if(!Number.isNaN(e)){s!==0&&(this.value_=e*(s/t),this.curCanonicalVoxelPhysicalSize=t,this.changed.dispatch());return}!n.valid||t===0||(this.curCanonicalVoxelPhysicalSize=t,this.value_=this.getDefaultValue(),this.changed.dispatch())}}toJSON(){const{value:e}=this;return Number.isNaN(e)?void 0:e}restoreState(e){this.curCanonicalVoxelPhysicalSize=0,this.legacyValue_=Number.NaN,e===void 0?this.value_=Number.NaN:this.value_=(0,f.Mo)(e),this.changed.dispatch()}reset(){this.curCanonicalVoxelPhysicalSize=0,this.value_=Number.NaN,this.legacyValue_=Number.NaN,this.changed.dispatch()}get legacyJsonView(){const e=this;return{changed:e.changed,toJSON(){return e.toJSON()},reset(){return e.reset()},restoreState(t){e.legacyValue=(0,f.Mo)(t)}}}setPhysicalScale(e,t){const n=this.curCanonicalVoxelPhysicalSize=this.canonicalVoxelPhysicalSize;this.value=e*(t/n)}assign(e){const{legacyValue:t}=e;Number.isNaN(t)?this.setPhysicalScale(e.value,e.canonicalVoxelPhysicalSize):this.legacyValue=t}}class Zw extends tf{getDefaultValue(){const{legacyValue_:e}=this;if(Number.isNaN(e))return 1;const{canonicalVoxelPhysicalSize:t}=this;return this.legacyValue_*1e-9/t}}class ex extends tf{getDefaultValue(){const{legacyValue_:e}=this;if(!Number.isNaN(e)){this.legacyValue_=Number.NaN;const{canonicalVoxelPhysicalSize:a}=this;return 200*Math.tan(Math.PI/8)*1e-9*e/a}const{coordinateSpaceValue:{bounds:{lowerBounds:t,upperBounds:n}}}=this,{canonicalVoxelFactors:s,displayDimensionIndices:r}=this.displayDimensionRenderInfo.value;let o=s.reduce((a,l,c)=>{const d=r[c],u=(n[d]-t[d])*l;return Math.max(a,u)},0);return Number.isFinite(o)?o=2**Math.ceil(Math.log2(o)):o=1024,o}}class Sc extends T.O8{constructor(e,t){super(),this.defaultValue=e,this.displayDimensionRenderInfo=t,this.changed=new j.IY,this.value_=e,this.canonicalVoxelPhysicalSize=t.value.canonicalVoxelPhysicalSize,this.registerDisposer(t.changed.add(()=>{this.value}))}get value(){let{value_:e}=this;if(e>0){const{canonicalVoxelPhysicalSize:t}=this.displayDimensionRenderInfo.value,n=this.canonicalVoxelPhysicalSize;t!==n&&(this.canonicalVoxelPhysicalSize=t,e=this.value_=e=n/t,this.changed.dispatch())}return e}set value(e){if(e===this.value)return;this.value_=e;const{canonicalVoxelPhysicalSize:t}=this.displayDimensionRenderInfo.value;this.canonicalVoxelPhysicalSize=t,this.changed.dispatch()}toJSON(){const{value:e}=this;if(e!==this.defaultValue)return e}reset(){this.value=this.defaultValue}restoreState(e){typeof e!="number"||!Number.isFinite(e)||e===0?this.value=this.defaultValue:this.value=e}setValueAbsolute(e,t){if(e>0){const{canonicalVoxelPhysicalSize:n}=this.displayDimensionRenderInfo.value;e=e*(t/n)}this.value=e}assign(e){this.setValueAbsolute(e.value,e.canonicalVoxelPhysicalSize)}}class nf extends jp{constructor(e,t){super(e),this.value=Wp(new Sc(e.defaultValue,t),this.peer,this.link,{assign:(n,s)=>n.assign(s),isValid:()=>!0})}}class ws extends T.O8{constructor(e,t,n){super(),this.pose=e,this.zoomFactor=t,this.depthRange=n,this.changed=new j.IY,this.registerDisposer(e),this.registerDisposer(t),this.registerDisposer(n),this.registerDisposer(this.pose.changed.add(this.changed.dispatch)),this.registerDisposer(this.zoomFactor.changed.add(this.changed.dispatch)),this.registerDisposer(this.depthRange.changed.add(this.changed.dispatch))}get coordinateSpace(){return this.pose.position.coordinateSpace}reset(){this.pose.reset(),this.zoomFactor.reset()}get position(){return this.pose.position}get displayDimensions(){return this.pose.displayDimensions}get relativeDisplayScales(){return this.pose.relativeDisplayScales}get displayDimensionRenderInfo(){return this.pose.displayDimensionRenderInfo}toMat4(e){this.pose.toMat4(e,this.zoomFactor.value)}toMat3(e){this.pose.toMat3(e,this.zoomFactor.value)}get relativeDepthRange(){let e=this.depthRange.value;return e>0?e/=this.zoomFactor.value:e*=-1,e}get valid(){return this.pose.valid&&!Number.isNaN(this.zoomFactor.value)}zoomBy(e){this.zoomFactor.value*=e}}/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class tx{constructor(e){if(this.parents=new Array,this.parentPriorities=new Array,this.bindings=new Map,e!==void 0){this.parents.push(...e.parents),this.parentPriorities.push(...e.parentPriorities);for(const[t,n]of e.bindings)this.bindings.set(t,n)}}addParent(e,t){const{parents:n,parentPriorities:s}=this;let r=0;const{length:o}=n;for(;r{this.removeParent(e)}}removeParent(e){const t=this.parents.indexOf(e);if(t===-1)throw new Error("Attempt to remove non-existent parent map.");this.parents.splice(t,1),this.parentPriorities.splice(t,1)}set(e,t){this.bindings.set(e,t)}delete(e){this.bindings.delete(e)}clear(){this.bindings.clear(),this.parents.length=0,this.parentPriorities.length=0}get(e){const{parents:t,parentPriorities:n}=this,s=n.length;let r=0,o;for(;r0;++r)if(o=t[r].get(e),o!==void 0)return o;if(o=this.bindings.get(e),o!==void 0)return o;for(;r0;)o=t[r].get(e),o!==void 0&&(yield o);for(o=this.bindings.get(e),o!==void 0&&(yield o);r0;++s)yield*e[s].entries();for(yield*this.bindings.entries();s(i[i.CONTROL=1]="CONTROL",i[i.ALT=2]="ALT",i[i.META=4]="META",i[i.SHIFT=8]="SHIFT",i))(sf||{});function bc(i){return(i.ctrlKey?1:0)|(i.altKey?2:0)|(i.metaKey?4:0)|(i.shiftKey?8:0)}function Cc(i,e){let t="";return e&1&&(t+="control+"),e&2&&(t+="alt+"),e&4&&(t+="meta+"),e&8&&(t+="shift+"),t+=i,t}function nx(i,e,t){let n="";return e&1&&(n+="control+"),t&1&&(n+="control?+"),e&2&&(n+="alt+"),t&2&&(n+="alt?+"),e&4&&(n+="meta+"),t&4&&(n+="meta?+"),e&8&&(n+="shift+"),t&8&&(n+="shift?+"),n+=i,n}function rf(i){const e=i.indexOf(":");let t;if(e!==-1&&(t=i.substring(0,e),t!=="at"&&t!=="bubble"))throw new Error(`Invalid event phase: ${JSON.stringify(t)}`);const n=i.substring(e+1).split("+");let s,r=0,o=0;e:for(const a of n)switch(a){case"control":r|=1;break;case"control?":o|=1;break;case"alt":r|=2;break;case"alt?":o|=2;break;case"meta":r|=4;break;case"meta?":o|=4;break;case"shift":r|=8;break;case"shift?":o|=8;break;default:if(s===void 0)s=a;else{s=void 0;break e}}if(s===void 0||r&o)throw new Error(`Invalid event identifier: ${JSON.stringify(i)}`);return{phase:t,keyName:s,modifiers:r,optionalModifiers:o}}function*ix(i,e,t){t===0&&(yield Cc(i,e));for(let n=0;n<16;++n)(n&(e|t))===n&&(n&e)===e&&(yield Cc(i,n))}function*of(i){const{phase:e}=i,t=ix(i.keyName,i.modifiers,i.optionalModifiers);if(e===void 0)for(const n of t)yield`at:${n}`,yield`bubble:${n}`;else for(const n of t)yield`${e}:${n}`}function sx(i,e){const t=nx(i.keyName,i.modifiers,i.optionalModifiers);return typeof e=="string"?{action:e,originalEventIdentifier:t}:{...e,originalEventIdentifier:t}}function rx(i){return i=i.replace(/^(?:at|bubble|capture)|(?:(?:shift|control|alt|meta)\?\+)/g,""),i}class Ae extends tx{static fromObject(e,t={}){const n=new Ae;if(n.label=t.label,t.parents!==void 0)for(const[s,r]of t.parents)n.addParent(s,r);for(const s of Object.keys(e))n.set(s,e[s]);return n}setFromObject(e){for(const t of Object.keys(e))this.set(t,e[t])}set(e,t){const n=rf(e),s=sx(n,t);for(const r of of(n))super.set(r,s)}delete(e){for(const t of of(rf(e)))super.delete(t)}describe(){const e=[],t=new Map;for(const[,s]of this.entries())t.set(s.originalEventIdentifier,s.action);const n=new Map;for(const[s,r]of t){let o=n.get(r);o===void 0&&(o=[],n.set(r,o)),o.push(rx(s))}for(const[s,r]of n){const o=r.length===1?r[0]:`{${r.join(",")}}`;e.push(`${o}\u2192${s}`)}return e.join(", ")}}function af(i,e,t){if(t===void 0)return;t.stopPropagation!==!1&&i.stopPropagation();const n=new CustomEvent("action:"+t.action,{bubbles:!0,detail:e,cancelable:!0}),s=!i.target.dispatchEvent(n);(t.preventDefault!==!1||s)&&i.preventDefault()}const Po=[];Po[Event.AT_TARGET]="at",Po[Event.CAPTURING_PHASE]="capture",Po[Event.BUBBLING_PHASE]="bubble";function lf(i,e,t,n,s){const r=Po[t]+":"+i,o=s.get(r);af(e,n,o)}function cf(i,e,t,n){lf(Cc(i,bc(e)),e,e.eventPhase,t,n)}function Z(i,e,t,n){return(0,T.K6)(i,`action:${e}`,t,n)}/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class tn extends T.O8{constructor(e,t,n){super(),this.target=e,this.eventMap=t,this.shouldIgnore=void 0,this.registerEventListener(e,"wheel",s=>{n!==void 0&&n(s),this.dispatch("wheel",s)}),this.registerEventListener(e,"click",s=>{n!==void 0&&n(s),this.dispatch(`click${s.button}`,s)}),this.registerEventListener(e,"dblclick",s=>{n!==void 0&&n(s),this.dispatch(`dblclick${s.button}`,s)}),this.registerEventListener(e,"mousedown",s=>{n!==void 0&&n(s);let r=s.button;r===2&&(s.buttons&3)===1&&(r=0),this.dispatch(`mousedown${r}`,s)}),this.registerEventListener(e,"mouseup",s=>{n!==void 0&&n(s),this.dispatch(`mouseup${s.button}`,s)})}dispatch(e,t){this.shouldIgnore?.(t)||cf(e,t,t,this.eventMap)}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function zt(i,e,t){const{document:n}=i.view;let s=i.clientX,r=i.clientY;const o=d=>{const u=d.clientX-s,h=d.clientY-r;s=d.clientX,r=d.clientY,e(d,u,h)},a=i.button,l=d=>{n.removeEventListener("pointermove",o,!0),n.removeEventListener("pointerup",c,!1),t!==void 0&&t(d,d.clientX-s,d.clientY-r)},c=d=>{d.button===a&&l(d)};n.addEventListener("pointermove",o,!0),n.addEventListener("pointerup",c,!1),n.addEventListener("pointercancel",l,!1)}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const ox=0,ax=1,lx=2;function _i(i){let e=0;const{deltaMode:t}=i;switch(t){case ox:e=.005;break;case ax:e=.1;break;case lx:e=2;break}return Math.exp(i.deltaY*e)}/** + * @license + * Copyright 2018 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const yr=6,FV=2,wc=` +vec2 getQuadVertexPosition(vec2 lower, vec2 upper) { + const vec2 coeffs[] = vec2[]( + vec2(0.0, 0.0), + vec2(0.0, 1.0), + vec2(1.0, 1.0), + vec2(1.0, 1.0), + vec2(1.0, 0.0), + vec2(0.0, 0.0) + ); + int v = gl_VertexID % 6; + return mix(lower, upper, coeffs[v]); +} +`;function Ao(i,e,t){i.drawArraysInstanced(WebGL2RenderingContext.TRIANGLES,0,yr*e,t)}/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const Ut=yr;function In(i,e=!1){i.addVertexCode(wc),i.addUniform("highp vec3","uLineParams"),i.addVarying("highp float","vLineCoord"),i.addVarying("highp float","vLineFeatherFraction"),e&&(i.addVarying("highp float","vEndpointFraction"),i.addVarying("highp float","vLineCoordT"),i.addVarying("highp float","vLineBorderStartFraction")),i.addVertexCode(Aw),i.addVertexCode(` +vec2 getLineOffset() { return getQuadVertexPosition(vec2(0.0, -1.0), vec2(1.0, 1.0)); } +float getLineEndpointCoefficient() { return getLineOffset().x; } +uint getLineEndpointIndex() { return uint(getLineEndpointCoefficient()); } +void emitLine(vec4 vertexAClip, vec4 vertexBClip, float lineWidthInPixels + ${e?", float borderWidth":""}) { + if (!clipLineToDepthRange(vertexAClip, vertexBClip)) { + gl_Position = vec4(2.0, 2.0, 2.0, 1.0); + return; + } + vec3 vertexADevice = vertexAClip.xyz / vertexAClip.w; + vec3 vertexBDevice = vertexBClip.xyz / vertexBClip.w; + + vec2 lineDirectionUnnormalized = vertexBDevice.xy - vertexADevice.xy; + vec2 lineDirection; + float linePixelLength = length(lineDirectionUnnormalized / uLineParams.xy * 0.5); + + if (linePixelLength < 1e-3) { + lineDirection = vec2(1.0, 0.0); + vertexADevice.z = vertexBDevice.z = 0.0; + } else { + lineDirection = normalize(lineDirectionUnnormalized); + } + vec2 lineNormal = normalize(vec2(lineDirection.y, -lineDirection.x) / uLineParams.yx * uLineParams.xy); + + vec2 lineOffset = getLineOffset(); + gl_Position = vec4(mix(vertexADevice, vertexBDevice, lineOffset.x), 1.0); + float totalLineWidth = lineWidthInPixels + 2.0 * uLineParams.z ${e?" + 2.0 * borderWidth":""}; + if (lineWidthInPixels == 0.0) totalLineWidth = 0.0; + vLineFeatherFraction = max(1e-6, uLineParams.z) / totalLineWidth; + gl_Position.xy += (lineOffset.y * lineNormal + ${e?"+ lineDirection * (2.0 * lineOffset.x - 1.0)":""}) + * totalLineWidth * uLineParams.xy; + vLineCoord = lineOffset.y; + ${e?"vEndpointFraction = totalLineWidth / (linePixelLength + totalLineWidth * 2.0);":""} + ${e?"vLineCoordT = lineOffset.x; vLineBorderStartFraction = lineWidthInPixels / totalLineWidth;":""} +} +void emitLine(mat4 projection, vec3 vertexA, vec3 vertexB, float lineWidthInPixels + ${e?", float borderWidth":""}) { + emitLine(projection * vec4(vertexA, 1.0), projection * vec4(vertexB, 1.0), + lineWidthInPixels + ${e?", borderWidth":""}); +} +`),e&&i.addFragmentCode(` +vec4 getRoundedLineColor(vec4 interiorColor, vec4 borderColor) { + float radius; + if (vLineCoordT < vEndpointFraction || vLineCoordT > 1.0 - vEndpointFraction) { + radius = length(vec2(1.0 - min(vLineCoordT, 1.0 - vLineCoordT) / vEndpointFraction, + vLineCoord)); + if (radius > 1.0) { + discard; + } + } else { + radius = abs(vLineCoord); + } + float borderColorFraction = clamp((radius - vLineBorderStartFraction) / vLineFeatherFraction, 0.0, 1.0); + float feather = clamp((1.0 - radius) / vLineFeatherFraction, 0.0, 1.0); + vec4 color = mix(interiorColor, borderColor, borderColorFraction); + return vec4(color.rgb, color.a * feather); +} +`),i.addFragmentCode(` +float getLineAlpha() { + return clamp((1.0 - abs(vLineCoord)) / vLineFeatherFraction, 0.0, 1.0); +} +`)}function mn(i,e,t){Ao(i,e,t)}function vn(i,e,t){const{gl:n}=i;n.uniform3f(i.uniform("uLineParams"),1/e.width,1/e.height,t)}/** + * @license + * Copyright 2024 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function df(i,e=-1,t=1,n=1,s=-1){const r=new Float32Array(i*yr*2),o=(t-e)/i;let a=e;for(let l=0;l1&&(i[0]-=1)}return i}/** + * @license + * Copyright 2018 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class hi extends T.O8{constructor(e,t=()=>C.eR.fromValues(1,0,0),n=hi.template(),s=()=>{},r=!0){super(),this.model=e,this.getDefaultColor=t,this.element=n,this.unsetHandler=s,n.addEventListener("change",()=>this.updateModel()),n.addEventListener("input",()=>this.updateModel()),r&&n.addEventListener("wheel",o=>{o.stopPropagation(),o.preventDefault(),this.adjustHueViaWheel(o)}),n.addEventListener("mousedown",o=>{o.button===2&&(o.stopPropagation(),s())}),this.registerDisposer(e.changed.add(()=>this.updateView())),this.updateView()}static template(){const e=document.createElement("input");return e.classList.add("neuroglancer-color-widget"),e.type="color",e}getRGB(){return this.model.value??this.getDefaultColor()}updateView(){this.element.value=Ge(this.getRGB())}updateModel(){this.model.value=me(this.element.value)}adjustHueViaWheel(e){const t=this.getRGB(),n=C.eR.create();cx(n,t[0],t[1],t[2]);const{deltaY:s}=e;let r=Math.round(n[0]*256);r+=s>0?1:s<0?-1:0,r=(r+256)%256,n[0]=r/256,Mo(n,n[0],n[1],n[2]),this.model.value=n}}var uf=G(2104),hf=G(2809);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function Me(i){for(;;){const e=i.firstChild;if(!e)break;i.removeChild(e)}}function at(i){const{parentElement:e}=i;return e?(e.removeChild(i),!0):!1}function $t(i,e=Math.max(1,i.value.length)){const t=`${e}ch`;i.style.width!==t&&(i.style.width="0px",i.offsetWidth,i.style.width=t)}function nn(i,e){let t=i.firstElementChild;for(const n of e)n!==t&&i.insertBefore(n,t),t=n.nextElementSibling;for(;t!==null;){const n=t.nextElementSibling;i.removeChild(t),t=n}}function xc(i){return i instanceof HTMLElement?!!(i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement||i.isContentEditable):!1}function dx(i){const e=i.cloneNode(!0);return e.style.position="absolute",document.body.appendChild(e),e.getBoundingClientRect()}/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function $V(i){const e=Ne(i);return i.svgHover&&(e.classList.add("neuroglancer-icon-hover"),e.innerHTML+=i.svgHover),e}function Ne(i){const{title:e,onClick:t,href:n}=i;let s;n!==void 0?(s=document.createElement("a"),s.href=n,s.target="_blank"):s=document.createElement("div"),e!==void 0&&(s.title=e),t!==void 0&&s.addEventListener("click",t);const{svg:r}=i;return s.className="neuroglancer-icon",r!==void 0&&(s.innerHTML=r),i.text!==void 0&&s.appendChild(document.createTextNode(i.text)),s}/** + * @license + * Copyright 2018 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class Gt extends T.O8{constructor(e=new vt(vt.VISIBLE)){super(),this.visibility=e,this.element=document.createElement("div");const{element:t}=this;t.classList.add("neuroglancer-tab-content")}get visible(){return this.visibility.visible}disposed(){at(this.element),super.disposed()}}class ux extends T.O8{constructor(){super(...arguments),this.changed=new j.IY,this.options=new Map,this.optionsChanged=new j.IY,this.selectedValue=void 0,this.defaultValue=void 0,this.ready_=!0}get value(){const{selectedValue:e}=this;return e!==void 0?e:this.defaultValue}set default(e){this.defaultValue!==e&&(this.defaultValue=e,this.changed.dispatch())}get default(){return this.defaultValue}set value(e){e!==void 0&&this.ready_&&!this.options.has(e)&&(e=void 0);const{selectedValue:t}=this;t!==e&&(this.selectedValue=e,this.changed.dispatch())}get validValue(){const e=this.selectedValue;return e===void 0||!this.options.has(e)?this.defaultValue:e}add(e,t){const{options:n}=this;if(n.has(e))throw new Error(`Option already defined: ${JSON.stringify(e)}.`);n.set(e,t),this.optionsChanged.dispatch(),this.defaultValue===void 0&&(this.default=e)}remove(e){const{options:t}=this;if(!t.has(e))throw new Error(`Option is not defined: ${JSON.stringify(e)}.`);t.delete(e),this.optionsChanged.dispatch()}toJSON(){const{value:e,defaultValue:t}=this;if(e!==t)return e}reset(){this.value=void 0}get ready(){return this.ready_}set ready(e){e!==this.ready_&&(this.ready_=e,e&&(this.value=this.value),this.changed.dispatch())}restoreState(e){typeof e!="string"&&(e=void 0),this.value=e}}class hx extends T.O8{constructor(e,t,n=new vt(vt.VISIBLE),s=!1){super(),this.getter=e,this.selected=t,this.visibility=n,this.invalidateByDefault=s,this.element=document.createElement("div"),this.tabs=new Map,this.tabVisibilityChanged=new j.HN,this.debouncedUpdateSelectedTab=this.registerCancellable((0,Qe.t)(()=>this.updateSelectedTab()));const{element:r}=this;r.className="neuroglancer-stack-view",this.registerDisposer(n.changed.add(this.debouncedUpdateSelectedTab)),this.registerDisposer(t.changed.add(this.debouncedUpdateSelectedTab)),this.updateSelectedTab()}get visible(){return this.visibility.visible}flush(){this.debouncedUpdateSelectedTab.flush()}invalidate(e){const{tabs:t}=this,n=t.get(e);n!==void 0&&(n.dispose(),t.delete(e),e===this.displayedTab&&(this.displayedTab=void 0,this.debouncedUpdateSelectedTab()))}hideTab(e){const t=this.tabs.get(e);t!==void 0&&(t.visibility.value=vt.IGNORED,t.element.style.display="none"),this.tabVisibilityChanged.dispatch(e,!1)}showTab(e){const{tabs:t}=this;let n=t.get(e);n===void 0&&(n=this.getter(e),this.element.appendChild(n.element),t.set(e,n)),n.element.style.display="",n.visibility.value=vt.VISIBLE,this.tabVisibilityChanged.dispatch(e,!0)}updateSelectedTab(){const{displayedTab:e}=this,t=this.visible?this.selected.value:void 0;t===e&&(t===void 0||this.tabs.has(t))||(e!==void 0&&this.hideTab(e),this.invalidateByDefault&&this.invalidateAll(),this.displayedTab=t,t!==void 0&&this.showTab(t))}invalidateAll(e=void 0){const{tabs:t}=this;for(const[n,s]of t)e?.(n)||(t.delete(n),s.dispose());this.debouncedUpdateSelectedTab()}disposed(){this.invalidateAll(),at(this.element),super.disposed()}}class px extends ux{}function fx(i,e){const t="neuroglancer-selected-tab-label";e?i.classList.add(t):i.classList.remove(t)}class gx extends T.O8{constructor(e,t=new vt(vt.VISIBLE)){super(),this.visibility=t,this.element=document.createElement("div"),this.tabBar=document.createElement("div"),this.tabLabels=new Map,this.tabsGeneration=-1,this.debouncedUpdateView=this.registerCancellable((0,Qe.t)(()=>this.updateTabs())),this.tabs=e.tabs,this.selectedTab=e.selectedTab,this.handleTabElement=e.handleTabElement;const{element:n,tabBar:s}=this;n.className="neuroglancer-tab-view",s.className="neuroglancer-tab-view-bar",n.appendChild(s),this.registerDisposer(t.changed.add(this.debouncedUpdateView));const r=this.stack=this.registerDisposer(new hx(e.makeTab,e.selectedTab,this.visibility));n.appendChild(r.element),this.registerDisposer(e.tabs.changed.add(this.debouncedUpdateView));let o=this.selectedTab.value;this.registerDisposer(e.selectedTab.changed.add(()=>{this.tabs.value.find(({id:c})=>c===o)?.hidden?(this.tabs.changed.count++,this.debouncedUpdateView()):this.updateTabLabelStyles(),o=this.selectedTab.value})),this.updateTabs()}get visible(){return this.visibility.visible}updateTabLabelStyles(){const e=this.selectedTab.value;for(const[t,n]of this.tabLabels)fx(n,t===e)}updateTabs(){this.tabsGeneration!==this.tabs.changed.count&&(this.destroyTabs(),this.visible&&this.makeTabs())}destroyTabs(){if(this.tabsGeneration!==-1){if(this.tabLabels.clear(),!this.visible)this.stack.invalidateAll();else{const e=this.tabs.value;this.stack.invalidateAll(t=>e.find(({id:n})=>n===t)!==void 0)}Me(this.tabBar),this.tabsGeneration=-1}}makeTabs(){const{tabBar:e,tabLabels:t,handleTabElement:n}=this;for(const{id:s,label:r,hidden:o}of this.tabs.value){if(o&&s!==this.selectedTab.value)continue;const a=document.createElement("div");a.classList.add("neuroglancer-tab-label"),a.textContent=r,a.addEventListener("click",()=>{this.selectedTab.value=s}),n!==void 0&&n(s,a),t.set(s,a),e.appendChild(a)}this.updateTabLabelStyles(),this.tabsGeneration=this.tabs.changed.count}disposed(){Me(this.tabBar),this.tabLabels.clear(),at(this.element),super.disposed()}}/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const pf=Ae.fromObject({"shift?+mousedown0":{action:"set"},"shift?+alt+mousedown0":{action:"adjust-window-via-drag"},"shift?+wheel":{action:"zoom-via-wheel"}});function ff(i,e){const t=new fn(i);return In(t),t.addTextureSampler("sampler2D","uHistogramSampler",e),t.addOutputBuffer("vec4","out_color",0),t.addAttribute("uint","aDataValue"),t.addUniform("float","uBoundsFraction"),t.addVertexCode(` +float getCount(int i) { + return texelFetch(uHistogramSampler, ivec2(i, 0), 0).x; +} +vec4 getVertex(float cdf, int i) { + float x; + if (i == 0) { + x = -1.0; + } else if (i == 255) { + x = 1.0; + } else { + x = float(i) / 254.0 * uBoundsFraction * 2.0 - 1.0; + } + return vec4(x, cdf * (2.0 - uLineParams.y) - 1.0 + uLineParams.y * 0.5, 0.0, 1.0); +} +`),t.setVertexMain(` +int lineNumber = int(aDataValue); +int dataValue = lineNumber; +float cumSum = 0.0; +for (int i = 0; i <= dataValue; ++i) { + cumSum += getCount(i); +} +float total = cumSum + getCount(dataValue + 1); +float cumSumEnd = dataValue == ${pi-1} ? cumSum : total; +if (dataValue == ${pi-1}) { + cumSum + getCount(dataValue + 1); +} +for (int i = dataValue + 2; i < 256; ++i) { + total += getCount(i); +} +total = max(total, 1.0); +float cdf1 = cumSum / total; +float cdf2 = cumSumEnd / total; +emitLine(getVertex(cdf1, lineNumber), getVertex(cdf2, lineNumber + 1), 1.0); +`),t.setFragmentMain(` +out_color = vec4(0.0, 1.0, 1.0, getLineAlpha()); +`),t.build()}class gf extends T.O8{constructor(e,t,n,s){super(),this.element=e,this.dataType=t,this.getModel=n,this.setModel=s,e.title=pf.describe(),this.registerDisposer(new tn(e,pf)),Z(e,"set",r=>{const o=r.detail,a=this.getModel(),l=this.getTargetValue(o);if(l===void 0)return;const c=Ze(a.window,a.range),d=Bn(c,l),u=h=>{const p=this.getModel();this.setModel(Sr(p,"range",d,h))};u(l),zt(o,h=>{const p=this.getTargetValue(h);p!==void 0&&u(p)})}),Z(e,"adjust-window-via-drag",r=>{const o=r.detail,a=this.getTargetFraction(o),l=this.getWindowLerp(a),c=a<.5?0:1,d=u=>{const h=this.getModel();this.setModel(Sr(h,"window",c,u))};zt(o,u=>{const h=this.getModel().window,p=this.getTargetFraction(u);d(c===0?de([l,h[1]],this.dataType,-p/(1-p)):de([h[0],l],this.dataType,1/p))})}),Z(e,"zoom-via-wheel",r=>{const o=r.detail,a=_i(o),l=this.getTargetFraction(o),{dataType:c}=this,d=this.getModel(),u=de(d.window,c,l*(1-a)),h=de(d.window,c,(1-l)*a+l);this.setModel({...d,window:[u,h],range:d.range})})}getTargetFraction(e){const t=this.element.getBoundingClientRect();return(e.clientX-t.left)/t.width}getWindowLerp(e){return de(this.getModel().window,this.dataType,e)}getTargetValue(e){const t=this.getTargetFraction(e);if(Number.isFinite(t))return this.getWindowLerp(t)}}const mf=Symbol("histogramSamplerTexture");function Sr(i,e,t,n,s=!1){const r={...i},o=i[e];if(r[e]=[o[0],o[1]],r[e][t]=n,e==="window"&&rt(n,o[1-t])*(2*t-1)<0&&(r[e][1-t]=n),e==="range"&&s){const a=[i.window[0],i.window[1]];for(let l=0;l<2;++l)rt(n,a[l])*(2*l-1)>0&&(a[l]=n);r.window=a}return r}const pi=254+1;class mx extends nc{constructor(e){super(e.display,document.createElement("div"),e.visibility),this.parent=e,this.controller=this.registerDisposer(new gf(this.element,this.parent.dataType,()=>this.parent.trackable.value,n=>{this.parent.trackable.value=n})),this.dataValuesBuffer=this.registerDisposer(ci(this.gl,WebGL2RenderingContext.ARRAY_BUFFER,()=>{const n=new Uint8Array(pi*Ut);for(let s=0;s{const n=new fn(this.gl);return n.addAttribute("vec2","aVertexPosition"),n.addUniform("vec2","uBounds"),n.addUniform("vec4","uColor"),n.addOutputBuffer("vec4","out_color",0),n.setVertexMain(` +gl_Position = vec4(mix(uBounds[0], uBounds[1], aVertexPosition.x) * 2.0 - 1.0, aVertexPosition.y, 0.0, 1.0); +`),n.setFragmentMain(` +out_color = uColor; +`),n.build()})());const{element:t}=this;t.classList.add("neuroglancer-invlerp-cdfpanel")}get drawOrder(){return 100}drawIndirect(){const{lineShader:e,gl:t,regionShader:n,parent:{dataType:s,trackable:{value:r}}}=this;this.setGLLogicalViewport(),t.clearColor(0,0,0,0),t.clear(WebGL2RenderingContext.COLOR_BUFFER_BIT),t.enable(WebGL2RenderingContext.BLEND),t.blendFunc(WebGL2RenderingContext.SRC_ALPHA,WebGL2RenderingContext.ONE_MINUS_SRC_ALPHA),t.disable(WebGL2RenderingContext.DEPTH_TEST),t.disable(WebGL2RenderingContext.STENCIL_TEST);{n.bind(),t.uniform4f(n.uniform("uColor"),.2,.2,.2,1);const o=re(r.window,r.range[0]),a=re(r.window,r.range[1]),l=le(s,r.window);t.uniform2f(n.uniform("uBounds"),Math.min(o,a)*l,Math.max(o,a)*l+(1-l));const c=n.attribute("aVertexPosition");this.regionCornersBuffer.bindToVertexAttrib(c,2,WebGL2RenderingContext.FLOAT),t.drawArrays(WebGL2RenderingContext.TRIANGLE_FAN,0,4),t.disableVertexAttribArray(c)}if(this.parent.histogramSpecifications.producerVisibility.visible){const{renderViewport:o}=this;e.bind(),vn(e,{width:o.logicalWidth,height:o.logicalHeight},1);const a=e.textureUnit(mf);t.uniform1f(e.uniform("uBoundsFraction"),le(s,r.window)),t.activeTexture(WebGL2RenderingContext.TEXTURE0+a),t.bindTexture(WebGL2RenderingContext.TEXTURE_2D,this.parent.texture),di(t);const l=e.attribute("aDataValue");this.dataValuesBuffer.bindToVertexAttribI(l,1,WebGL2RenderingContext.UNSIGNED_BYTE),mn(t,pi,1),t.disableVertexAttribArray(l),t.bindTexture(WebGL2RenderingContext.TEXTURE_2D,null)}t.disable(WebGL2RenderingContext.BLEND)}isReady(){return!0}}function vx(){}class yx extends nc{constructor(e){super(e.display,document.createElement("div"),e.visibility),this.parent=e,this.cornersBuffer=ur(this.gl,-1,-1,1,1);const{element:t}=this;t.classList.add("neuroglancer-invlerp-legend-panel");const n=this.shaderOptions=e.legendShaderOptions;this.shaderGetter=Ai(this,this.gl,{...n,memoizeKey:{id:"colorLegendShader",base:n.memoizeKey},defineShader:(s,r,o)=>{s.addOutputBuffer("vec4","v4f_fragData0",0),s.addAttribute("vec2","aVertexPosition"),s.addUniform("float","uLegendOffset"),s.addVarying("float","vLinearPosition"),s.setVertexMain(` +gl_Position = vec4(aVertexPosition, 0.0, 1.0); +vLinearPosition = -uLegendOffset + ((aVertexPosition.x + 1.0) * 0.5) * (1.0 + 2.0 * uLegendOffset); +`);const a=this.parent.dataType,l=yt(a);s.addFragmentCode(zw(s,"ng_colorLegendLerp",a)),s.addFragmentCode(` +void emit(vec4 v) { + v4f_fragData0 = v; +} +${l} getDataValue() { + return ng_colorLegendLerp(vLinearPosition); +} +${l} getDataValue(int dummyChannel) { + return getDataValue(); +} +${l} getInterpolatedDataValue() { + return getDataValue(); +} +${l} getInterpolatedDataValue(int dummyChannel) { + return getDataValue(); +} +`),n.defineShader(s,r,o)}})}drawIndirect(){const e=this.shaderGetter(vx),{shader:t}=e;if(t===null)return;this.setGLLogicalViewport();const{gl:n}=this;n.clearColor(0,0,0,0),n.clear(WebGL2RenderingContext.COLOR_BUFFER_BIT),t.bind(),this.shaderOptions.initializeShader(e),n.enable(WebGL2RenderingContext.BLEND);const{trackable:{value:{window:s}},dataType:r}=this.parent;Ni(t,"ng_colorLegendLerp",this.parent.dataType,s);const o=ie(r,s);n.uniform1f(t.uniform("uLegendOffset"),Number.isFinite(o)?o:0),n.blendFunc(WebGL2RenderingContext.SRC_ALPHA,WebGL2RenderingContext.ONE_MINUS_SRC_ALPHA),n.disable(WebGL2RenderingContext.DEPTH_TEST),n.disable(WebGL2RenderingContext.STENCIL_TEST);const a=t.attribute("aVertexPosition");this.cornersBuffer.bindToVertexAttrib(a,2,WebGL2RenderingContext.FLOAT),n.drawArrays(WebGL2RenderingContext.TRIANGLE_FAN,0,4),n.disableVertexAttribArray(a)}isReady(){return!0}}function vf(i,e){const t=document.createElement("input");return t.addEventListener("focus",()=>{t.select()}),t.classList.add("neuroglancer-invlerp-widget-bound"),t.classList.add(`neuroglancer-invlerp-widget-${i}-bound`),t.type="text",t.spellcheck=!1,t.autocomplete="off",t.title=i==="range"?`Data value that maps to ${e}`:`${e===0?"Lower":"Upper"} bound for distribution`,t}function yf(i,e,t){const n=document.createElement("div");n.classList.add("neuroglancer-invlerp-widget-bounds"),n.classList.add(`neuroglancer-invlerp-widget-${i}-bounds`);const s=[vf(i,0),vf(i,1)];for(let o=0;o<2;++o){const a=s[o];a.addEventListener("input",()=>{Ec(a)}),a.addEventListener("change",()=>{const l=t.value,c=l[i];try{const d=qt(e,a.value);t.value=Sr(l,i,o,d,!0)}catch{br(a,c[o])}})}let r;return n.appendChild(s[0]),n.appendChild(s[1]),i==="range"&&(r=[document.createElement("div"),document.createElement("div"),document.createElement("div")],r[1].classList.add("neuroglancer-invlerp-widget-range-spacer"),n.insertBefore(r[0],s[0]),n.insertBefore(r[1],s[1]),n.appendChild(r[2])),{container:n,inputs:s,spacers:r}}function Ec(i){$t(i,Math.max(1,i.value.length+.1))}function br(i,e){let t;e instanceof P.R||Number.isInteger(e)?t=e.toString():t=e.toPrecision(6),i.value=t,Ec(i)}function Sf(i){const e=i.value,{range:t}=e;i.value={...e,range:[t[1],t[0]]}}function Sx(i,e,t){const n=e.value,s=de(n.range,i,.5-t/2),r=de(n.range,i,.5+t/2);e.value={...n,range:[s,r]}}function bx(i,e,t,n,s){const r=Math.exp(s),o=e.value,a=de(t,i,.5-r/2+n),l=de(t,i,.5+r/2+n);e.value={...o,range:[a,l]}}class bf extends Gt{constructor(e,t,n,s,r,o,a){super(e),this.display=t,this.dataType=n,this.trackable=s,this.histogramSpecifications=r,this.histogramIndex=o,this.legendShaderOptions=a,this.cdfPanel=this.registerDisposer(new mx(this)),this.boundElements={range:yf("range",this.dataType,this.trackable),window:yf("window",this.dataType,this.trackable)},this.registerDisposer(r.visibility.add(this.visibility));const{element:l,boundElements:c}=this;if(a!==void 0){const u=this.registerDisposer(new yx(this));l.appendChild(u.element)}const d=u=>{const h=Ne({svg:u,title:"Invert range",onClick:()=>{this.invertRange()}});return c.range.spacers[1].appendChild(h),h};this.invertArrows=[d(hf),d(uf)],l.appendChild(c.range.container),l.appendChild(this.cdfPanel.element),l.classList.add("neuroglancer-invlerp-widget"),l.appendChild(c.window.container),this.updateView(),this.registerDisposer(s.changed.add(this.registerCancellable((0,Qe.t)(()=>this.updateView()))))}get texture(){return this.histogramSpecifications.getFramebuffers(this.display.gl)[this.histogramIndex].colorBuffers[0].texture}invertRange(){Sf(this.trackable)}updateView(){const{boundElements:e}=this,{trackable:{value:t},dataType:n}=this;for(let u=0;u<2;++u)br(e.range.inputs[u],t.range[u]),br(e.window.inputs[u],t.window[u]);const s=rt(t.range[0],t.range[1])>0;e.range.container.style.flexDirection=s?"row-reverse":"row";const r=Ze(t.window,t.range),o=e.range.spacers,a=le(n,t.window),l=re(t.window,r[s?1:0])*a,c=re(t.window,r[s?0:1])*a+(1-a);o[s?2:0].style.width=`${l*100}%`,o[s?0:2].style.width=`${(1-c)*100}%`;const{invertArrows:d}=this;d[s?1:0].style.display="",d[s?0:1].style.display="none"}}class Cx extends Gt{constructor(e,t,n,s,r,o,a){super(e),this.display=t,this.watchableDataType=n,this.trackable=s,this.histogramSpecifications=r,this.histogramIndex=o,this.legendShaderOptions=a,this.invlerpWidget=this.makeInvlerpWidget(),this.registerDisposer(n.changed.add(()=>{Me(this.element),this.invlerpWidget.dispose(),this.invlerpWidget=this.makeInvlerpWidget()}))}get dataType(){return this.watchableDataType.value}disposed(){this.invlerpWidget.dispose(),super.disposed()}makeInvlerpWidget(){const{dataType:e}=this,t=new bf(this.visibility,this.display,e,this.trackable,this.histogramSpecifications,this.histogramIndex,this.legendShaderOptions);return this.element.appendChild(t.element),t}}const wx=Ae.fromObject({"at:shift+wheel":{action:"adjust-contrast-via-wheel"},"at:shift+mousedown0":{action:"adjust-via-drag"},"at:shift+mousedown2":{action:"invert-range"}});function Cf(i,e){i.bindInputEventMap(wx),i.bindAction("adjust-contrast-via-wheel",t=>{t.stopPropagation();const n=_i(t.detail);Sx(e.dataType,e.trackable,n)}),i.bindAction("adjust-via-drag",t=>{t.stopPropagation();let n=t.detail.screenX,s=t.detail.screenY,r=e.trackable.value.range,o=r,a=n,l=s;zt(t.detail,c=>{const d=e.trackable.value.range,u=c.screenX,h=c.screenY;Bt(e.dataType,d,o)||(r=d,n=a,s=l),bx(e.dataType,e.trackable,r,(h-s)*2/screen.height,(u-n)*4/screen.width),o=e.trackable.value.range,a=u,l=h})}),i.bindAction("invert-range",t=>{t.stopPropagation(),Sf(e.trackable)})}var wf=G(5061),xf=G(7349),Ef=G(350),xx=G(9575);/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function No(i={}){return Ne({svg:xx,...i})}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */let zn=null,fi=null;const Ex=200;class pe{constructor(e=!1,t=!1){if(zn===null){zn=document.createElement("ul"),zn.id="statusContainer",zn.tabIndex=-1;const s=document.getElementById("neuroglancer-container");s?s.appendChild(zn):document.body.appendChild(zn)}if(t&&fi===null){fi=document.createElement("ul"),fi.id="statusContainerModal";const s=document.getElementById("neuroglancer-container");s?s.appendChild(fi):document.body.appendChild(fi)}const n=document.createElement("li");if(this.element=n,e===!0&&(e=Ex),e!==!1?(this.setVisible(!1),this.timer=window.setTimeout(this.setVisible.bind(this,!0),e)):this.timer=null,t){const s=document.createElement("div"),r=No({title:"Dismiss",onClick:()=>{this.dismissModal()}});r.classList.add("dismiss-modal"),r.addEventListener("click",()=>this.dismissModal()),s.appendChild(r),s.appendChild(n),this.modalElementWrapper=s,fi.appendChild(s)}else zn.appendChild(n)}dispose(){this.modalElementWrapper?fi.removeChild(this.modalElementWrapper):zn.removeChild(this.element),this.element=void 0,this.timer!==null&&clearTimeout(this.timer)}dismissModal(){this.modalElementWrapper&&(fi.removeChild(this.modalElementWrapper),this.modalElementWrapper=void 0,zn.appendChild(this.element))}setText(e,t){this.element.textContent=e,t&&this.setVisible(!0)}setHTML(e,t){this.element.innerHTML=e,t&&this.setVisible(!0)}setVisible(e){this.timer!==null&&(clearTimeout(this.timer),this.timer=null),this.element.style.display=e?"block":"none"}static forPromise(e,t){const n=new pe(t.delay);n.setText(t.initialMessage);const s=n.dispose.bind(n);return e.then(s,r=>{let o;r instanceof Error?o=r.message:o=""+r;const{errorPrefix:a=""}=t;n.setErrorMessage(a+o),n.setVisible(!0)}),e}setErrorMessage(e){this.element.textContent=e+" ";const t=document.createElement("button");t.textContent="Dismiss",t.addEventListener("click",()=>{this.dispose()}),this.element.appendChild(t)}static showMessage(e){const t=new pe;return t.element.textContent=e,t.setVisible(!0),t}static showTemporaryMessage(e,t=2e3){const n=pe.showMessage(e);return window.setTimeout(()=>n.dispose(),t),n}}/** + * @license + * Copyright 2018 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const Tx=/^[A-Z]$/;class Tf extends T.O8{constructor(e,t){super(),this.tool=e,this.inputEventMapBinder=t}bindAction(e,t){this.registerDisposer(Z(window,e,t))}bindInputEventMap(e){this.inputEventMapBinder(e,this)}cancel(){const{globalBinder:e}=this.tool;this===e.activeTool_&&e.deactivate_()}}class Oo extends T.O8{constructor(e,t=!1){super(),this.localBinder=e,this.toggle=t,this.changed=new j.HN,this.keyBinding=void 0}get context(){return this.localBinder.context}get globalBinder(){return this.localBinder.globalBinder}unbind(){const{keyBinding:e}=this;e!==void 0&&this.localBinder.set(e,void 0)}}class gi extends Oo{constructor(e,t=!1){super(e.toolBinder,t),this.layer=e}get mouseState(){return this.layer.manager.root.layerSelectedValues.mouseState}}class Df extends T.O8{constructor(e){super(),this.layer=e,this.changed=new j.HN}get context(){return this.layer}get mouseState(){return this.layer.manager.root.layerSelectedValues.mouseState}deactivate(){}unbind(){const{layer:e}=this;e.tool.value===this&&(e.tool.value=void 0)}}function Tc(i,e){if(e===void 0)return;typeof e=="string"&&(e={type:e}),(0,f.Rf)(e);const t=(0,f.cQ)(e,"type",f.zr);let n=i,s;for(;;){if(n=Object.getPrototypeOf(n),n===null)throw new Error(`Invalid tool type: ${JSON.stringify(e)}.`);if(s=_o.get(n)?.get(t),s!==void 0)break}return s(i,e)}function Dx(i,e){if(e===void 0)return;typeof e=="string"&&(e={type:e}),(0,f.Rf)(e);const t=(0,f.cQ)(e,"type",f.zr),n=If.get(t);if(n===void 0)throw new Error(`Invalid tool type: ${JSON.stringify(e)}.`);return n(i,e)}const If=new Map,_o=new Map;function Cr(i,e){If.set(i,e)}function sn(i,e,t){const{prototype:n}=i;let s=_o.get(n);s===void 0&&(s=new Map,_o.set(n,s)),s.set(e,t)}function Ix(i,e){const{prototype:t}=i,n=_o.get(t);n&&n.delete(e)}class Lx extends T.O8{constructor(e){super(),this.layer=e,this.changed=new j.HN}get value(){return this.value_}set value(e){e!==this.value_&&(this.unregister(),e!==void 0&&(e.changed.add(this.changed.dispatch),this.value_=e),this.changed.dispatch())}unregister(){const e=this.value_;e!==void 0&&(e.changed.remove(this.changed.dispatch),e.dispose(),this.value_=void 0)}disposed(){this.unregister(),super.disposed()}restoreState(e){this.value=Dx(this.layer,e)}reset(){this.value=void 0}toJSON(){const e=this.value_;if(e!==void 0)return e.toJSON()}}class Rx extends T.O8{constructor(e){super(),this.inputEventMapBinder=e,this.bindings=new Map,this.changed=new j.HN,this.debounceDeactivate=this.registerCancellable((0,Fe.A)(()=>{this.deactivate_(),this.reactivateQueuedTool()},100))}get(e){return this.bindings.get(e)}set(e,t){const{bindings:n}=this,s=n.get(e);if(s!==void 0){s.keyBinding=void 0,n.delete(e);const r=s.localBinder;r.bindings.delete(e),r.jsonToKey.delete(JSON.stringify(s.toJSON())),this.destroyTool(s),r.changed.dispatch()}if(t!==void 0){const r=t.localBinder,o=JSON.stringify(t.toJSON()),a=r.jsonToKey.get(o);if(a!==void 0){const l=r.bindings.get(a);l.keyBinding=void 0,n.delete(a),r.bindings.delete(a),r.jsonToKey.delete(o),this.destroyTool(l)}r.bindings.set(e,t),t.keyBinding=e,r.jsonToKey.set(o,e),n.set(e,t),r.changed.dispatch()}this.changed.dispatch()}activate(e,t){if(t=t||this.get(e),t===void 0){this.deactivate_();return}this.debounceDeactivate.cancel();const n=this.activeTool_;if(t.toJSON()===n?.tool.toJSON()){t.toggle&&this.deactivate_();return}n!==void 0&&(n.tool.toggle&&!t.toggle&&(this.queuedTool=n.tool),this.deactivate_());const s=new Tf(t,this.inputEventMapBinder);if(this.activeTool_=s,!t.toggle){const r=`Key${e}`;s.registerEventListener(window,"keydown",o=>{o.stopPropagation(),o.preventDefault()}),s.registerEventListener(window,"keyup",o=>{o.code===r&&this.debounceDeactivate()}),s.registerEventListener(window,"blur",()=>{this.debounceDeactivate()})}return t.activate(s),t}reactivateQueuedTool(){if(this.queuedTool){const e=new Tf(this.queuedTool,this.inputEventMapBinder);this.activeTool_=e,this.queuedTool.activate(e),this.queuedTool=void 0}}destroyTool(e){this.queuedTool===e&&(this.queuedTool=void 0),this.activeTool_?.tool===e&&this.deactivate_(),e.dispose()}disposed(){this.deactivate_(),super.disposed()}deactivate_(){this.debounceDeactivate.cancel();const e=this.activeTool_;e!==void 0&&(this.activeTool_=void 0,e.dispose())}}class Dc extends T.O8{constructor(e,t){super(),this.context=e,this.globalBinder=t,this.bindings=new Map,this.jsonToKey=new Map,this.changed=new j.HN}disposed(){this.clear(),super.disposed()}get(e){return this.bindings.get(e)}set(e,t){this.globalBinder.set(e,t)}setJson(e,t){const n=Tc(this.context,t);n!==void 0&&this.set(e,n)}removeJsonString(e){const t=this.jsonToKey.get(e);t!==void 0&&this.set(t,void 0)}toJSON(){const{bindings:e}=this;if(e.size===0)return;const t={};for(const[n,s]of e)t[n]=s.toJSON();return t}deleteTool(e){const{globalBinder:t,bindings:n,jsonToKey:s}=this,r=n.get(e);r&&(n.delete(e),t.bindings.delete(e),s.delete(JSON.stringify(r.toJSON())),t.destroyTool(r),t.changed.dispatch(),this.changed.dispatch())}clear(){const{globalBinder:e,bindings:t}=this;if(t.size!==0){for(const[n,s]of t)s.keyBinding=void 0,e.bindings.delete(n),e.destroyTool(s);t.clear(),this.jsonToKey.clear(),e.changed.dispatch(),this.changed.dispatch()}}reset(){this.clear()}restoreState(e){if(e!==void 0){(0,f.Rf)(e);for(const[t,n]of Object.entries(e)){if(!t.match(Tx))throw new Error(`Invalid tool key: ${JSON.stringify(t)}`);const s=Tc(this.context,n);if(s===void 0)return;this.set(t,s)}}}}class Lf extends T.O8{constructor(e,t){super(),this.localBinder=e,this.toolJson=t,this.element=document.createElement("div"),this.toolJsonString=JSON.stringify(this.toolJson);const{element:n}=this;n.classList.add("neuroglancer-tool-key-binding"),this.registerDisposer(e.changed.add(this.registerCancellable((0,Qe.t)(()=>this.updateView())))),this.updateView(),n.title="click \u2192 bind key, dbclick \u2192 unbind",n.addEventListener("dblclick",()=>{this.localBinder.removeJsonString(this.toolJsonString)}),Rf(this,n,s=>this.localBinder.setJson(s,this.toolJson))}updateView(){const{localBinder:e}=this,t=e.jsonToKey.get(this.toolJsonString);this.element.textContent=t??" "}}function Rf(i,e,t){let n;e.addEventListener("mousedown",s=>{if(s.button!==0||n!==void 0)return;s.preventDefault(),s.stopPropagation(),n=new T.O8,i.registerDisposer(n),n.registerDisposer(new pe(!1)).setText("Press A-Z to bind key"),n.registerEventListener(window,"keydown",o=>{const{code:a}=o,l=a.match(/^Key([A-Z])$/);if(l===null)return;o.stopPropagation(),o.preventDefault();const c=l[1];t(c)},{capture:!0}),n.registerEventListener(window,"mouseup",o=>{o.button!==0||n===void 0||(o.preventDefault(),o.stopPropagation(),i.unregisterDisposer(n),n.dispose(),n=void 0)})}),e.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation()})}function Wn(i,e,t){const n=document.createElement("div");n.classList.add("neuroglancer-tool-button"),n.appendChild(i.registerDisposer(new Lf(e,t.toolJson)).element);const s=document.createElement("div");s.classList.add("neuroglancer-tool-button-label");const r=t.label;return r!==void 0&&(s.textContent=r),t.title&&(s.title=t.title),n.appendChild(s),n}function kf(i){const e=i.registerDisposer(new pe(!1));e.element.classList.add("neuroglancer-tool-status");const t=document.createElement("div");t.classList.add("neuroglancer-tool-status-content"),e.element.appendChild(t);const{inputEventMapBinder:n}=i;return i.inputEventMapBinder=(s,r)=>{const o=document.createElement("div");o.textContent=s.describe(),o.classList.add("neuroglancer-tool-status-bindings"),e.element.appendChild(o),n(s,r)},{message:e,content:t}}function Vi(i){const{message:e,content:t}=kf(i),n=document.createElement("div");n.classList.add("neuroglancer-tool-status-header");const s=document.createElement("div");s.classList.add("neuroglancer-tool-status-header-container"),s.appendChild(n),t.appendChild(s);const r=document.createElement("div");return r.classList.add("neuroglancer-tool-status-body"),t.appendChild(r),{message:e,body:r,header:n}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function mi(i,e="text/plain"){let t=!1;const n=(0,T.K6)(document,"copy",s=>{const{clipboardData:r}=s;r!==null&&(r.setData(e,i),t=!0),s.stopPropagation(),s.preventDefault()},!0);try{document.execCommand("copy")}finally{n()}return t}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const Vo=new _.B0(0);window.addEventListener("keydown",i=>{Vo.value=bc(i)}),window.addEventListener("keyup",i=>{Vo.value=bc(i)});const kx=new Set(["f1","f2","f3","f4","f5","f6","f7","f8","f9","f10","f11","f12","escape","pause"]),Px=new Set(["color","date","datetime","datetime-local","email","month","number","password","search","tel","text","time","url","week"]);class yn extends T.O8{constructor(e,t){super(),this.target=e,this.eventMap=t,this.modifierShortcutsAreGlobal=!0,this.allShortcutsAreGlobal=!1,this.allowSpaceKeyOnButtons=!1,this.shouldIgnore=void 0,this.registerEventListener(e,"keydown",this.handleKeyDown.bind(this),!1)}shouldIgnoreEvent(e,t){if(this.shouldIgnore?.(t))return!0;const n=t.target,{tagName:s}=n;if(n===this.target)return!1;const r=s==="TEXTAREA"||s==="INPUT"||s==="BUTTON"||s==="SELECT",o=!r&&(n.isContentEditable||n.ownerDocument&&n.ownerDocument.designMode==="on");return!r&&!o||this.allShortcutsAreGlobal||kx.has(e)?!1:o||this.modifierShortcutsAreGlobal&&(t.altKey||t.ctrlKey||t.metaKey)?!0:s==="INPUT"&&Px.has(n.type)?e!=="enter":s==="INPUT"||s==="BUTTON"?this.allowSpaceKeyOnButtons?!1:e==="space":!0}handleKeyDown(e){const t=Ax(e);this.shouldIgnoreEvent(t,e)||cf(t,e,e,this.eventMap)}}function Ax(i){return i.code.toLowerCase()}/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class rn extends T.O8{constructor(e,t){super(),this.element=Ne({...t,onClick:()=>{e.value=!e.value}}),this.element.classList.add("neuroglancer-checkbox-icon"),this.element.classList.add(t.backgroundScheme==="dark"?"dark-background":"light-background");const n=()=>{const s=e.value;this.element.dataset.checked=s?"true":"false",this.element.title=(s?t.disableTitle:t.enableTitle)||""};this.registerDisposer(e.changed.add(n)),n()}}var Mx=G(3112);/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function Hn(i={}){return Ne({svg:Mx,...i})}/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class Nx extends T.O8{constructor(e){super(),this.redraw=e}}class Wt extends T.O8{constructor(e,t,n=new vt(vt.VISIBLE)){super(),this.model=e,this.render=t,this.visibility=n,this.element=document.createElement("div"),this.generation=-1,this.currentViewDisposer=void 0,this.debouncedUpdateView=this.registerCancellable((0,Qe.t)(()=>this.updateView())),this.debouncedForceUpdateView=()=>{this.generation=-1,this.debouncedUpdateView()},this.element.style.display="contents",this.registerDisposer(e.changed.add(this.debouncedUpdateView)),this.registerDisposer(n.changed.add(()=>{this.visible&&this.debouncedUpdateView()})),this.updateView()}get visible(){return this.visibility.visible}updateView(){if(!this.visible)return;const{model:e}=this,t=e.changed.count;if(t===this.generation)return;this.disposeCurrentView();const n=this.currentViewDisposer=new Nx(this.debouncedForceUpdateView);this.render(e.value,this.element,n),this.generation=t}disposeCurrentView(){const{currentViewDisposer:e}=this;e!==void 0&&e.dispose(),Me(this.element)}disposed(){this.disposeCurrentView(),super.disposed()}}/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class Bo extends T.O8{constructor(e){super(),this.model=e,this.element=document.createElement("select"),this.valueIndexMap=new Map;const{element:t,valueIndexMap:n}=this;let s=0;for(const r of Object.keys(e.enumType))if(Number.isNaN(Number(r))){const o=document.createElement("option");o.textContent=o.value=r.toLowerCase(),t.appendChild(o),n.set(e.enumType[r],s),++s}this.registerDisposer(e.changed.add(()=>this.updateView())),this.registerEventListener(t,"change",()=>this.updateModel()),this.registerEventListener(t,"wheel",r=>{r.preventDefault(),r.stopPropagation(),this.adjustViaWheel(r)}),this.updateView()}adjustViaWheel(e){const{element:t}=this,{deltaY:n}=e;n>0?(t.selectedIndex=(t.options.length+t.selectedIndex-1)%t.options.length,this.updateModel()):n<0&&(t.selectedIndex=(t.options.length+t.selectedIndex+1)%t.options.length,this.updateModel())}updateView(){const{element:e}=this;e.selectedIndex=this.valueIndexMap.get(this.model.value)}updateModel(){this.model.restoreState(this.element.value)}}/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class Ic extends T.O8{constructor(e,t={}){super(),this.model=e,this.element=document.createElement("label"),this.inputElement=document.createElement("input");let{validator:n,label:s}=t;const{element:r,inputElement:o}=this;n===void 0&&(e instanceof _.DN?n=e.validator:n=a=>a),this.validator=n,s!==void 0&&(r.textContent=s),r.appendChild(o),r.className="neuroglancer-number-input",o.type="text",this.registerDisposer(this.model.changed.add(()=>this.updateView())),this.registerEventListener(o,"change",()=>this.updateModel()),this.updateView()}updateView(){this.inputElement.value=""+this.model.value}updateModel(){let e=parseFloat(this.inputElement.value.trim());if(Number.isNaN(e)){this.updateView();return}try{e=this.validator(e),this.model.value=e}catch{this.updateView()}}disposed(){at(this.element),super.disposed()}}/** + * @license + * Copyright 2017-2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function Pf(i,e,t,n){return Math.floor((i-e)*(n-1)/(t-e))}function Ox(i,e,t){const{boundingBoxes:n,bounds:s}=i;let[r,o]=_h(s,e);if(r=Math.floor(r),o=Math.floor(o-1),!Number.isFinite(r)||!Number.isFinite(o))return;const a=[],l=d=>Pf(d,r,o,t),{rank:c}=i;for(const d of n){const u=Bh(d,e,c);u!==void 0&&(u.lower=Math.max(0,l(u.lower)),u.upper=Math.min(t-1,l(Math.ceil(u.upper-1))),a.push(u))}return a.sort((d,u)=>{const h=d.lower-u.lower;return h!==0?h:u.upper-u.upper}),(0,F.U8)(a,(d,u)=>{if(u===0)return!0;const h=a[u-1];return h.lower!==d.lower||h.upper!==d.upper}),{lowerBound:r,upperBound:o,normalizedBounds:a}}class Af extends T.O8{constructor(e,t,n="column"){super(),this.position=e,this.dimensionId=t,this.orientation=n,this.element=document.createElement("div"),this.visible=!0,this.dragging=new _.B0(!1),this.tickWidth=this.orientation==="column"?10:5,this.barWidth=this.orientation==="column"?15:10,this.barRightMargin=this.orientation==="column"?10:2,this.canvasWidth=this.tickWidth+this.barWidth+this.barRightMargin;const s=this.element;s.classList.add("neuroglancer-position-dimension-plot"),s.dataset.orientation=n;const r=document.createElement("canvas"),o=r.getContext("2d"),a=document.createElement("div"),l=document.createElement("div");l.appendChild(a);const c=document.createTextNode("");a.appendChild(c);const d=document.createElement("div"),u=document.createElement("div");l.classList.add("neuroglancer-position-dimension-plot-lowerbound"),d.classList.add("neuroglancer-position-dimension-plot-upperbound"),u.classList.add("neuroglancer-position-dimension-plot-hoverposition"),s.appendChild(l),s.appendChild(d),s.appendChild(u),s.appendChild(r);let h,p,m;const g=()=>{const w=this.position.coordinateSpace.value,b=w.ids.indexOf(this.dimensionId);if(b===-1)return;let x;n==="column"?(x=100,r.width=this.canvasWidth,r.height=x,d.style.marginTop=`${x-1}px`):(x=r.clientWidth,r.width=x,r.height=this.canvasWidth);const E=Ox(w,b,x);if(E===void 0||w.bounds.lowerBounds[b]+1===w.bounds.upperBounds[b]){this.element.style.display="none",this.visible=!1;return}this.visible=!0;const{lowerBound:D,upperBound:I}=E;h=D,p=I,c.textContent=D.toString(),d.textContent=I.toString();let L,N,k;n!=="column"&&(N=a.clientWidth,k=d.clientWidth,L=Math.max(N,k)/2,r.style.marginLeft=`${L}px`,r.style.marginRight=`${L}px`,d.style.position="relative",d.style.left=`${x+L-k/2}px`,a.style.marginLeft=`${L-N/2}px`),this.drawDimensionBounds(r,o,E);const O=this.position.value[b],V=(X,ce)=>{if(X!==void 0&&X>=D&&Math.floor(X)<=I){o.fillStyle=ce;const oe=Pf(X,D,I,x);return n==="column"?o.fillRect(0,oe,this.canvasWidth,1):o.fillRect(oe,0,1,this.canvasWidth),oe}},z=V(O,"#f66"),Y=this.dragging.value;let Q=Y?z:V(m,"#66f");if(Q!==void 0){u.textContent=(Y?Math.floor(O):m).toString();const X=n==="column"?a.clientHeight:a.clientWidth,ce=n==="column"?d.clientHeight:d.clientWidth;let oe,Se,Ke;if(n!=="column"){oe=u.clientWidth,Q+=L,Q-=oe/2,Q=Math.max(0,Q);const $e=x+L-ce/2-oe;Se=Q>L+X/2,Ke=Q<$e}else Se=Q>X,Ke=Q{if(h===void 0||p===void 0)return;const b=r.getBoundingClientRect();let x;return n==="column"?x=(w.clientY-b.top)/b.height:x=(w.clientX-b.left)/b.width,x=Math.max(0,x),x=Math.min(1,x),Math.round(x*(p-h))+h},S=w=>{const b=this.position.coordinateSpace.value,x=b.ids.indexOf(this.dimensionId);if(x===-1)return;let E=y(w);if(E===void 0)return;const{position:D}=this,I=D.value;b.bounds.voxelCenterAtIntegerCoordinates[x]||(E+=.5),I[x]=E,D.value=I};r.addEventListener("pointermove",w=>{m=y(w),v()}),r.addEventListener("pointerleave",()=>{m=void 0,v()}),r.addEventListener("pointerdown",w=>{w.preventDefault(),w.stopPropagation(),!(w.ctrlKey||w.altKey||w.metaKey)&&(zt(w,b=>{this.wasDisposed||(m=void 0,S(b),v(),this.dragging.value=!0)},()=>{this.dragging.value=!1,v()}),S(w))}),g(),n==="row"&&(r.style.maxWidth="100%",r.style.justifySelf="stretch",new ResizeObserver(g).observe(r))}drawDimensionBounds(e,t,n){const{orientation:s}=this;t.clearRect(0,0,e.width,e.height);const{normalizedBounds:r}=n,o=s==="column"?l=>{t.fillRect(0,l,this.tickWidth,1)}:l=>{t.fillRect(l,0,1,this.tickWidth)};t.fillStyle="#fff";for(const{lower:l,upper:c}of r)o(l),o(c);const a=r.length;t.fillStyle="#ccc";for(let l=0;li.nameElement,i=>i.coordinate,i=>i.scaleElement];function Uo(i,e){const t=i.coordinateArrays[e];return t===void 0?t:i.units[e]!==""||i.scales[e]!==1?null:t}class Vx{constructor(e,t,n,s){this.coordinateSpace=e,this.id=t,this.container=document.createElement("div"),this.nameContainer=document.createElement("span"),this.nameElement=document.createElement("input"),this.scaleContainer=document.createElement("span"),this.scaleElement=document.createElement("input"),this.coordinate=document.createElement("input"),this.coordinateLabel=document.createElement("span"),this.playButton=document.createElement("div"),this.pauseButton=document.createElement("div"),this.coordinateLabelWidth=0,this.maxPositionWidth=0,this.maxPositionWidthSeen=0,this.dropdownOwner=void 0,this.modified=!1,this.draggingPosition=!1,this.hasFocus=!1;const{container:r,scaleElement:o,scaleContainer:a,coordinate:l,nameElement:c,nameContainer:d,coordinateLabel:u,playButton:h,pauseButton:p}=this;r.title="",r.classList.add("neuroglancer-position-dimension");const{allowFocus:m,showPlayback:g}=s;m&&(r.draggable=!0,r.tabIndex=-1),r.appendChild(d),r.appendChild(o),d.appendChild(c),d.title="Drag to reorder, double click to rename. Names ending in ' or ^ indicate dimensions local to the layer; names ending in ^ indicate channel dimensions (image layers only).",a.appendChild(o),c.classList.add("neuroglancer-position-dimension-name"),c.disabled=!0,c.spellcheck=!1,c.autocomplete="off",c.required=!0,c.placeholder=" ",a.classList.add("neuroglancer-position-dimension-scale-container"),o.classList.add("neuroglancer-position-dimension-scale"),o.disabled=!0,o.spellcheck=!1,o.autocomplete="off",r.appendChild(a),g&&(h.classList.add("neuroglancer-icon"),p.classList.add("neuroglancer-icon"),h.innerHTML=xf,p.innerHTML=wf,r.appendChild(h),r.appendChild(p)),r.appendChild(l),l.type="text",l.classList.add("neuroglancer-position-dimension-coordinate"),l.spellcheck=!1,l.autocomplete="off",l.pattern=String.raw`(-?\d+(?:\.(?:\d+)?)?)`;const v=Uo(e,n);if(v!=null){let y=0;for(const S of v.labels)y=Math.max(y,S.length);this.coordinateLabelWidth=y,u.style.width=`${y+2}ch`,r.appendChild(u)}l.required=!0,l.placeholder=" ",u.classList.add("neuroglancer-position-dimension-coordinate-label"),m&&(d.addEventListener("dblclick",()=>{c.disabled=!1,c.focus(),c.select()}),a.addEventListener("dblclick",()=>{o.disabled=!1,o.focus(),o.select()}),l.addEventListener("focus",()=>{l.select()}),r.addEventListener("click",y=>{(!(y.target instanceof HTMLInputElement)||y.target.disabled)&&l.focus()}))}}function Nf(i,e){const t=e.length;t>i.maxPositionWidthSeen&&(i.maxPositionWidthSeen=t),$t(i.coordinate,Math.max(Math.min(i.maxPositionWidth,i.maxPositionWidthSeen),t))}function Of(i){const{value:e}=i;$t(i),i.parentElement.dataset.isEmpty=e===""?"true":"false"}class xs extends T.O8{constructor(e,t,{copyButton:n=!0,velocity:s=void 0,singleDimensionId:r=void 0,getToolBinder:o=void 0,allowFocus:a=!0,showPlayback:l=!0}={}){super(),this.position=e,this.combiner=t,this.element=document.createElement("div"),this.dimensionContainer=document.createElement("div"),this.coordinateSpace=void 0,this.dimensionWidgets=new Map,this.dimensionWidgetList=[],this.dragSource=void 0;const{element:c,dimensionContainer:d}=this;if(this.velocity=s,this.singleDimensionId=r,this.getToolBinder=o,this.allowFocus=a,this.showPlayback=l,this.registerDisposer(e.coordinateSpace.changed.add(this.registerCancellable((0,Qe.t)(()=>this.updateDimensions())))),c.className="neuroglancer-position-widget",d.style.display="contents",c.appendChild(d),n){const m=Hn({title:"Copy position to clipboard",onClick:()=>{const g=mi(this.getPositionText());pe.showTemporaryMessage(g?"Position copied to clipboard":"Failed to copy position to clipboard")}});m.addEventListener("dragstart",g=>{g.dataTransfer.setData(Fo,JSON.stringify({position:e.toJSON(),dimensions:e.coordinateSpace.value.names})),g.dataTransfer.setData("text",this.getPositionText()),g.stopPropagation()}),m.draggable=!0,c.appendChild(m)}const u=this.registerCancellable((0,Qe.t)(()=>this.updateView()));this.registerDisposer(e.changed.add(u)),s!==void 0&&this.registerDisposer(s.changed.add(u));const h=m=>{const g=m.target;return!!(g instanceof Element&&g.matches(".neuroglancer-position-dimension-playback *"))};if(a){const m=this.registerDisposer(new yn(c,Mf));m.allShortcutsAreGlobal=!0,m.shouldIgnore=h}const p=this.registerDisposer(new tn(c,Mf));p.shouldIgnore=h,this.registerDisposer(Z(c,"cancel",m=>{this.coordinateSpace=void 0,this.updateView(),this.closeDropdown();const{target:g}=m;g instanceof HTMLElement&&g.blur()})),this.updateView()}getDimensionIndex(e){return this.position.coordinateSpace.value.ids.indexOf(e)}openRegularDropdown(e,t){t.classList.add("neuroglancer-position-dimension-dropdown");const n=e.dropdownOwner,s=this.getToolBinder?.();if(s!==void 0){const a=this.getDimensionIndex(e.id),l=Wn(n,s,{toolJson:{type:wr,dimension:e.coordinateSpace.names[a]}});t.appendChild(l)}const r=n.registerDisposer(new Af(this.position,e.id));t.appendChild(r.element);const o=this.velocity?.dimensionVelocity(n,e.id);if(o!==void 0){const a=document.createElement("div");a.classList.add("neuroglancer-position-dimension-playback");const l=document.createElement("div");l.classList.add("neuroglancer-position-dimension-playback-header"),a.appendChild(l),l.appendChild(n.registerDisposer(new rn(this.velocity.playbackEnabled(e.id),{svg:Ef,enableTitle:"Enable playback/velocity",disableTitle:"Disable playback/velocity",backgroundScheme:"dark"})).element),l.appendChild(document.createTextNode("Playback")),t.appendChild(a);const c=n.registerDisposer((0,_.Uq)(d=>d!==void 0,[o]));a.appendChild(n.registerDisposer(new Wt(c,(d,u,h)=>{if(!d)return;const p=new _.B0(0);p.changed.add(()=>{const b=p.value,x=o.value;x!==void 0&&x.velocity!==b&&(o.value={...x,velocity:b})});const m=Ne({text:"\xB1",title:"Negate velocity",onClick:()=>{p.value=-p.value}}),g=h.registerDisposer(new Ic(p));g.element.insertBefore(m,g.element.firstChild),g.element.title="Velocity in coordinates per second";const v=document.createElement("span");v.textContent="/s",g.element.appendChild(v),u.appendChild(g.element);const y=new Oi.F(Gn,Gn.STOP),S=()=>{y.value=o.value?.atBoundary??Gn.STOP,p.value=o.value?.velocity??0};S(),h.registerDisposer(o.changed.add(S)),y.changed.add(()=>{const b=y.value,x=o.value;x!==void 0&&x.atBoundary!==b&&(o.value={...x,atBoundary:b})});const w=new Bo(y).element;u.appendChild(w),w.title="Behavior when lower/upper bound is reached"})).element)}r.dragging.changed.add(()=>{(e.draggingPosition=r.dragging.value)===!1&&this.updateDropdownVisibility(e)})}openCoordinateArrayDropdown(e,t,n){t.classList.add("neuroglancer-position-dimension-coordinate-dropdown");const{coordinates:s,labels:r}=n,o=[],a=s.length;t.style.setProperty("--neuroglancer-coordinate-label-width",`${e.coordinateLabelWidth}ch`);for(let l=0;l{const h=this.getDimensionIndex(e.id);if(h===-1)return;const{position:p}=this,m=p.value;m[h]=s[l]+.5,e.modified=!1,p.value=m}),t.appendChild(c),o.push({entryElement:c,coordinateElement:d,labelElement:u})}}openDropdown(e){if(e.dropdownOwner!==void 0)return;const t=this.getDimensionIndex(e.id);if(t===-1)return;this.closeDropdown();const n=e.dropdownOwner=new T.O8,s=document.createElement("div");s.draggable=!0,s.addEventListener("dragstart",o=>{o.stopPropagation(),o.preventDefault()}),s.addEventListener("pointerenter",()=>{e.hasFocus=!0}),s.tabIndex=-1,e.container.appendChild(s);const r=Uo(e.coordinateSpace,t);r==null?this.openRegularDropdown(e,s):this.openCoordinateArrayDropdown(e,s,r),this.widgetWithOpenDropdown=e,n.registerDisposer(()=>{at(s),e.dropdownOwner=void 0,e.container.dataset.dropdownVisible=void 0,this.widgetWithOpenDropdown=void 0}),n.registerEventListener(document,"pointerdown",o=>{const{target:a}=o;a instanceof Node&&e.container.contains(a)||this.closeDropdown(e)},{capture:!0})}closeDropdown(e=this.widgetWithOpenDropdown){if(e===void 0)return;const{dropdownOwner:t}=e;t!==void 0&&t.dispose()}pasteString(e,t){for(;;){e.coordinate.focus();const n=t.match(/^\s*(-?\d+(?:\.(?:\d+)?)?)((?:\s+(?![\s,]))|(?:\s*,\s*))?/);if(n===null)break;if(n[1]!==void 0&&document.execCommand("insertText",void 0,n[1]),n[2]!==void 0){const{dimensionWidgetList:s}=this,r=s.indexOf(e);if(r===-1||r+1===s.length)break;const o=t.substring(n[0].length);e=s[r+1],t=o;continue}break}}reorderDimensionTo(e,t){if(e===t)return;const{coordinateSpace:n}=this.position;n.value=Qh(n.value,e,t)}updateDropdownVisibility(e){e.hasFocus||e.draggingPosition?this.openDropdown(e):this.closeDropdown(e)}newDimension(e,t,n){const s=new Vx(e,t,n,{allowFocus:this.allowFocus,showPlayback:this.showPlayback});this.singleDimensionId===void 0&&(s.container.addEventListener("dragstart",r=>{this.dragSource=s,r.stopPropagation(),r.dataTransfer.setData("neuroglancer-dimension","")}),s.container.addEventListener("dragenter",r=>{const{dragSource:o}=this;if(o===void 0||o===s)return;const{dimensionWidgetList:a}=this,l=a.indexOf(o),c=a.indexOf(s);l===-1||c===-1||(r.preventDefault(),this.reorderDimensionTo(c,l))}),s.container.addEventListener("dragend",r=>{this.dragSource===s&&(this.dragSource=void 0)})),this.allowFocus?(s.container.addEventListener("focusin",()=>{s.hasFocus=!0,this.updateDropdownVisibility(s)}),s.container.addEventListener("focusout",r=>{const{relatedTarget:o}=r;o instanceof Node&&s.container.contains(o)||(s.hasFocus=!1,this.updateDropdownVisibility(s))}),s.coordinate.addEventListener("paste",r=>{const o=s.coordinate,a=o.value,{clipboardData:l}=r;if(l===null)return;let c=l.getData("text"),{selectionEnd:d,selectionStart:u}=o;if(u!==0||d!==a.length){u==null&&(u=0),d==null&&(d=0);const h=c.match(/[^\-0-9.]/);h!==null&&(c=c.substring(0,h.index)),c.length>0&&document.execCommand("insertText",void 0,c)}else this.pasteString(s,c);r.preventDefault(),r.stopPropagation()}),s.coordinate.addEventListener("input",()=>{s.modified=!0;const r=s.coordinate,o=r.value;let{selectionDirection:a,selectionEnd:l,selectionStart:c}=r;c===null&&(c=0),l===null&&(l=c);let d="";const u=/[^\-0-9.]/g;d+=o.substring(0,c).replace(u,"");const h=d.length;d+=o.substring(c,l).replace(u,"");const p=d.length;d+=o.substring(l).replace(u,""),r.value=d,r.selectionStart=h,r.selectionEnd=p,r.selectionDirection=a,Nf(s,d),l===c&&l===o.length&&o.match(/^(-?\d+(?:\.(?:\d+)?)?)((?:\s+(?![\s,]))|(?:\s*,\s*))$/)&&this.selectAdjacentCoordinate(s,1)}),s.nameElement.addEventListener("input",()=>{const{nameElement:r}=s;$t(r),this.updateNameValidity()}),s.scaleElement.addEventListener("input",()=>{const{scaleElement:r}=s;Of(r),this.updateScaleValidity(s)}),s.coordinate.addEventListener("blur",r=>{const{relatedTarget:o}=r;this.dimensionWidgetList.some(a=>a.coordinate===o)||s.modified&&this.updatePosition()}),s.nameElement.addEventListener("blur",r=>{s.nameElement.disabled=!0;const{relatedTarget:o}=r;this.dimensionWidgetList.some(a=>a.nameElement===o)||this.updateNames()||this.forceUpdateDimensions()}),s.scaleElement.addEventListener("blur",r=>{s.scaleElement.disabled=!0;const{relatedTarget:o}=r;this.dimensionWidgetList.some(a=>a.scaleElement===o)||this.updateScales()||this.forceUpdateDimensions()})):s.coordinate.disabled=!0,Z(s.container,"adjust-via-wheel",r=>{const o=r.detail,{deltaY:a}=o;a!==0&&this.adjustDimensionPosition(s.id,Math.sign(a))}),Z(s.container,"adjust-velocity-via-wheel",r=>{const o=r.detail;this.adjustDimensionVelocity(s,_i(o))}),Z(s.container,"adjust-up",()=>{this.adjustDimensionPosition(s.id,-1)}),Z(s.container,"adjust-down",()=>{this.adjustDimensionPosition(s.id,1)});for(const r of _x){const o=r(s);Z(o,"maybe-tab-forward",a=>{this.handleLeftRightMovement(a,s,1,r)}),Z(o,"maybe-tab-backward",a=>{this.handleLeftRightMovement(a,s,-1,r)}),Z(o,"tab-forward",()=>{this.selectAdjacentField(s,1,r)}),Z(o,"tab-backward",()=>{this.selectAdjacentField(s,-1,r)})}if(Z(s.coordinate,"commit",()=>{this.updatePosition()}),Z(s.nameElement,"commit",()=>{this.updateNames()}),Z(s.scaleElement,"commit",()=>{this.updateScales()}),Z(s.coordinate,"delete-backward",r=>{r.stopPropagation();const{coordinate:o}=s;o.selectionStart===o.selectionEnd&&o.selectionStart===0&&(r.preventDefault(),this.selectAdjacentCoordinate(s,-1))}),this.showPlayback){const r=o=>{this.velocity?.togglePlayback(s.id,o)};s.playButton.addEventListener("click",()=>r(!1)),s.pauseButton.addEventListener("click",()=>r(!0))}return s}forceUpdateDimensions(){let{position:{coordinateSpace:{value:e}}}=this;e.valid||(e=Fn),this.coordinateSpace=e;const{dimensionWidgets:t,dimensionWidgetList:n}=this;n.length=0;const{names:s,ids:r,scales:o,units:a,bounds:{lowerBounds:l,upperBounds:c}}=e,d=(h,p)=>{const m=l[p],g=c[p],v=Math.max(Number.isFinite(m)?Math.floor(m).toString().length:0,Number.isFinite(g)?Math.ceil(g).toString().length:0);let y=t.get(h);y===void 0?(y=this.newDimension(e,h,p),t.set(h,y),y.maxPositionWidthSeen=v):y.coordinateSpace=e,y.maxPositionWidth=v;const S=s[p];y.nameElement.value=S,y.nameElement.dataset.isValid=void 0,$t(y.nameElement);const w=Uo(e,p);w===void 0?y.container.dataset.coordinateArray="none":w===null?y.container.dataset.coordinateArray="invalid":y.container.dataset.coordinateArray="valid",y.scaleContainer.title="Drag to reorder, double click to change scale",w===null&&(y.scaleContainer.title+=". Coordinate array disabled. To use the coordinate array, remove the unit/scale.");const{scale:b,prefix:x,unit:E}=kh(o[p],a[p]),D=`${b}${x}${E}`;return y.scaleElement.value=D,y.scaleElement.dataset.isValid=void 0,Of(y.scaleElement),n.push(y),y.container},{singleDimensionId:u}=this;if(u!==void 0){const h=this.getDimensionIndex(u);h===-1?nn(this.dimensionContainer,[]):nn(this.dimensionContainer,[d(u,h)])}else nn(this.dimensionContainer,r.map(d));for(const[h,p]of t)p.coordinateSpace!==e&&(this.closeDropdown(p),t.delete(h))}updateDimensions(){const{position:{coordinateSpace:{value:e}}}=this;e!==this.coordinateSpace&&this.forceUpdateDimensions()}selectAdjacentField(e,t,n){const{dimensionWidgetList:s}=this;let r=s.indexOf(e);if(r!==-1)for(;;){if(r+=t,r<0||r>=s.length)return!1;const o=s[r],a=n(o);if(a.style.display!=="none")return a.disabled=!1,a.focus(),a.selectionStart=0,a.selectionEnd=a.value.length,a.selectionDirection=t===1?"forward":"backward",!0}}selectAdjacentCoordinate(e,t){return this.selectAdjacentField(e,t,n=>n.coordinate)}handleLeftRightMovement(e,t,n,s){e.stopPropagation();const r=s(t);r.selectionStart!==r.selectionEnd||r.selectionStart!==(n===1?r.value.length:0)||this.selectAdjacentField(t,n,s)&&e.preventDefault()}updateNameValidity(){const{dimensionWidgetList:e}=this,t=e.map(r=>r.nameElement.value),n=t.length,s=this.combiner.getRenameValidity(t);for(let r=0;rl.nameElement.value);if(this.combiner.getRenameValidity(s).includes(!1))return!1;const r=n.names;if((0,F.r1)(r,s))return!1;const o=n.timestamps.map((l,c)=>r[c]===s[c]?l:Date.now()),a={...n,names:s,timestamps:o};return t.value=a,!0}updateScales(){if(!this.allowFocus)return;const{dimensionWidgetList:e}=this,{position:{coordinateSpace:t}}=this,n=t.value,s=e.map(u=>sr(u.scaleElement.value));if(s.includes(void 0))return!1;const r=Float64Array.from(s,u=>u.scale),o=Array.from(s,u=>u.unit),{scales:a,units:l}=n;if((0,F.r1)(a,r)&&(0,F.r1)(l,o))return!1;const c=n.timestamps.map((u,h)=>r[h]===a[h]&&o[h]===l[h]?u:Date.now()),d=Oe({valid:n.valid,rank:n.rank,scales:r,units:o,timestamps:c,ids:n.ids,names:n.names,boundingBoxes:n.boundingBoxes,coordinateArrays:n.coordinateArrays});return t.value=d,!0}getPositionText(){const{position:e}=this;return e.valid?e.value.map(t=>Math.floor(t)).join(", "):""}updateView(){this.updateDimensions();const{position:{value:e},dimensionWidgetList:t}=this,n=t.length;if(e===void 0)return;const s=this.coordinateSpace,{velocity:r}=this;for(let o=0;ov-y);g!==m.length&&(h=u.labels[g])}const p=a.coordinateLabel;if(p.textContent=h,this.showPlayback){const m=r?.value?.[o];if(m!==void 0){const g=m.paused;a.playButton.style.display=g?"":"none",a.pauseButton.style.display=g?"none":""}else a.playButton.style.display="none",a.pauseButton.style.display="none"}}}disposed(){this.closeDropdown(),at(this.element),super.disposed()}}class Bx extends T.O8{constructor(e,t,n){super(),this.element=e,this.mouseState=t,this.coordinateSpace=n,this.tempPosition=C.eR.create(),e.className="neuroglancer-mouse-position-widget";const s=this.registerCancellable((0,Qe.t)(()=>this.updateView()));this.registerDisposer(t.changed.add(s)),this.registerDisposer(n.changed.add(s))}updateView(){let e="";const{mouseState:t,coordinateSpace:{value:n}}=this;if(t.active&&n!==void 0){const s=t.position,{rank:r,names:o}=n;for(let a=0;a{const r=this.coordinateSpace.value,o=this.dimensionIndex=this.coordinateSpace.value.ids.indexOf(t);if(o===-1){this.unbind();return}const a=r.names[o];this.dimensionName!==a&&(this.dimensionName=a,this.changed.dispatch())}))}get position(){return this.viewer.position}get velocity(){return this.viewer.velocity}get coordinateSpace(){return this.viewer.coordinateSpaceCombiner.combined}activate(e){const{viewer:t}=this,{content:n}=kf(e);n.classList.add("neuroglancer-position-tool"),e.bindInputEventMap(Fx);const s=new xs(t.position,t.coordinateSpaceCombiner,{velocity:t.velocity,singleDimensionId:this.dimensionId,copyButton:!1,allowFocus:!1,showPlayback:!1});s.element.style.userSelect="none",n.appendChild(e.registerDisposer(s).element);const r=e.registerDisposer(new Af(t.position,this.dimensionId,"row"));r.element.style.flex="1",n.appendChild(r.element),e.bindAction("adjust-position-via-wheel",l=>{l.stopPropagation();const c=l.detail,{deltaY:d}=c;d!==0&&s.adjustDimensionPosition(this.dimensionId,Math.sign(d))});const o=this.velocity.dimensionVelocity(e,this.dimensionId),a=e.registerDisposer((0,_.Uq)(l=>l!==void 0,[o]));n.appendChild(e.registerDisposer(new Wt(a,(l,c,d)=>{if(!l)return;c.classList.add("neuroglancer-position-dimension-playback");const u=document.createElement("div"),h=document.createElement("div");u.classList.add("neuroglancer-icon"),h.classList.add("neuroglancer-icon"),u.innerHTML=xf,h.innerHTML=wf,c.appendChild(u),c.appendChild(h);const p=()=>t.velocity.togglePlayback(this.dimensionId);u.addEventListener("click",p),h.addEventListener("click",p);const m=()=>{const E=o.value?.paused;u.style.display=E?"":"none",h.style.display=E?"none":""};d.registerDisposer(o.changed.add(m)),m();const g=new _.B0(0);g.changed.add(()=>{const E=g.value,D=o.value;D!==void 0&&D.velocity!==E&&(o.value={...D,velocity:E})});const v=Ne({text:"\xB1",title:"Negate velocity",onClick:()=>{g.value=-g.value}}),y=d.registerDisposer(new Ic(g));y.inputElement.disabled=!0,y.element.insertBefore(v,y.element.firstChild),y.element.title="Velocity in coordinates per second";const S=document.createElement("span");S.textContent="/s",y.element.appendChild(S),c.appendChild(y.element);const w=new Oi.F(Gn,Gn.STOP),b=()=>{w.value=o.value?.atBoundary??Gn.STOP,g.value=o.value?.velocity??0};b(),d.registerDisposer(o.changed.add(b)),w.changed.add(()=>{const E=w.value,D=o.value;D!==void 0&&D.atBoundary!==E&&(o.value={...D,atBoundary:E})});const x=new Bo(w).element;c.appendChild(x),x.title="Behavior when lower/upper bound is reached"})).element),n.appendChild(e.registerDisposer(new rn(t.velocity.playbackEnabled(this.dimensionId),{svg:Ef,enableTitle:"Enable playback/velocity",disableTitle:"Disable playback/velocity",backgroundScheme:"dark"})).element),e.bindAction("adjust-velocity-via-wheel",l=>{l.stopPropagation();const c=_i(l.detail);t.velocity.multiplyVelocity(this.dimensionId,c)}),e.bindAction("toggle-playback",l=>{l.stopPropagation(),t.velocity.togglePlayback(this.dimensionId)})}get description(){return`dim ${this.dimensionName}`}toJSON(){return{type:wr,dimension:this.dimensionName}}}function Lc(i,e){const t=(0,f.cQ)(e,"dimension",f.zr),n=i.coordinateSpaceCombiner.combined.value,s=n.names.indexOf(t);if(s===-1)throw new Error(`Invalid dimension name: ${JSON.stringify(t)}`);return new Ux(i,n.ids[s])}function $x(i){sn(i,wr,(e,t)=>Lc({position:e.position,velocity:e.velocity,coordinateSpaceCombiner:e.layerSpecification.coordinateSpaceCombiner,toolBinder:e.toolBinder},t))}function Gx(i){sn(i,wr,(e,t)=>Lc({position:e.localPosition,velocity:e.localVelocity,coordinateSpaceCombiner:e.localCoordinateSpaceCombiner,toolBinder:e.toolBinder},t))}function zx(i){sn(i,wr,(e,t)=>Lc({position:e.viewerNavigationState.position.value,velocity:e.viewerNavigationState.velocity.velocity,coordinateSpaceCombiner:e.layerSpecification.root.coordinateSpaceCombiner,toolBinder:e.toolBinder},t))}/** + * @license + * Copyright 2024 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const $o=512,xr=4,_f=4,Rc=.05,Go=.05,Vf=Symbol("transferFunctionSamplerTexture"),Bf=Symbol("histogramSamplerTexture"),Ff={[R.UINT8]:256,[R.INT8]:256,[R.UINT16]:8192,[R.INT16]:8192,[R.UINT32]:8192,[R.INT32]:8192,[R.UINT64]:8192,[R.FLOAT32]:8192};class Ln{constructor(e,t=C.yb){this.inputValue=e,this.outputColor=t}normalizedInput(e){return re(e,this.inputValue)}transferFunctionIndex(e,t){return Math.floor(this.normalizedInput(e)*(t-1))}interpolateColor(e,t){const n=C.ln.create();for(let s=0;s<4;++s)n[s]=de([this.outputColor[s],e.outputColor[s]],R.UINT8,t);return n}static copyFrom(e){const t=e.inputValue,n=C.ln.clone(e.outputColor);return new Ln(t,n)}}class zo{constructor(e=[],t,n=!0){this.controlPoints=e,this.dataType=t,this.autoComputeRange=n,this.controlPoints=e,this.range=he[t],this.sortAndComputeRange()}get length(){return this.controlPoints.length}addPoint(e){const{inputValue:t,outputColor:n}=e,s=this.controlPoints.findIndex(o=>o.inputValue===t);s!==-1&&this.updatePointColor(s,n);const r=new Ln(t,n);this.controlPoints.push(r),this.sortAndComputeRange()}removePoint(e){this.controlPoints.splice(e,1),this.computeRange()}updatePoint(e,t){this.controlPoints[e]=t;const n=t.inputValue,s=t.outputColor;this.sortAndComputeRange();for(let r=0;rt.normalizedInput(this.range)),e,(t,n)=>t-n)}sortAndComputeRange(){this.controlPoints.sort((e,t)=>e.normalizedInput(this.range)-t.normalizedInput(this.range)),this.computeRange()}computeRange(){if(this.autoComputeRange)if(this.controlPoints.length==0)this.range=he[this.dataType];else if(this.controlPoints.length===1){let e=he[this.dataType][1];this.dataType===R.FLOAT32&&e<=this.controlPoints[0].inputValue&&(e=this.controlPoints[0].inputValue+1),this.range=[this.controlPoints[0].inputValue,e]}else this.range=[this.controlPoints[0].inputValue,this.controlPoints[this.controlPoints.length-1].inputValue];this.range[0]===this.range[1]&&(this.range=he[this.dataType])}copy(){const e=new zo([],this.dataType,this.autoComputeRange);return e.range=this.range,e.controlPoints=this.controlPoints.map(t=>Ln.copyFrom(t)),e}}class Es{constructor(e){this.lookupTableSize=e,this.outputValues=new Uint8Array(e*xr).fill(0)}resize(e){this.lookupTableSize=e,this.outputValues=new Uint8Array(e*xr).fill(0)}updateFromControlPoints(e,t=void 0){const n=t||e.range,{controlPoints:s}=e,r=this.outputValues,o=this.lookupTableSize;function a(u,h){r[u]=h[0],r[u+1]=h[1],r[u+2]=h[2],r[u+3]=h[3]}function l(u){return u.transferFunctionIndex(n,o)}if(s.length===0){r.fill(0);return}const c=l(s[0]);if(c>0){const u=C.ln.fromValues(0,0,0,0);for(let h=0;h=v&&d++}}}static equal(e,t){return(0,F.r1)(e.outputValues,t.outputValues)}copy(){const e=new Es(this.lookupTableSize);return e.outputValues.set(this.outputValues),e}}class Wx extends T.O8{constructor(e,t,n=Ff[e]){super(),this.dataType=e,this.trackable=t,this.lookupTable=new Es(n),this.updateLookupTable()}get sortedControlPoints(){return this.trackable.value.sortedControlPoints}get range(){return this.sortedControlPoints.range}get size(){return this.lookupTable.lookupTableSize}updateLookupTable(e=void 0){this.lookupTable.updateFromControlPoints(this.sortedControlPoints,e)}addPoint(e){this.sortedControlPoints.addPoint(e)}updatePoint(e,t){return this.sortedControlPoints.updatePoint(e,t)}removePoint(e){this.sortedControlPoints.removePoint(e)}updatePointColor(e,t){this.sortedControlPoints.updatePointColor(e,t)}findNearestControlPointIndex(e,t){const n=de(t,this.dataType,e);return this.sortedControlPoints.findNearestControlPointIndex(n)}}class Uf extends T.O8{constructor(e){super(),this.gl=e,this.texture=null,this.height=1,this.priorOptions=void 0}updateAndActivate(e){const{gl:t}=this;if(t===null)return;let{texture:n}=this;function s(o,a){if(a===void 0)throw new Error("Texture unit must be defined for transfer function texture");o.activeTexture(WebGL2RenderingContext.TEXTURE0+a),o.bindTexture(WebGL2RenderingContext.TEXTURE_2D,n)}if(n!==null&&this.optionsEqual(e))return s(t,e.textureUnit),this.width*this.height;n===null&&(n=this.texture=t.createTexture()),s(t,e.textureUnit),di(t);const r=this.createLookupTable(e);return t.texImage2D(WebGL2RenderingContext.TEXTURE_2D,0,WebGL2RenderingContext.RGBA,this.width,this.height,0,WebGL2RenderingContext.RGBA,WebGL2RenderingContext.UNSIGNED_BYTE,r.outputValues),this.setOptions(e),this.width*this.height}setTextureWidthAndHeightFromSize(e){this.width=e}disposed(){this.gl?.deleteTexture(this.texture),this.texture=null,this.priorOptions=void 0,super.disposed()}}class Hx extends Uf{constructor(e){super(e),this.gl=e,this.texture=null,this.priorOptions=void 0}optionsEqual(e){const t=this.priorOptions;if(t===void 0)return!1;const n=Es.equal(t.lookupTable,e.lookupTable),s=t.textureUnit===e.textureUnit;return n&&s}createLookupTable(e){return this.setTextureWidthAndHeightFromSize(e.lookupTable.lookupTableSize),e.lookupTable}setOptions(e){this.priorOptions={...e,lookupTable:e.lookupTable.copy()}}}class Jx extends Uf{constructor(e){super(e),this.gl=e}optionsEqual(e){const t=this.priorOptions;if(t===void 0)return!1;const n=(0,F.wm)(t.sortedControlPoints.controlPoints,e.sortedControlPoints.controlPoints,(o,a)=>o.inputValue===a.inputValue&&(0,F.r1)(o.outputColor,a.outputColor)),s=t.textureUnit===e.textureUnit,r=t.dataType===e.dataType;return n&&s&&r}setOptions(e){this.priorOptions={...e,sortedControlPoints:e.sortedControlPoints.copy()}}createLookupTable(e){const t=this.ensureTextureSize(e.lookupTableSize);if(t===void 0)return new Es(0);this.setTextureWidthAndHeightFromSize(t);const n=new Es(t),s=e.sortedControlPoints;return n.updateFromControlPoints(s),n}ensureTextureSize(e){const t=this.gl;if(t===null)return;const n=t.getParameter(t.MAX_TEXTURE_SIZE);return Math.min(e,n)}}class jx extends nc{constructor(e){super(e.display,document.createElement("div"),e.visibility),this.parent=e,this.controlPointsPositionArray=new Float32Array,this.controlPointsColorArray=new Float32Array,this.linePositionArray=new Float32Array,this.transferFunction=this.registerDisposer(new Wx(this.parent.dataType,this.parent.trackable,$o)),this.controller=this.registerDisposer(new Qx(this.element,this.parent.dataType,this.transferFunction,()=>this.parent.trackable.value,r=>{this.parent.trackable.value=r})),this.dataValuesBuffer=this.registerDisposer(ci(this.gl,WebGL2RenderingContext.ARRAY_BUFFER,()=>{const r=new Uint8Array(pi*Ut);for(let o=0;o{const r=new fn(this.gl);return In(r),r.addAttribute("vec4","aLineStartEnd"),r.addOutputBuffer("vec4","out_color",0),r.addVarying("float","vColor"),r.setVertexMain(` +vec4 start = vec4(aLineStartEnd[0], aLineStartEnd[1], 0.0, 1.0); +vec4 end = vec4(aLineStartEnd[2], aLineStartEnd[3], 0.0, 1.0); +emitLine(start, end, 1.0); +`),r.setFragmentMain(` +out_color = vec4(0.35, 0.35, 0.35, getLineAlpha()); +`),r.build()})()),this.transferFunctionShader=this.registerDisposer((()=>{const r=new fn(this.gl);return r.addAttribute("vec2","aVertexPosition"),r.addVarying("vec2","vTexCoord"),r.addOutputBuffer("vec4","out_color",0),r.addTextureSampler("sampler2D","uSampler",Vf),r.addUniform("float","uTransferFunctionEnd"),r.setVertexMain(` +gl_Position = vec4(aVertexPosition, 0.0, 1.0); +vTexCoord = (aVertexPosition + 1.0) / 2.0; +`),r.setFragmentMain(` +ivec2 texel = ivec2(floor(vTexCoord.x * uTransferFunctionEnd), 0); +out_color = texelFetch(uSampler, texel, 0); +`),r.build()})()),this.controlPointsShader=this.registerDisposer((()=>{const r=new fn(this.gl);return r.addAttribute("vec2","aVertexPosition"),r.addAttribute("vec3","aVertexColor"),r.addVarying("vec3","vColor"),r.addOutputBuffer("vec4","out_color",0),r.setVertexMain(` +gl_Position = vec4(aVertexPosition, 0.0, 1.0); +gl_PointSize = 14.0; +vColor = aVertexColor; +`),r.setFragmentMain(` +float vColorSum = vColor.r + vColor.g + vColor.b; +vec3 bordercolor = vec3(0.0, 0.0, 0.0); +if (vColorSum < 0.4) { + bordercolor = vec3(1.0, 1.0, 1.0); +} +float dist = distance(gl_PointCoord, vec2(0.5, 0.5)); +float alpha = smoothstep(0.25, 0.4, dist); +vec4 tempColor = vec4(mix(vColor, bordercolor, alpha), 1.0); +alpha = 1.0 - smoothstep(0.4, 0.5, dist); +out_color = tempColor * alpha; +`),r.build()})());const{element:t,gl:n}=this;t.classList.add("neuroglancer-transfer-function-panel"),this.textureVertexBufferArray=df($o),this.texture=this.registerDisposer(new Hx(n));function s(r){return ci(n,WebGL2RenderingContext.ARRAY_BUFFER,()=>r).value}this.textureVertexBuffer=this.registerDisposer(s(this.textureVertexBufferArray)),this.controlPointsVertexBuffer=this.registerDisposer(s(this.controlPointsPositionArray)),this.controlPointsColorBuffer=this.registerDisposer(s(this.controlPointsColorArray)),this.linePositionBuffer=this.registerDisposer(s(this.linePositionArray))}get drawOrder(){return 1}updateTransferFunctionPointsAndLines(){const e=this.parent.trackable.value.window;function t(I){return re(e,I)*2-1}function n(I){return I/255*2-1}function s(I){return I/255}function r(I,L,N){for(let k=0;k=-1&&I<=1}const{transferFunction:a}=this,{controlPoints:l}=a.trackable.value.sortedControlPoints;let c=Math.max(l.length-1,0);const d=xr-1,u=new Float32Array(l.length*d),h=new Float32Array(l.length*2);let p=0,m=null,g=null;const v=l.map(I=>{const L=t(I.inputValue),N=n(I.outputColor[3]);return{input:L,output:N}});if(l.length>0){const{firstPointIndexInWindow:I,lastPointIndexInWindow:L,pointClosestToLeftEdge:N,pointClosestToRightEdge:k}=E();if(I===null){const O=v[l.length-1].input<-1,V=v[0].input>1;O?D():!V&&l.length>1&&x(N,k)}else{const O=v[I];O.input>-1&&(I>0?b(I,O):m=C.ln.fromValues(O.input,-1,O.input,O.output),c+=1);const V=v[L];V.input<1&&(L1){k=V;break}}return{firstPointIndexInWindow:I,lastPointIndexInWindow:L,pointClosestToLeftEdge:N,pointClosestToRightEdge:k}}function D(){const I=l.length-1;c+=1;const L=v[I].output;m=C.ln.fromValues(-1,L,1,L)}}drawIndirect(){const{transferFunctionLineShader:e,gl:t,transferFunctionShader:n,controlPointsShader:s,histogramLineShader:r}=this;this.setGLLogicalViewport(),t.clearColor(0,0,0,0),t.clear(WebGL2RenderingContext.COLOR_BUFFER_BIT),t.enable(WebGL2RenderingContext.BLEND),t.blendFunc(WebGL2RenderingContext.SRC_ALPHA,WebGL2RenderingContext.ONE_MINUS_SRC_ALPHA),t.disable(WebGL2RenderingContext.DEPTH_TEST),t.disable(WebGL2RenderingContext.STENCIL_TEST);{n.bind();const o=n.attribute("aVertexPosition");t.uniform1f(n.uniform("uTransferFunctionEnd"),$o-1),this.textureVertexBuffer.bindToVertexAttrib(o,2,WebGL2RenderingContext.FLOAT);const a=n.textureUnit(Vf);this.texture.updateAndActivate({lookupTable:this.transferFunction.lookupTable,textureUnit:a}),Ao(this.gl,$o,1),t.disableVertexAttribArray(o),t.bindTexture(WebGL2RenderingContext.TEXTURE_2D,null)}if(this.parent.histogramSpecifications.producerVisibility.visible){const{renderViewport:o}=this;r.bind(),vn(r,{width:o.logicalWidth,height:o.logicalHeight},1);const a=r.textureUnit(Bf);t.uniform1f(r.uniform("uBoundsFraction"),le(this.parent.dataType,this.parent.trackable.value.window)),t.activeTexture(WebGL2RenderingContext.TEXTURE0+a),t.bindTexture(WebGL2RenderingContext.TEXTURE_2D,this.parent.texture),di(t);const l=r.attribute("aDataValue");this.dataValuesBuffer.bindToVertexAttribI(l,1,WebGL2RenderingContext.UNSIGNED_BYTE),mn(t,pi,1),t.disableVertexAttribArray(l),t.bindTexture(WebGL2RenderingContext.TEXTURE_2D,null)}if(this.controlPointsPositionArray.length>0){const{renderViewport:o}=this;e.bind();const a=e.attribute("aLineStartEnd");this.linePositionBuffer.bindToVertexAttrib(a,4,WebGL2RenderingContext.FLOAT),vn(e,{width:o.logicalWidth,height:o.logicalHeight},1),mn(t,this.linePositionArray.length/(Ut*_f),1),t.disableVertexAttribArray(a),s.bind();const l=s.attribute("aVertexPosition");this.controlPointsVertexBuffer.bindToVertexAttrib(l,2,WebGL2RenderingContext.FLOAT);const c=s.attribute("aVertexColor");this.controlPointsColorBuffer.bindToVertexAttrib(c,3,WebGL2RenderingContext.FLOAT),t.drawArrays(t.POINTS,0,this.controlPointsPositionArray.length/2),t.disableVertexAttribArray(l),t.disableVertexAttribArray(c)}t.disable(WebGL2RenderingContext.BLEND)}update(){this.transferFunction.updateLookupTable(this.parent.trackable.value.window),this.updateTransferFunctionPointsAndLines()}isReady(){return!0}}function Yx(i,e){function t(r){const o=document.createElement("input");return o.addEventListener("focus",()=>{o.select()}),o.classList.add("neuroglancer-transfer-function-widget-bound"),o.type="text",o.spellcheck=!1,o.autocomplete="off",o.title=`${r===0?"Lower":"Upper"} window for transfer function`,o}const n=document.createElement("div");n.classList.add("neuroglancer-transfer-function-window-bounds");const s=[t(0),t(1)];for(let r=0;r<2;++r){const o=s[r];o.addEventListener("input",()=>{Ec(o)}),o.addEventListener("change",()=>{const a=e.value.window,l={range:a,window:a};try{const c=qt(i,o.value),d=Sr(l,"window",r,c,!0).window;if(d[0]===d[1])throw new Error("Window bounds cannot be equal");e.value={...e.value,window:d}}catch{br(o,a[r])}})}return n.appendChild(s[0]),n.appendChild(s[1]),{container:n,inputs:s}}const kc=Ae.fromObject({"shift?+mousedown0":{action:"add-or-drag-point"},"shift+dblclick0":{action:"remove-point"},"shift?+mousedown2":{action:"change-point-color"},"shift?+wheel":{action:"zoom-via-wheel"}});class Qx extends T.O8{constructor(e,t,n,s,r){super(),this.element=e,this.dataType=t,this.transferFunction=n,this.getModel=s,this.setModel=r,this.currentGrabbedControlPointIndex=-1,e.title=kc.describe(),this.registerDisposer(new tn(e,kc)),Z(e,"add-or-drag-point",o=>{const a=o.detail;this.updateValue(this.addControlPoint(a)),zt(a,l=>{this.updateValue(this.moveControlPoint(l))})}),Z(e,"remove-point",o=>{const a=o.detail,l=this.findControlPointIfNearCursor(a);l!==-1&&(this.transferFunction.removePoint(l),this.updateValue({...this.getModel(),sortedControlPoints:this.transferFunction.trackable.value.sortedControlPoints}))}),Z(e,"change-point-color",o=>{const a=o.detail,l=this.findControlPointIfNearCursor(a);if(l!==-1){const c=this.transferFunction.trackable.value.defaultColor,d=this.convertPanelSpaceColorToAbsoluteValue(c);this.transferFunction.updatePointColor(l,d),this.updateValue({...this.getModel(),sortedControlPoints:this.transferFunction.trackable.value.sortedControlPoints})}}),Z(e,"zoom-via-wheel",o=>{const a=o.detail,l=_i(a),c=this.getTargetFraction(a),{dataType:d}=this,u=this.getModel(),h=de(u.window,d,c*(1-l)),p=de(u.window,d,(1-c)*l+c);h!==p&&this.setModel({...u,window:[h,p]})})}getTargetFraction(e){const t=this.element.getBoundingClientRect();return(e.clientX-t.left)/t.width}updateValue(e){e!==void 0&&this.setModel(e)}convertPanelSpaceInputToAbsoluteValue(e){return de(this.transferFunction.trackable.value.window,this.dataType,e)}convertPanelSpaceColorToAbsoluteValue(e){return e.length===3?C.eR.fromValues(Math.round(e[0]*255),Math.round(e[1]*255),Math.round(e[2]*255)):C.ln.fromValues(Math.round(e[0]*255),Math.round(e[1]*255),Math.round(e[2]*255),Math.round(e[3]*255))}addControlPoint(e){const t=this.transferFunction.trackable.value.defaultColor,n=this.findControlPointIfNearCursor(e);if(n!==-1){this.currentGrabbedControlPointIndex=n;return}const s=this.getControlPointPosition(e);if(s===void 0)return;const{normalizedX:r,normalizedY:o}=s,a=C.ln.fromValues(t[0],t[1],t[2],o);return this.transferFunction.addPoint(new Ln(this.convertPanelSpaceInputToAbsoluteValue(r),this.convertPanelSpaceColorToAbsoluteValue(a))),this.currentGrabbedControlPointIndex=this.findControlPointIfNearCursor(e),{...this.getModel(),sortedControlPoints:this.transferFunction.trackable.value.sortedControlPoints}}moveControlPoint(e){if(this.currentGrabbedControlPointIndex!==-1){const t=this.getControlPointPosition(e);if(t===void 0)return;const{normalizedX:n,normalizedY:s}=t,r=this.transferFunction.trackable.value.sortedControlPoints.controlPoints[this.currentGrabbedControlPointIndex].outputColor;return r[3]=Math.round(s*255),this.currentGrabbedControlPointIndex=this.transferFunction.updatePoint(this.currentGrabbedControlPointIndex,new Ln(this.convertPanelSpaceInputToAbsoluteValue(n),r)),{...this.getModel(),sortedControlPoints:this.transferFunction.trackable.value.sortedControlPoints}}}getControlPointPosition(e){const t=this.element.getBoundingClientRect();let n=(e.clientX-t.left)/t.width,s=(t.bottom-e.clientY)/t.height;if(!(n<0||n>1||s<0||s>1))return n1-Go/3&&(n=1),s1-Go&&(s=1),{normalizedX:n,normalizedY:s}}findControlPointIfNearCursor(e){const{transferFunction:t}=this,{window:n}=t.trackable.value,s=t.sortedControlPoints.controlPoints.length;function r(S){return S<0||S>=s?null:re(n,t.sortedControlPoints.controlPoints[S].inputValue)}function o(S){return S<0||S>=s?null:t.sortedControlPoints.controlPoints[S].outputColor[3]/255}const a=this.getControlPointPosition(e);if(a===void 0)return-1;const l=a.normalizedX,c=a.normalizedY,d=t.findNearestControlPointIndex(l,n);if(d===-1)return-1;const u=r(d);if(Math.abs(l-u)>Rc)return-1;const h=[[d,Math.abs(o(d)-c)]],p=r(d+1);(p!==null?Math.abs(p-l):1/0)<=Rc&&h.push([d+1,Math.abs(o(d+1)-c)]);const g=r(d-1);return(g!==null?Math.abs(g-l):1/0)<=Rc&&h.push([d-1,Math.abs(o(d-1)-c)]),h.sort((S,w)=>S[1]-w[1])[0][0]}}class Kx extends Gt{constructor(e,t,n,s,r,o){super(e),this.display=t,this.dataType=n,this.trackable=s,this.histogramSpecifications=r,this.histogramIndex=o,this.transferFunctionPanel=this.registerDisposer(new jx(this)),this.window=Yx(this.dataType,this.trackable),this.registerDisposer(r.visibility.add(this.visibility));const{element:a}=this;a.classList.add("neuroglancer-transfer-function-widget"),a.appendChild(this.transferFunctionPanel.element),a.appendChild(this.window.container),this.window.container.dispatchEvent(new Event("change"));const l=document.createElement("div");l.classList.add("neuroglancer-transfer-function-color-picker");const c=this.registerDisposer(new hi((0,_.Uq)(d=>d.defaultColor,[s]),()=>C.eR.fromValues(1,1,1)));c.element.title="Transfer Function Color Picker",c.element.id="neuroglancer-tf-color-widget",c.element.addEventListener("change",()=>{s.value={...this.trackable.value,defaultColor:c.model.value}}),c.element.addEventListener("input",()=>{s.value={...this.trackable.value,defaultColor:c.model.value}}),l.appendChild(c.element),a.appendChild(l),this.updateControlPointsAndDraw(),this.registerDisposer(this.trackable.changed.add(()=>{this.updateControlPointsAndDraw()}))}get texture(){return this.histogramSpecifications.getFramebuffers(this.display.gl)[this.histogramIndex].colorBuffers[0].texture}updateView(){for(let e=0;e<2;++e)br(this.window.inputs[e],this.trackable.value.window[e]);this.transferFunctionPanel.scheduleRedraw()}updateControlPointsAndDraw(){this.transferFunctionPanel.update(),this.updateView()}}function qx(i,e,t,n){i.addUniform("highp float",`uTransferFunctionEnd_${e}`),i.addTextureSampler("sampler2D",`uTransferFunctionSampler_${e}`,`TransferFunction.${e}`);const s=Ss(i,e,t,!0),r=yt(t);let o=` +vec4 ${e}_(float inputValue) { + int index = clamp(int(round(inputValue * uTransferFunctionEnd_${e})), 0, int(uTransferFunctionEnd_${e})); + return texelFetch(uTransferFunctionSampler_${e}, ivec2(index, 0), 0); +} +vec4 ${e}(${r} inputValue) { + float v = computeInvlerp(inputValue, uLerpParams_${e}); + defaultMaxProjectionIntensity = v; + return v < 0.0 ? vec4(0.0, 0.0, 0.0, 0.0) : ${e}_(clamp(v, 0.0, 1.0)); +} +vec4 ${e}() { + return ${e}(getDataValue(${n.join(",")})); +} +`;if(t!==R.UINT64&&t!==R.FLOAT32){const a=ae[t]?"int":"uint";o+=` +vec4 ${e}(${a} inputValue) { + return ${e}(${r}(inputValue)); +} +`}return[s[0],s[1],s[2],o]}function Xx(i,e,t,n,s=Ff[t]){const{gl:r}=i;i.transferFunctionTextures.get(`TransferFunction.${e}`)===void 0&&i.transferFunctionTextures.set(`TransferFunction.${e}`,new Jx(r));const a=i.bindAndUpdateTransferFunctionTexture(`TransferFunction.${e}`,n,t,s);if(a===void 0)throw new Error("Failed to create transfer function texture");r.uniform1f(i.uniform(`uTransferFunctionEnd_${e}`),a-1);const l=n.range;Ni(i,e,t,l)}function Zx(i,e){i.bindInputEventMap(kc)}function eE(i){return{makeControl:(e,t,n)=>{const{watchableValue:s,channelCoordinateSpaceCombiner:r,defaultChannel:o,histogramSpecifications:a,histogramIndex:l,dataType:c}=i(e);if(r!==void 0&&o.length!==0){const u=t.registerDisposer(new ui(r.combined)),h=t.registerDisposer(new xs(u,r,{copyButton:!1}));t.registerDisposer(u.changed.add(()=>{const m=u.value,g=Array.from(m,y=>Math.floor(y)),v=s.value;(0,F.r1)(v.channel,g)||(s.value={...s.value,channel:g})}));const p=()=>{const m=u.value,g=s.value;(0,F.r1)(g.channel,m)||(m.set(g.channel),u.changed.dispatch())};p(),t.registerDisposer(s.changed.add(p)),n.labelContainer.appendChild(h.element)}const d=t.registerDisposer(new Kx(n.visibility,n.display,c,s,a,l));return{control:d,controlElement:d.element}},activateTool:(e,t)=>{Zx(e,t)}}}/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function tE(i){const e=/\/\/.*?$|\/\*(?:.|\n)*?\*\/|'(?:\\.|[^\\'])*'|"(?:\\.|[^\\"])*"/gm;return i.replace(e,t=>t.startsWith("/")?t.replace(/[^\s]/g," "):t)}function nE(i){const e=/^(?:-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?|"(?:\\.|[^\\"])*"|true|false|:|\s+|,|\[|\]|\{|\})/;let t=0;const n=i;e:for(;i.length;){const s=i.match(e);if(s===null)break;const r=s[0];switch(r.charAt(0)){case"[":case"{":++t;break;case"]":case"}":if(--t<0)return-1;break;case",":if(t===0)break e;break;default:if(t===0){i=i.substring(r.length);break e}break}i=i.substring(r.length)}return t!==0?-1:n.length-i.length}function iE(i){const e=[],t=new Map;if(i===void 0)return{errors:e,parameters:t};const n=/^([_a-z][_a-zA-Z0-9]*)[ \t]*=/;for(;i=i.trim(),i.length!==0;){const s=i.match(n);if(s===null){e.push("Invalid #uicontrol parameter syntax, expected: =, ...");break}const r=s[1];i=i.substring(s[0].length);const o=nE(i);if(o<=0){e.push("Invalid #uicontrol parameter syntax, expected: =, ...");break}let a;try{a=JSON.parse(i.substring(0,o))}catch{e.push(`Invalid #uicontrol parameter value for ${r}: ${a}`);break}t.has(r)?e.push(`Duplicate #uicontrol parameter: ${r}`):t.set(r,a),i=i.substring(o),i=i.trim(),i.length>0&&!i.startsWith(",")&&e.push("Invalid #uicontrol parameter syntax, expected: =, ..."),i=i.substring(1)}return{parameters:t,errors:e}}function sE(i,e){let t,n,s,r;const o=[];i!=="float"&&i!=="uint"&&i!=="int"&&o.push("type must be float, int, or uint");for(const[a,l]of e){const c=()=>{if(typeof l!="number"){o.push(`Expected ${a} argument to be a number`);return}return(i==="int"||i==="uint")&&(Number.isInteger(l)||o.push(`Expected ${a} argument to be an integer`),i==="uint"&&l<0&&o.push(`Expected ${a} argument to be an unsigned integer`)),l};a==="min"?t=c():a==="max"?n=c():a==="default"?r=c():a==="step"?s=c():o.push(`Invalid parameter: ${a}`)}return t===void 0&&o.push("min must be specified"),n===void 0&&o.push("max must be specified"),t!==void 0&&n!==void 0&&(t>n&&o.push("min must be less than max"),s===void 0&&(i==="float"?s=(n-t)/100:s=1),r!==void 0?(rn)&&o.push("default must be within valid range"):i==="float"?r=(t+n)/2:r=t),o.length>0?{errors:o}:{control:{type:"slider",valueType:i,min:t,max:n,step:s,default:r},errors:void 0}}function rE(i,e){let t=!1;const n=[];i!=="bool"&&n.push("type must be bool");for(const[s,r]of e)if(s==="default"){if(typeof r!="boolean"){n.push(`Expected ${s} argument to be a boolean`);continue}t=r}else n.push(`Invalid parameter: ${s}`);return n.length>0?{errors:n}:{control:{type:"checkbox",valueType:i,default:t},errors:void 0}}function oE(i,e){let t="white";const n=[];i!=="vec3"&&n.push("type must be vec3");for(const[s,r]of e)s==="default"?typeof r!="string"?n.push("Expected default argument to be a string"):t=r:n.push(`Invalid parameter: ${s}`);return n.length>0?{errors:n}:{control:{type:"color",valueType:i,defaultString:t,default:me(t)},errors:void 0}}function Wo(i,e){typeof i=="number"&&(i=[i]);const t=new Array(e);return(0,f.Xu)(t,i,n=>{if(!Number.isInteger(n)||n<0)throw new Error(`Expected non-negative integer, but received: ${JSON.stringify(n)}`);return n}),t}function aE(i,e,t){const{imageData:n,properties:s}=t;if(n!==void 0)return lE(i,e,n);if(s!==void 0)return cE(i,e,s);const r=[];return r.push("invlerp control not supported"),{errors:r}}function lE(i,e,t){const n=[];i!=="invlerp"&&n.push("type must be invlerp");let s=new Array(t.channelRank).fill(0);const{dataType:r}=t;let o=!0,a=he[r],l;for(const[c,d]of e)try{switch(c){case"range":{a=Lt(d,r);break}case"window":{l=et(Lt(d,r));break}case"clamp":{typeof d!="boolean"?n.push(`Invalid clamp value: ${JSON.stringify(d)}`):o=d;break}case"channel":{s=Wo(d,s.length);break}default:n.push(`Invalid parameter: ${c}`);break}}catch(u){n.push(`Invalid ${c} value: ${u.message}`)}return n.length>0?{errors:n}:{control:{type:"imageInvlerp",dataType:r,clamp:o,default:{range:a,window:l??st(a),channel:s}},errors:void 0}}function cE(i,e,t){const n=[];i!=="invlerp"&&n.push("type must be invlerp");let s=!0,r,o,a;for(const[c,d]of e)try{switch(c){case"range":{r=Ii(d);break}case"window":{o=Ii(d);break}case"clamp":{typeof d!="boolean"?n.push(`Invalid clamp value: ${JSON.stringify(d)}`):s=d;break}case"property":{const u=(0,f.zr)(d);if(!t.has(u))throw new Error(`Property not defined: ${JSON.stringify(a)}`);a=u;break}default:n.push(`Invalid parameter: ${c}`);break}}catch(u){n.push(`Invalid ${c} value: ${u.message}`)}if(n.length>0)return{errors:n};if(a===void 0)for(const c of t.keys()){a=c;break}const l=t.get(a);return r!==void 0&&(r=Ce(r,l)),o!==void 0&&(o=Ce(o,l)),{control:{type:"propertyInvlerp",clamp:s,properties:t,default:{range:r,window:o,property:a,dataType:l}},errors:void 0}}function dE(i,e,t){const n=t.imageData,s=n?.dataType,r=n?.channelRank,o=[];let a=new Array(r).fill(0),l=C.eR.fromValues(1,1,1),c,d=new zo([],s!==void 0?s:R.FLOAT32),u=!1;i!=="transferFunction"&&o.push("type must be transferFunction"),s===void 0&&o.push("image data must be provided to use a transfer function");for(const[h,p]of e)try{switch(h){case"channel":{a=Wo(p,a.length);break}case"defaultColor":{l=me(p);break}case"window":{s!==void 0&&(c=et(Lt(p,s)));break}case"controlPoints":{u=!0,s!==void 0&&(d=zf(p,s));break}default:o.push(`Invalid parameter: ${h}`);break}}catch(m){o.push(`Invalid ${h} value: ${m.message}`)}if(c===void 0&&(c=d.range),d.length===0&&!u&&s!==void 0){const h=de(c,s,.4),p=de(c,s,.7);d.addPoint(new Ln(h,C.yb)),d.addPoint(new Ln(p,C.ln.fromValues(255,255,255,255)))}return o.length>0?{errors:o}:{control:{type:"transferFunction",dataType:s,default:{sortedControlPoints:d,channel:a,defaultColor:l,window:c}},errors:void 0}}const uE=new Map([["slider",sE],["color",oE],["invlerp",aE],["checkbox",rE],["transferFunction",dE]]);function Er(i,e={}){i=tE(i);const t=/^[ \t]*#[ \t]*uicontrol[ \t]+(.*)$/gm,n=/^([_a-zA-Z][_a-zA-Z0-9]*)[ \t]+([a-z][a-zA-Z0-9_]*)(?:[ \t]+([a-z]+))?[ \t]*(?:\([ \t]*(.*)\)[ \t]*)?/,s=[],r=new Map,o=i.replace(t,(a,l,c)=>{const d=l.match(n),u=()=>Math.max(0,i.substring(0,c).split(` +`).length-1);if(d===null)return s.push({line:u(),message:"Invalid #uicontrol syntax, expected: #uicontrol (=, ...)"}),"";const h=d[1],p=d[2],m=d[3]??h,g=d[4],{parameters:v,errors:y}=iE(g);for(const b of y)s.push({line:u(),message:b});if(r.has(p)&&s.push({line:u(),message:`Duplicate definition for control ${p}`}),y.length>0)return"";const S=uE.get(m);if(S===void 0)return s.push({line:u(),message:`Invalid control type ${m}`}),"";const w=S(h,v,e);if(w.errors!==void 0){for(const b of w.errors)s.push({line:u(),message:b});return""}return r.set(p,w.control),""});return{source:i,code:o,errors:s,controls:r}}function $f(i){return`u_shaderControl_${i}`}function Ts(i,e){const{builderValues:t}=i;for(const[n,s]of i.parseResult.controls){const r=$f(n),o=t[n];switch(s.type){case"imageInvlerp":{const a=[Ss(e,r,s.dataType,s.clamp),` +float ${r}() { + return ${r}(getDataValue(${o.channel.join(",")})); +} +`];e.addFragmentCode(a),e.addFragmentCode(`#define ${n} ${r} +`);break}case"propertyInvlerp":{const a=o.property,l=s.properties.get(a),c=[Ss(e,r,l,s.clamp),` +float ${r}() { + return ${r}(prop_${a}()); +} +`];e.addVertexCode(c),e.addVertexCode(`#define ${n} ${r} +`);break}case"checkbox":{const a=`#define ${n} ${o.value} +`;e.addFragmentCode(a),e.addVertexCode(a);break}case"transferFunction":{e.addFragmentCode(`#define ${n} ${r} +`),e.addFragmentCode(qx(e,r,s.dataType,o.channel));break}default:{e.addUniform(`highp ${s.valueType}`,r),e.addVertexCode(`#define ${n} ${r} +`),e.addFragmentCode(`#define ${n} ${r} +`);break}}}}function hE(i){const e={};for(const[t,n]of i)e[t]=n;return e}function pE(i,e){return e instanceof Map?Array.from(e.entries()):e}function Gf(i){if(i!==void 0)return JSON.stringify(hE(i),pE)}class fE{constructor(){this.changed=new j.IY,this.controls=void 0}get value(){return this.controls}set value(e){Gf(e)!==Gf(this.controls)&&(this.controls=e,this.changed.dispatch())}}function gE(i,e,t){return i===void 0?t:((0,f.Rf)(i),{range:(0,f.MM)(i,"range",n=>Lt(n,e),t.range),window:(0,f.MM)(i,"window",n=>et(Lt(n,e)),t.window),channel:(0,f.MM)(i,"channel",n=>Wo(n,t.channel.length),t.channel)})}class mE extends _.DN{constructor(e,t){super(t,n=>gE(n,e,t)),this.dataType=e,this.defaultValue=t}toJSON(){const{value:{range:e,window:t,channel:n},dataType:s,defaultValue:r}=this,o=A(e,s,r.range),a=A(t,s,r.window),l=(0,F.r1)(r.channel,n)?void 0:n;if(!(o===void 0&&a===void 0&&l===void 0))return{range:o,window:a,channel:l}}}function vE(i,e,t){if(i===void 0)return t;(0,f.Rf)(i);const n=(0,f.MM)(i,"property",r=>{if(r=(0,f.zr)(r),!e.has(r))throw new Error(`Invalid value: ${JSON.stringify(r)}`);return r},t.property),s=e.get(n);return{property:n,dataType:s,range:(0,f.MM)(i,"range",r=>Lt(r,s),t.range),window:(0,f.MM)(i,"window",r=>et(Lt(r,s)),t.window)}}class yE extends _.DN{constructor(e,t){super(t,n=>vE(n,e,t)),this.properties=e,this.defaultValue=t}toJSON(){const{value:{range:e,window:t,property:n,dataType:s},defaultValue:r}=this,o=he[s],a=A(e??o,s,r.range??o),l=A(t??o,s,r.window??o),c=n===r.property?void 0:n;if(!(a===void 0&&l===void 0&&c===void 0))return{range:a,window:l,property:c}}}function zf(i,e){const t=(0,f.$v)(i,n=>{const s=e===R.UINT64&&typeof n[0]=="string"||typeof n[0]=="number";if(n.length!==3||!s||typeof n[1]!="string"||typeof n[2]!="number")throw new Error(`Expected array of length 3 (x, "#RRGGBB", A), but received: ${JSON.stringify(n)}`);const r=qt(e,n[0]);if(n[1].length!==7||n[1][0]!=="#")throw new Error(`Expected #RRGGBB, but received: ${JSON.stringify(n[1])}`);if(n[2]<0||n[2]>1)throw new Error(`Expected opacity in range [0, 1], but received: ${JSON.stringify(n[2])}`);const o=me(n[1]);function a(l){return Math.min(255,Math.max(Math.round(l*255),0))}return new Ln(r,C.ln.fromValues(a(o[0]),a(o[1]),a(o[2]),a(n[2])))});return new zo(t,e)}function SE(i,e,t){if(i===void 0)return t;(0,f.Rf)(i);const n=(0,f.MM)(i,"controlPoints",r=>zf(r,e),t.sortedControlPoints),s=(0,f.MM)(i,"window",r=>Lt(r,e),t.window);return{sortedControlPoints:n,channel:(0,f.MM)(i,"channel",r=>Wo(r,t.channel.length),t.channel),defaultColor:(0,f.MM)(i,"defaultColor",r=>me(r),t.defaultColor),window:s}}function bE(i){return{...i,sortedControlPoints:i.sortedControlPoints.copy()}}class CE extends _.DN{constructor(e,t){const n=bE(t);super(n,s=>SE(s,e,n)),this.dataType=e,this.defaultValue=t}controlPointsToJson(e,t){function n(s){return t===R.UINT64?s.toJSON():s}return e.map(s=>[n(s.inputValue),Ge(C.eR.fromValues(s.outputColor[0]/255,s.outputColor[1]/255,s.outputColor[2]/255)),s.outputColor[3]/255])}toJSON(){const{value:{channel:e,sortedControlPoints:t,defaultColor:n,window:s},dataType:r,defaultValue:o}=this,a=A(s,r,o.window),l=(0,F.r1)(o.channel,e)?void 0:e,c=(0,F.r1)(o.defaultColor,n)?void 0:Ge(n),d=(0,F.wm)(o.sortedControlPoints.controlPoints,t.controlPoints,(u,h)=>(0,F.r1)(u.outputColor,h.outputColor)&&u.inputValue===h.inputValue)?void 0:this.controlPointsToJson(t.controlPoints,r);if(!(l===void 0&&c===void 0&&d===void 0&&a===void 0))return{channel:l,defaultColor:c,controlPoints:d,window:a}}}function Wf(i){switch(i.type){case"slider":return{trackable:new _.DN(i.default,e=>{let t;if(i.valueType==="float"?t=(0,f.zo)(e):t=(0,f.bX)(e),ti.max)throw new Error(`${JSON.stringify(e)} is outside valid range [${i.min}, ${i.max}]`);return t}),getBuilderValue:()=>null};case"color":return{trackable:new q(i.default),getBuilderValue:()=>null};case"imageInvlerp":return{trackable:new mE(i.dataType,i.default),getBuilderValue:e=>({channel:e.channel,dataType:i.dataType})};case"propertyInvlerp":return{trackable:new yE(i.properties,i.default),getBuilderValue:e=>({property:e.property,dataType:e.dataType})};case"checkbox":return{trackable:new nt(i.default),getBuilderValue:e=>({value:e})};case"transferFunction":return{trackable:new CE(i.dataType,i.default),getBuilderValue:e=>({channel:e.channel,dataType:i.dataType})}}}function Hf(i,e){return JSON.stringify(i)+"\0"+e.source}function Ho(i){const e={},t=[];for(const[n,s]of i.controls){const{trackable:r,getBuilderValue:o}=Wf(s),a=o(r.value);e[n]=a,s.type==="propertyInvlerp"&&t.push(a.property)}return{builderValues:e,parseResult:i,key:Hf(e,i),referencedProperties:t}}class Jo extends T.O8{constructor(e,t=(0,_.XZ)({}),n){super(),this.fragmentMain=e,this.dataContext=t,this.channelCoordinateSpaceCombiner=n,this.changed=new j.IY,this.controls=new fE,this.fragmentMainGeneration=-1,this.dataContextGeneration=-1,this.parseErrors_=[],this.processedFragmentMain_="",this.controlsGeneration=-1,this.parseResultChanged=new j.IY,this.state_=new Map,this.unparsedJson=void 0,this.registerDisposer(e.changed.add(()=>this.handleFragmentMainChanged())),this.registerDisposer(this.controls.changed.add(()=>this.handleControlsChanged())),this.registerDisposer(this.dataContext.changed.add(()=>this.handleFragmentMainChanged())),this.handleFragmentMainChanged();const s=this;this.parseErrors={changed:this.parseResultChanged,get value(){return s.handleFragmentMainChanged(),s.parseErrors_}},this.processedFragmentMain={changed:this.parseResultChanged,get value(){return s.handleFragmentMainChanged(),s.processedFragmentMain_}},this.parseResult={changed:this.parseResultChanged,get value(){return s.parseResult_}},this.builderState=(0,_.Uq)((l,c)=>{const d={},u=[];for(const[h,{control:p,trackable:m,getBuilderValue:g}]of c){const v=g(m.value);d[h]=v,p.type==="propertyInvlerp"&&u.push(v.property)}return{key:Hf(d,l),parseResult:l,builderValues:d,referencedProperties:u}},[this.parseResult,this],(l,c)=>l.key===c.key);const r=(0,_.Uq)(l=>{const c=[];for(const{control:d,trackable:u}of l.values())d.type!=="imageInvlerp"&&d.type!=="transferFunction"||c.push({channel:u.value.channel});return c},[this],(l,c)=>(0,F.wm)(l,c,(d,u)=>(0,F.r1)(d.channel,u.channel))),o=(0,_.Uq)(l=>{const c=[];for(const{control:d,trackable:u}of l.values())d.type==="propertyInvlerp"&&c.push(u.value.property);return c},[this],F.r1),a=(0,_.ol)(l=>{const c=[];for(const{control:d,trackable:u}of l.values())if(d.type==="imageInvlerp"||d.type==="transferFunction")c.push(u.value.window);else if(d.type==="propertyInvlerp"){const{dataType:h,range:p,window:m}=u.value;c.push(m??p??he[h])}return c},this);this.histogramSpecifications=this.registerDisposer(new Np(r,o,a))}handleFragmentMainChanged(){const e=this.fragmentMain.changed.count,t=this.dataContext.changed.count;if(e===this.fragmentMainGeneration&&t===this.dataContextGeneration)return;this.fragmentMainGeneration=e,this.dataContextGeneration=t;const n=this.dataContext.value;if(n===null)this.parseResult_={source:"",code:"",controls:new Map,errors:[{line:0,message:"Loading"}]},this.parseErrors_=[],this.processedFragmentMain_="",this.controls.value=void 0;else{const s=this.parseResult_=Er(this.fragmentMain.value,n);this.parseErrors_=s.errors,this.processedFragmentMain_=s.code,s.errors.length===0&&(this.controls.value=s.controls)}this.parseResultChanged.dispatch()}handleControlsChanged(){const e=this.controls.changed.count;if(e===this.controlsGeneration)return;this.controlsGeneration=e;const t=this.controls.value;if(t===void 0)return;let n=!1;const{state_:s,unparsedJson:r}=this;for(const[o,a]of s)t.get(o)===void 0&&(a.trackable.changed.remove(this.changed.dispatch),s.delete(o),n=!0);for(const[o,a]of t){let l=s.get(o);if(l!==void 0&&JSON.stringify(l.control)!==JSON.stringify(a)&&(l.trackable.changed.remove(this.changed.dispatch),l=void 0),l===void 0){const{trackable:c,getBuilderValue:d}=Wf(a);l={control:a,trackable:c,getBuilderValue:d},l.trackable.changed.add(this.changed.dispatch),s.set(o,l),n=!0}if(r!==void 0&&Object.prototype.hasOwnProperty.call(r,o)){n=!0;try{l.trackable.restoreState(r[o])}catch{}}}r!==void 0&&(n=!0),this.unparsedJson=void 0,n&&this.changed.dispatch()}get state(){return this.controls.changed.count!==this.controlsGeneration&&this.handleControlsChanged(),this.state_}get value(){return this.state}restoreState(e){if(e===void 0)return;const{state:t}=this;if((0,f.Rf)(e),this.controls.value===void 0){this.unparsedJson=e,this.changed.dispatch();return}for(const[s,r]of t){const{trackable:o}=r;if(o.reset(),Object.prototype.hasOwnProperty.call(e,s))try{o.restoreState(e[s])}catch{}}this.unparsedJson=void 0}reset(){for(const e of this.state.values())e.trackable.reset();this.unparsedJson!==void 0&&(this.unparsedJson=void 0,this.changed.dispatch())}toJSON(){const{state:e}=this,{unparsedJson:t}=this;if(t!==void 0)return t;const n={};let s=!0;for(const[r,o]of e){const a=o.trackable.toJSON();a!==void 0&&(n[r]=a,s=!1)}if(!s)return n}}function Jf(i,e,t,n,s){const r=$f(t),o=e.uniform(r);switch(n.type){case"slider":switch(n.valueType){case"int":case"uint":i.uniform1i(o,s);break;case"float":i.uniform1f(o,s)}break;case"color":i.uniform3fv(o,s);break;case"imageInvlerp":Ni(e,r,n.dataType,s.range);break;case"propertyInvlerp":{const{dataType:a}=s;Ni(e,r,a,s.range??he[a]);break}case"checkbox":break;case"transferFunction":Xx(e,r,n.dataType,s.sortedControlPoints)}}function vi(i,e,t,n){const{state:s}=t;if(t.controls.value===n)for(const[r,o]of s)Jf(i,e,r,o.control,o.trackable.value);else for(const[r,o]of n){const a=s.get(r),l=a!==void 0&&JSON.stringify(a.control)===JSON.stringify(o)?a.trackable.value:o.default;Jf(i,e,r,o,l)}}/** + * @license + * Copyright 2018 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class wE extends _.B0{}class xE extends rc{constructor(){super((e,{showMatches:t,segmentationState:n})=>{e.registerDisposer(t.changed.add(this.changed.dispatch)),e.registerDisposer(n.changed.add(this.changed.dispatch)),e.registerDisposer((0,_.no)((s,r)=>{if(r==null)return;const{segmentationGroupState:o}=r;s.registerDisposer(o.changed.add(this.changed.dispatch)),s.registerDisposer((0,_.no)((a,l)=>{const{visibleSegments:c}=l;let d=c.size===0;a.registerDisposer(c.changed.add(()=>{const u=c.size===0;u!==d&&(d=u,this.changed.dispatch())}))},o))},n))})}get(e){let t=super.get(e);return t===void 0&&(t={segmentationState:new _.B0(void 0),showMatches:new nt(!1)},super.set(e,t)),t}}const jf=` +void main() { + setColor(defaultColor()); +} +`;class Yf extends T.O8{constructor(){super(...arguments),this.annotationProperties=new _.B0(void 0),this.shader=Co(jf),this.shaderControls=new Jo(this.shader,(0,_.ol)(e=>{const t=new Map;if(e===void 0)return null;for(const n of e){const s=kl[n.type];s!==void 0&&t.set(n.identifier,s)}return{properties:t}},this.annotationProperties)),this.fallbackShaderControls=new _.B0(Ho(Er(jf))),this.shaderError=dr(),this.color=new q(C.eR.fromValues(1,1,0)),this.relationshipStates=this.registerDisposer(new xE),this.ignoreNullSegmentFilter=new nt(!0),this.swapVisibleSegmentsOnMove=new nt(!0),this.disablePicking=new _.B0(!1),this.displayUnfiltered=(0,_.ol)((e,t)=>{for(const n of e.values())if(n.showMatches.value){if(!t)return!1;const s=n.segmentationState.value;if(s!=null&&s.segmentationGroupState.value.visibleSegments.size>0)return!1}return!0},this.relationshipStates,this.ignoreNullSegmentFilter),this.hoverState=new wE(void 0)}}class jo extends T.O8{constructor(e){super();const{transform:t,localPosition:n,source:s,role:r=li.ANNOTATION}=e;this.transform=t,this.localPosition=n,this.source=this.registerDisposer(s),this.role=r,this.displayState=e.displayState,this.chunkTransform=this.registerDisposer((0,_.ol)(o=>bo(()=>po(sc(o))),this.transform)),this.dataSource=e.dataSource,this.subsourceId=e.subsourceId,this.subsourceIndex=e.subsourceIndex,this.subsubsourceId=e.subsubsourceId}get sourceIndex(){const{dataSource:e}=this;return e.layer.dataSources.indexOf(e)}}var Qf=G(9459);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const Yo=!1,EE=!1,TE=C.pB.create();function DE(i,e){let t=0,n=Math.abs(i.detTransform);const{transform:s,size:r}=i;for(let o=0;o<3;++o){let a=0;for(let c=0;c<3;++c)a+=e[c*4+2]*s[4*o+c];const l=r[o];t+=Math.abs(a)*l,n*=l}return n/t}function Kf(i,e,t){const{curPositionInChunks:n,fixedPositionWithinChunk:s}=i,{nonDisplayLowerClipBound:r,nonDisplayUpperClipBound:o}=i,{rank:a,chunkDataSize:l}=i.source.spec;if(!gs(n,e,t,i.layerRank,i.fixedLayerToChunkTransform))return!1;for(let c=0;c=o[c])return Yo&&console.log("excluding source",i,`because of chunkDim=${c}, sum=${d}`,r,o,i.fixedLayerToChunkTransform),!1;const u=l[c],h=n[c]=Math.floor(d/u);s[c]=d-h*u}return!0}function IE(i,e){const t=e.length;let n=0;if(Yo&&console.log(e),t>1){let s=0;for(let r=0;rs&&(s=l,n=r)}}return n}const Ds=new Qf.i(C.eR.create(),C.pB.create(),0);class LE extends op{constructor(){super(...arguments),this.viewportNormalInGlobalCoordinates=C.eR.create(),this.viewportNormalInCanonicalCoordinates=C.eR.create(),this.centerDataPosition=C.eR.create(),this.pixelSize=0}}function RE(i,e){if(i.displayDimensionRenderInfo!==e.displayDimensionRenderInfo||i.pixelSize!==e.pixelSize)return!0;const{viewMatrix:t}=i,{viewMatrix:n}=e;for(let s=0;s<12;++s)if(t[s]!==n[s])return!0;return!1}class kE extends hn{constructor(e){super(),this.projectionParameters=e,this.visibleLayers=new Map,this.visibleSourcesStale=!0,this.registerDisposer(e.changed.add((t,n)=>{RE(t,n)&&this.invalidateVisibleSources(),this.invalidateVisibleChunks()}))}invalidateVisibleSources(){this.visibleSourcesStale=!0}invalidateVisibleChunks(){}updateVisibleSources(){if(!this.visibleSourcesStale)return;this.visibleSourcesStale=!1;const e=this.projectionParameters.value.displayDimensionRenderInfo,{visibleLayers:t}=this;for(const[n,s]of t){const{allSources:r,visibleSources:o}=s;if(o.length=0,r.length===0||!qw(s,e))continue;const a=IE(this.projectionParameters.value.viewMatrix,r.map(c=>c[0])),l=r[a];for(const c of n.filterVisibleSources(this,l))o.push(c);o.reverse(),Yo&&console.log("visible sources chosen",o)}}}const PE=18;function Qo(i){let{rank:e,upperVoxelBound:t,maxVoxelsPerChunkLog2:n=PE,chunkToViewTransform:s,displayRank:r,minBlockSize:o,maxBlockSize:a}=i;const{lowerVoxelBound:l=new Uint32Array(e)}=i,c=new Float32Array(e);for(let p=0;p=u[g])continue;const v=d[g]*c[g];v3)throw new Error("Unsupported view transform");if(t<3)return[Qo(i)];for(let r=0;r<3;++r){const o=(r+2)%3,a=new Float32Array(n);for(let l=0;l(i[i.ISOTROPIC=0]="ISOTROPIC",i[i.FLAT=1]="FLAT",i))(qf||{});function zV(i,e,t){return t===void 0?e:matrix.multiply(new Float32Array((i+1)*(i+1)),i+1,e,i+1,t,i+1,i+1,i+1,i+1)}function ME(i){if(i.chunkDataSizes!==void 0)return i.chunkDataSizes;const{chunkLayoutPreference:e=0}=i;switch(e){case 0:return[Qo(i)];case 1:return AE(i)}}function Ko(i){const{rank:e,chunkDataSize:t,upperVoxelBound:n}=i,{lowerVoxelBound:s=new Float32Array(e)}=i,r=new Float32Array(e),o=new Float32Array(e);for(let a=0;a{const u=n*r;for(let h=0;h<3;++h){const p=d[h];if(p>u&&p>1.01*s[h])return!0}return!1},a=(d,u)=>{const h=n*r;for(let p=0;p<3;++p){const m=d[p],g=u[p];if(Math.abs(h-m)h&&(h=S,u=y)}if(p===0)return;if(p===1){l[c[0]]=s[0],l[c[1]]=s[1],l[c[2]]=s[2],t(s,i);return}const m=s[u],g=r[u],v=Math.floor(.5*(m+g));r[u]=v,d(),r[u]=g,s[u]=v,d(),s[u]=m}d()}function tg(i,e,t,n){if(!Kf(t,i.globalPosition,e))return;const{size:s}=t.chunkLayout,r=C.pB.multiply(Xf,i.viewProjectionMat,t.chunkLayout.transform);for(let c=0;c<3;++c){const d=s[c];for(let u=0;u<4;++u)r[4*c+u]*=d}const o=Zf;(0,C._S)(o,r);const a=Pc,l=Ac;a.fill(Number.NEGATIVE_INFINITY),l.fill(Number.POSITIVE_INFINITY),eg(o,t,n,C.T_)}function UE(i,e,t,n,s){if(!Kf(t,i.globalPosition,e))return;const{size:r}=n,o=C.pB.multiply(Xf,i.viewProjectionMat,n.transform);for(let h=0;h<3;++h){const p=r[h];for(let m=0;m<4;++m)o[4*h+m]*=p}const a=TE;C.pB.invert(a,o);const l=Pc,c=Ac,d=.001;for(let h=0;h<3;++h){const p=a[12+h]+d/r[h],m=Math.abs(a[h]),g=Math.abs(a[4+h]);l[h]=Math.floor(p-m-g),c[h]=Math.floor(p+m+g+1)}const u=Zf;for(let h=0;h<3;++h){const p=o[4*h],m=o[4*h+1],g=o[4*h+2];u[h]=p,u[4+h]=-p,u[8+h]=+m,u[12+h]=-m,u[16+h]=+g,u[20+h]=-g}{const p=o[12],m=o[4*3+1],g=o[4*3+2];u[3]=1+p,u[7]=1-p,u[11]=1+m,u[15]=1-m,u[19]=g,u[23]=-g}EE&&(console.log("clippingPlanes",u),console.log("modelViewProjection",o.join(",")),console.log(`lower=${l.join(",")}, upper=${c.join(",")}`)),eg(u,t,s,C.qp)}function Mc(i,e){const{finiteRank:t}=e;if(t===3)return e;Ds.finiteRank=t,C.eR.copy(Ds.size,e.size);const n=C.pB.copy(Ds.transform,e.transform),s=C.pB.copy(Ds.invTransform,e.invTransform);Ds.detTransform=e.detTransform;const{invViewMatrix:r,width:o,height:a}=i,l=(0,C.sJ)(i.projectionMat);for(let c=t;c<3;++c){const d=r[12+c];let u=d,h=d;const p=Math.abs(r[c]*o);u-=p,h+=p;const m=Math.abs(r[c+4]*a);u-=m,h+=m;const g=Math.abs(r[c+8]*l);u-=g,h+=g;const v=Math.max(1,h-u);n[12+c]=u,n[5*c]=v}return C.pB.invert(s,n),Ds}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const $E="annotation.MetadataChunkSource",GE="annotation.GeometryChunkSource",zE="annotation.SubsetGeometryChunkSource",WE="annotation.reference.add",HE="annotation.reference.delete",JE="annotation.commit",jE="annotation.commit",YE="annotation/SpatiallyIndexedRenderLayer",QE="annotation/PerspectiveRenderLayer:updateSources",KE="annotation/RenderLayer",qE="annotation/RenderLayer.updateSegmentation",XE=C.w0.create();function ng(i,e,t,n,s,r){const{displayDimensionRenderInfo:o,viewMatrix:a,projectionMat:l,width:c,height:d}=i,{voxelPhysicalScales:u}=o,h=Math.abs(C.w0.determinant((0,C._A)(XE,a))),p=(0,C.xK)(u),m=(0,C.I1)(l)/h*p;if(n.length===0)return;const g=n[0];let v=Math.abs(g.chunkLayout.detTransform)*p;const{lowerClipDisplayBound:y,upperClipDisplayBound:S}=g;for(let I=0;I<3;++I)v*=S[I]-y[I];const w=Math.min(v,m),b=c*d,E=b/t**2/w;let D=0;for(let I=n.length-1;I>=0&&D{oe&&(s(L,I),oe=!1),r(L,I,we,Ke,$e)}),D=Se}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const Is=`vec3 colormapJet(float x) { + vec3 result; + result.r = x < 0.89 ? ((x - 0.35) / 0.31) : (1.0 - (x - 0.89) / 0.11 * 0.5); + result.g = x < 0.64 ? ((x - 0.125) * 4.0) : (1.0 - (x - 0.64) / 0.27); + result.b = x < 0.34 ? (0.5 + x * 0.5 / 0.11) : (1.0 - (x - 0.34) / 0.31); + return clamp(result, 0.0, 1.0); +} +vec3 colormapCubehelix(float x) { + float xclamp = clamp(x, 0.0, 1.0); + float angle = 2.0 * 3.1415926 * (4.0 / 3.0 + xclamp); + float amp = xclamp * (1.0 - xclamp) / 2.0; + vec3 result; + float cosangle = cos(angle); + float sinangle = sin(angle); + result.r = -0.14861 * cosangle + 1.78277 * sinangle; + result.g = -0.29227 * cosangle + -0.90649 * sinangle; + result.b = 1.97294 * cosangle; + result = clamp(xclamp + amp * result, 0.0, 1.0); + return result; +} +`;/** + * @license + * Copyright 2018 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const ZE=!1;function ig(i,e){return{defineShader(t,n){const s=`prop_${n}`,r=`a_${s}`;t.addAttribute(`${i}`,r),t.addVertexCode(`${i} ${s}() { return ${r}; }`),t.addInitializer(o=>{const a=o.attribute(r),{gl:l}=o;o.vertexShaderInputBinders[s]=a===-1?{enable(){},disable(){},bind(){}}:{enable(c){l.enableVertexAttribArray(a),l.vertexAttribDivisor(a,c)},disable(){l.vertexAttribDivisor(a,0),l.disableVertexAttribArray(a)},bind(c,d){e(l,a,c,d)}}})}}}function Nc(i,e,t,n){return ig(i,(s,r,o,a)=>{s.vertexAttribPointer(r,e,t,n,o,a)})}function Ls(i,e,t){return ig(i,(n,s,r,o)=>{n.vertexAttribIPointer(s,e,t,r,o)})}const sg={rgb:Nc("highp vec3",3,WebGL2RenderingContext.UNSIGNED_BYTE,!0),rgba:Nc("highp vec4",4,WebGL2RenderingContext.UNSIGNED_BYTE,!0),float32:Nc("highp float",1,WebGL2RenderingContext.FLOAT,!1),uint32:Ls("highp uint",1,WebGL2RenderingContext.UNSIGNED_INT),int32:Ls("highp int",1,WebGL2RenderingContext.INT),uint16:Ls("highp uint",1,WebGL2RenderingContext.UNSIGNED_SHORT),int16:Ls("highp int",1,WebGL2RenderingContext.SHORT),uint8:Ls("highp uint",1,WebGL2RenderingContext.UNSIGNED_BYTE),int8:Ls("highp int",1,WebGL2RenderingContext.BYTE)};class eT extends T.O8{constructor(e,t,n,s){super(),this.gl=e,this.annotationType=t,this.rank=n,this.properties=s;const r=this.serializedGeometryBytesPerAnnotation=Ft[t].serializedBytes(n),{offsets:o,serializedBytes:a,propertyGroupBytes:l}=xh(n,r,s);this.serializedBytesPerAnnotation=a,this.propertyOffsets=o,this.propertyGroupBytes=l,this.geometryDataStride=l[0];const c=this.propertyGroupCumulativeBytes=new Array(l.length);c[0]=0;for(let d=1;d{const c=t.map(u=>l.vertexShaderInputBinders[`prop_${n[u].identifier}`]),d=c.length;l.vertexShaderInputBinders.properties={enable(u){for(let h=0;h{const{rank:r,properties:o}=this,a=[],l=s.referencedProperties,c=s.parseResult.code;for(let u=0,h=o.length;u`highp uint partIndex${r}`).join()}) { + highp uint pickID = uPickID; + highp uint pickBaseOffset = getPickBaseOffset(); +${t.map((s,r)=>`highp uint pickOffset${r} = pickBaseOffset + partIndex${r};`).join(` +`)} +`;return t.length===0&&(n+=` + highp uint pickOffset0 = pickBaseOffset; +`),n+=` + vPickID = pickID + pickOffset0; + highp uint selectedIndex = uSelectedIndex; +if (selectedIndex == pickBaseOffset${t.map((s,r)=>` || selectedIndex == pickOffset${r}`).join("")}) { + vColor = vec4(mix(vColor.rgb, vec3(1.0, 1.0, 1.0), 0.75), vColor.a); + } +} +`,e.addVertexCode(n),`setPartIndex(${t.join()})`}get invokeUserMain(){return` +ng_discardValue = false; +userMain(); +if (ng_discardValue) { + gl_Position = vec4(2.0, 0.0, 0.0, 1.0); + return; +} +`}getCrossSectionFadeFactor(){return this.targetIsSliceView?"(clamp(1.0 - 2.0 * abs(0.5 - gl_FragCoord.z), 0.0, 1.0))":"(1.0)"}enable(e,t,n){const{shader:s,parameters:r}=e(t.renderContext.emitter);if(s===null)return;s.bind();const{gl:o}=this,{renderContext:a}=t,{annotationLayer:l}=t;if(vi(o,s,this.shaderControlState,r.parseResult.controls),o.uniform3fv(s.uniform("uSubspaceMatrix"),t.subspaceMatrix),o.uniform1fv(s.uniform("uModelClipBounds"),t.modelClipBounds),o.uniformMatrix4fv(s.uniform("uModelViewProjection"),!1,t.modelViewProjectionMatrix),a.emitPickID&&o.uniform1ui(s.uniform("uPickID"),t.basePickId),a.emitColor){const d=l.state.displayState.color.value;o.uniform3f(s.uniform("uColor"),d[0],d[1],d[2]),o.uniform1ui(s.uniform("uSelectedIndex"),t.selectedIndex)}const c=s.vertexShaderInputBinders.properties;c.enable(1),o.bindBuffer(WebGL2RenderingContext.ARRAY_BUFFER,t.buffer.buffer),c.bind(t.count,t.bufferOffset),n(s),c.disable()}getHistogramShader(e){const{histogramShaders:t}=this;let n=t.get(e);if(n===void 0){const{gl:s}=this;n=s.memoize.get(JSON.stringify({t:"propertyHistogramGenerator",propertyType:e}),()=>{const r=new fn(s);return this.defineHistogramShader(r,e),r.build()}),t.set(e,n)}return n}defineHistogramShader(e,t){sg[t].defineShader(e,"histogram",0),e.addOutputBuffer("vec4","out_histogram",0);const s="invlerpForHistogram",r=kl[t];e.addVertexCode(Ss(e,s,r,!1)),e.setVertexMain(` +float x = invlerpForHistogram(prop_histogram()); +if (x < 0.0) x = 0.0; +else if (x > 1.0) x = 1.0; +else x = (1.0 + x * 253.0) / 255.0; +gl_Position = vec4(2.0 * (x * 255.0 + 0.5) / 256.0 - 1.0, 0.0, 0.0, 1.0); +gl_PointSize = 1.0; +`),e.setFragmentMain("out_histogram = vec4(1.0, 1.0, 1.0, 1.0);")}computeHistograms(e,t){const{histogramSpecifications:n}=this.shaderControlState,s=n.properties.value,r=s.length,{properties:o}=this,a=o.length,{propertyOffsets:l}=this,{propertyGroupBytes:c,propertyGroupCumulativeBytes:d}=this,{gl:u}=this;u.enable(WebGL2RenderingContext.BLEND),u.disable(WebGL2RenderingContext.SCISSOR_TEST),u.disable(WebGL2RenderingContext.DEPTH_TEST),u.blendFunc(WebGL2RenderingContext.ONE,WebGL2RenderingContext.ONE);const h=n.getFramebuffers(u),p=n.frameNumber;n.frameNumber=t,u.bindBuffer(WebGL2RenderingContext.ARRAY_BUFFER,e.buffer.buffer);for(let m=0;m{for(var s=n>1?void 0:n?nT(e,t):e,r=i.length-1,o;r>=0;r--)(o=i[r])&&(s=(n?o(e,t,s):o(s))||s);return n&&s&&tT(e,t,s),s};/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const og=!1;class Jn{constructor(e){this.source=e,this.state=Ue.SYSTEM_MEMORY}get gl(){return this.source.gl}copyToGPU(e){this.state=Ue.GPU_MEMORY}freeGPUMemory(e){this.state=Ue.SYSTEM_MEMORY}}function ag(i){if(typeof i!="number"||i<0)throw new Error(`Expected non-negative number as limit, but received: ${JSON.stringify(i)}`);return i}class Zo{constructor({defaultItemLimit:e=Number.POSITIVE_INFINITY,defaultSizeLimit:t=Number.POSITIVE_INFINITY}={}){this.sizeLimit=new _.DN(t,ag),this.itemLimit=new _.DN(e,ag)}}let Vc=class extends hn{constructor(i,e,t,n){super(),this.gl=e,this.frameNumberCounter=t,this.capacities=n,this.visibleChunksChanged=new j.IY,this.pendingChunkUpdates=null,this.pendingChunkUpdatesTail=null,this.chunkUpdateDeadline=null,this.chunkUpdateDelay=30,this.enablePrefetch=new nt(!0,!0);const s=r=>({itemLimit:this.registerDisposer(ft.makeFromExisting(i,r.itemLimit)).rpcId,sizeLimit:this.registerDisposer(ft.makeFromExisting(i,r.sizeLimit)).rpcId});this.initializeCounterpart(i,{gpuMemoryCapacity:s(n.gpuMemory),systemMemoryCapacity:s(n.systemMemory),downloadCapacity:s(n.download),computeCapacity:s(n.compute),enablePrefetch:this.registerDisposer(ft.makeFromExisting(i,this.enablePrefetch)).rpcId})}scheduleChunkUpdate(){const i=this.chunkUpdateDeadline;let e;i===null||Date.now()e){this.chunkUpdateDeadline=null,setTimeout(()=>this.processPendingChunkUpdates(),this.chunkUpdateDelay);break}const s=this.pendingChunkUpdates;if(s==null)break;try{this.applyChunkUpdate(s)&&(t=!0)}finally{if(++n,(this.pendingChunkUpdates=s.nextUpdate)==null){this.pendingChunkUpdatesTail=null;break}}}return t&&this.visibleChunksChanged.dispatch(),n}handleFetch_(i,e){const{resolve:t,reject:n,cancellationToken:s}=e.promise;if(s.isCanceled){n(Je.wS);return}const r=e.key,o=i.chunks.get(r);if(!o){n(new Error(`No chunk found at ${r} for source ${i.constructor.name}`));return}const a=o.data;if(!a){n(new Error(`At ${r} for source ${i.constructor.name}: chunk has no data`));return}t({value:a})}applyChunkUpdate(i){let e=!1;const{rpc:t}=this,n=t.get(i.source);if(n!==void 0){if(og&&console.log(`${Date.now()} Chunk.update processed: ${n.rpcId} ${i.id} ${i.state}`),i.promise!==void 0)this.handleFetch_(n,i);else if(i.id===void 0){for(const s of n.chunks.keys())n.deleteChunk(s);e=!0}else{const s=i.state;if(s===Ue.EXPIRED)n.deleteChunk(i.id);else{let r;const o=i.id;i.new?(r=n.getChunk(i),n.addChunk(o,r)):r=n.chunks.get(o);const a=r.state;if(s!==a)switch(s){case Ue.GPU_MEMORY:r.copyToGPU(this.gl),r.constructor.name!=="ManifestChunk"&&(e=!0);break;case Ue.SYSTEM_MEMORY:a===Ue.GPU_MEMORY&&r.freeGPUMemory(this.gl);break;default:throw new Error(`INTERNAL ERROR: Invalid chunk state: ${Ue[s]}`)}if(s<=Ue.SYSTEM_MEMORY){const{chunkRequesters:l}=n;if(l!==void 0){const c=l.get(o);if(c!==void 0)for(const d of c)d(r)}}}}return e}}flushPendingChunkUpdates(){return this.processPendingChunkUpdates(!0)}async getStatistics(){const i=this.rpc,e=await i.promiseInvoke(GC,{queue:this.rpcId}),t=new Map;for(const[n,s]of e){const r=i.get(n);r!==void 0&&t.set(r,s)}return t}};Vc=_c([Zt(FC)],Vc);function lg(i,e){const t=i.get(e.source);og&&console.log(`${Date.now()} Chunk.update received: ${t.rpcId} ${e.id} ${e.state} with chunkDataSize ${e.chunkDataSize}`);const n=t.chunkManager.chunkQueueManager;if(t.immediateChunkUpdates){n.applyChunkUpdate(e)&&n.visibleChunksChanged.dispatch();return}const s=n.pendingChunkUpdatesTail;s==null?(n.pendingChunkUpdates=e,n.pendingChunkUpdatesTail=e,n.scheduleChunkUpdate()):(s.nextUpdate=e,n.pendingChunkUpdatesTail=e)}pt("Chunk.update",function(i){lg(this,i)}),pp("Chunk.retrieve",function(i,e){return new Promise((t,n)=>{i.promise={resolve:t,reject:n,cancellationToken:e},lg(this,i)})}),pt(zC,function(i){const e=this.get(i.id);for(const t of e.prevStatisticsLayers)t.numVisibleChunksNeeded=0,t.numVisibleChunksAvailable=0,t.numPrefetchChunksNeeded=0,t.numPrefetchChunksAvailable=0;e.prevStatisticsLayers.length=0;for(const t of i.layers){const n=this.get(t.id);if(n===void 0)continue;const s=n.layerChunkProgressInfo;s.numVisibleChunksAvailable=t.numVisibleChunksAvailable,s.numVisibleChunksNeeded=t.numVisibleChunksNeeded,s.numPrefetchChunksAvailable=t.numPrefetchChunksAvailable,s.numPrefetchChunksNeeded=t.numPrefetchChunksNeeded,e.prevStatisticsLayers.push(s)}e.layerChunkStatisticsUpdated.dispatch()});let Bc=class extends hn{constructor(i){super(),this.chunkQueueManager=i,this.memoize=new rg.e,this.prevStatisticsLayers=[],this.layerChunkStatisticsUpdated=new j.IY,this.registerDisposer(i.addRef()),this.initializeCounterpart(i.rpc,{chunkQueueManager:i.rpcId})}get gl(){return this.chunkQueueManager.gl}getChunkSource(i,e){const t=i.encodeOptions(e);t.constructorId=xt(i);const n=(0,f.JB)(t);return this.memoize.get(n,()=>{const s=new i(this,e);return s.initializeCounterpart(this.rpc,{}),s.key=t,s})}};Bc=_c([Zt(UC)],Bc);class on extends hn{constructor(e,t={}){super(),this.chunkManager=e,this.chunks=new Map,this.immediateChunkUpdates=!1}initializeCounterpart(e,t){t.chunkManager=this.chunkManager.rpcId,super.initializeCounterpart(e,t)}get gl(){return this.chunkManager.chunkQueueManager.gl}deleteChunk(e){const t=this.chunks.get(e);t.state===Ue.GPU_MEMORY&&t.freeGPUMemory(this.gl),this.chunks.delete(e)}addChunk(e,t){this.chunks.set(e,t)}getChunk(e){throw new Error("Not implemented.")}invalidateCache(){this.rpc.invoke($C,{id:this.rpcId})}static encodeOptions(e){return{}}}function it(i,e){let t=class extends i{constructor(...n){super(...n);const s=n[1];this.parameters=s.parameters}initializeCounterpart(n,s){s.parameters=this.parameters,super.initializeCounterpart(n,s)}static encodeOptions(n){return Object.assign({parameters:n.parameters},i.encodeOptions(n))}};return t=_c([Zt(e.RPC_ID)],t),t}class Dr extends hn{constructor(e){super(),this.layerChunkProgressInfo=e}}var Rt=G(4242);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const cg=["visibleSegments","segmentEquivalences","temporaryVisibleSegments","temporarySegmentEquivalences","useTemporaryVisibleSegments","useTemporarySegmentEquivalences"];function iT(i,e,t){i.registerDisposer(e.visibleSegments.changed.add(t)),i.registerDisposer(e.segmentEquivalences.changed.add(t))}function sT(i,e,t){i.registerDisposer(e.temporaryVisibleSegments.changed.add(t)),i.registerDisposer(e.temporarySegmentEquivalences.changed.add(t)),i.registerDisposer(e.useTemporaryVisibleSegments.changed.add(t)),i.registerDisposer(e.useTemporarySegmentEquivalences.changed.add(t))}function Sn(i){return`${i.low},${i.high}`}function rT(i){return!!(i.high>>>31)}function dg(i){return i.useTemporaryVisibleSegments.value?i.temporaryVisibleSegments:i.visibleSegments}function oT(i){return i.useTemporarySegmentEquivalences.value?i.temporarySegmentEquivalences:i.segmentEquivalences}function Rs(i,e){const t=dg(i),n=oT(i),s=n.disjointSets.visibleSegmentEquivalencePolicy.value;for(const r of t.unsafeKeys())if(s&Rt.y6.NONREPRESENTATIVE_EXCLUDED){const o=n.get(r);e(r,o)}else{if(!n.disjointSets.isMinElement(r))continue;for(const o of n.setElements(r))s&Rt.y6.REPRESENTATIVE_EXCLUDED&&s&Rt.y6.MAX_REPRESENTATIVE&&rT(o)||e(o,r)}}/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const mt=40,Ir=.5,ks=-4;function ea(i,e=ks){return(Math.log2(i)-e)/Ir}function aT(i,e=ks){return 2**(i*Ir+e)}function Bi(i,e=2**ks,t){t===void 0&&(t=2**Math.round(Ir*mt+ks)-1);const n=(0,f.JY)(e,t);return new _.DN(i,n)}class Ps{constructor(e=ks){this.visibility=new or,this.changed=new j.IY,this.frameNumber=-1,this.spatialScales=new Map,this.numHistogramRows=1,this.value=new Uint32Array(mt*this.numHistogramRows*2),this.fakeChunkCount=0,this.logScaleOrigin=e}begin(e){e!==this.frameNumber&&(this.value.fill(0),this.frameNumber=e,this.spatialScales.clear(),this.fakeChunkCount=0,this.changed.dispatch())}add(e,t,n,s,r=!1){let{spatialScales:o,numHistogramRows:a,value:l}=this,c=o.get(e);if(c===void 0&&(c=o.size,o.set(e,c)),c>=a){this.numHistogramRows=a*=2;const u=new Uint32Array(a*mt*2);u.set(l),this.value=l=u}const d=c*mt*2+Math.min(Math.max(0,Math.round(ea(t,this.logScaleOrigin))),mt-1);l[d]+=n,l[d+mt]+=s,r&&(this.fakeChunkCount=this.fakeChunkCount+s)}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class Fc extends mp{constructor(e,t,n){super(),this.chunkManager=e,this.multiscaleSource=t,this.rpcId=null,this.rpcTransfer={},this.visibleSources=new Map,this.visibleSourcesList_=[];const{renderScaleTarget:s=Bi(1)}=n;this.renderScaleTarget=s,this.renderScaleHistogram=n.renderScaleHistogram,this.transform=n.transform,this.localPosition=n.localPosition,this.rpcTransfer=n.rpcTransfer||{},this.dataHistogramSpecifications=this.registerDisposer(n.dataHistogramSpecifications??new Np((0,_.XZ)([]),(0,_.XZ)([]),(0,_.XZ)([]))),this.registerDisposer(this.dataHistogramSpecifications.visibility.changed.add(this.redrawNeeded.dispatch))}getDataHistogramCount(){return this.dataHistogramSpecifications.visibleHistograms}getSources(e){return this.multiscaleSource.getSources(e)}addSource(e,t){const{visibleSources:n}=this,s=n.get(e);s!==void 0?(++s.refCount,s.chunkTransform=t):(n.set(e,{source:e,refCount:1,chunkTransform:t}),this.visibleSourcesList_.length=0)}removeSource(e){const{visibleSources:t}=this,n=t.get(e);n.refCount!==1?--n.refCount:(t.delete(e),this.visibleSourcesList_.length=0)}get visibleSourcesList(){const{visibleSources:e,visibleSourcesList_:t}=this;if(t.length===0&&e.size!==0){for(const n of e.values())t.push(n);t.sort((n,s)=>Math.abs(n.chunkTransform.chunkToLayerTransformDet)-Math.abs(s.chunkTransform.chunkToLayerTransformDet))}return t}initializeCounterpart(){const e=this.registerDisposer(new Dr(this.layerChunkProgressInfo)),t=this.chunkManager.rpc;e.RPC_TYPE_ID=this.RPC_TYPE_ID,e.initializeCounterpart(t,{localPosition:this.registerDisposer(ft.makeFromExisting(t,this.localPosition)).rpcId,renderScaleTarget:this.registerDisposer(ft.makeFromExisting(t,this.renderScaleTarget)).rpcId,...this.rpcTransfer}),this.rpcId=e.rpcId}get gl(){return this.chunkManager.chunkQueueManager.gl}setGLBlendMode(e,t){t>0?(e.enable(WebGL2RenderingContext.BLEND),e.blendFunc(WebGL2RenderingContext.SRC_ALPHA,WebGL2RenderingContext.ONE_MINUS_SRC_ALPHA)):e.disable(WebGL2RenderingContext.BLEND)}filterVisibleSources(e,t){return NE(e,this,t)}}Fc.prototype.RPC_TYPE_ID=_E;class Fi extends vp{draw(e,t){}isReady(e,t){return!0}}var lT=Object.defineProperty,cT=Object.getOwnPropertyDescriptor,dT=(i,e,t,n)=>{for(var s=n>1?void 0:n?cT(e,t):e,r=i.length-1,o;r>=0;r--)(o=i[r])&&(s=(n?o(e,t,s):o(s))||s);return n&&s&&lT(e,t,s),s};/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class uT extends kE{}const hT=ar(uT);function pT(i){return{source:i.source.addCounterpartRef(),effectiveVoxelSize:i.effectiveVoxelSize,layerRank:i.layerRank,nonDisplayLowerClipBound:i.nonDisplayLowerClipBound,nonDisplayUpperClipBound:i.nonDisplayUpperClipBound,lowerClipBound:i.lowerClipBound,upperClipBound:i.upperClipBound,lowerClipDisplayBound:i.lowerClipDisplayBound,upperClipDisplayBound:i.upperClipDisplayBound,chunkDisplayDimensionIndices:i.chunkDisplayDimensionIndices,lowerChunkDisplayBound:i.lowerChunkDisplayBound,upperChunkDisplayBound:i.upperChunkDisplayBound,fixedLayerToChunkTransform:i.fixedLayerToChunkTransform,combinedGlobalLocalToChunkTransform:i.combinedGlobalLocalToChunkTransform,chunkLayout:i.chunkLayout.toObject()}}function ta(i){return i.map(e=>e.map(pT))}function Uc(i,e){for(const t of e)for(const{source:n}of t)i.removeSource(n),n.dispose()}let na=class extends hT{constructor(i,e,t,n){super(new yp({parametersConstructor:LE,navigationState:t,update:(o,a)=>{const{invViewMatrix:l,centerDataPosition:c}=o;a.toMat4(l);const{canonicalVoxelFactors:d,voxelPhysicalScales:u}=o.displayDimensionRenderInfo;for(let b=0;b<3;++b)c[b]=l[12+b];const{logicalWidth:h,logicalHeight:p,projectionMat:m,viewportNormalInGlobalCoordinates:g,viewportNormalInCanonicalCoordinates:v}=o,{relativeDepthRange:y}=a;C.pB.ortho(m,-h/2,h/2,p/2,-p/2,-y,y),ip(o,m),ap(o);const{viewMatrix:S}=o;for(let b=0;b<3;++b){const x=g[b]=S[b*4+2];v[b]=x/d[b]}C.eR.normalize(g,g),C.eR.normalize(v,v);let w=0;for(let b=0;b<3;++b){const x=u[b],E=l[b];w+=(x*E)**2}w=Math.sqrt(w),o.pixelSize=w}})),this.chunkManager=i,this.layerManager=e,this.navigationState=t,this.wireFrame=n,this.gl=this.chunkManager.gl,this.viewChanged=new j.IY,this.renderingStale=!0,this.visibleChunksStale=!0,this.visibleLayerList=new Array,this.offscreenFramebuffer=this.registerDisposer(new $n(this.gl,{colorBuffers:vs(this.gl,1),depthBuffer:new xw(this.gl)})),this.histogramInputTextures=[],this.offscreenFramebuffersWithHistograms=[this.offscreenFramebuffer],this.histogramGenerator=hc.get(this.gl),this.updateVisibleLayers=this.registerCancellable((0,Fe.A)(()=>{this.updateVisibleLayersNow()},0)),this.registerDisposer(t),this.registerDisposer(this.projectionParameters),this.registerDisposer(this.projectionParameters.changed.add((o,a)=>{o.displayDimensionRenderInfo!==a.displayDimensionRenderInfo&&this.updateVisibleLayers()}));const s=this.chunkManager.rpc,r=this.sharedProjectionParameters=this.registerDisposer(new So(s,this.projectionParameters));this.initializeCounterpart(s,{chunkManager:i.rpcId,projectionParameters:r.rpcId}),this.registerDisposer(e.layersChanged.add(()=>{this.updateVisibleLayers()})),this.wireFrame.changed.add(this.viewChanged.dispatch),this.viewChanged.add(()=>{this.renderingStale=!0}),this.registerDisposer(i.chunkQueueManager.visibleChunksChanged.add(this.viewChanged.dispatch)),this.updateVisibleLayers()}get displayDimensionRenderInfo(){return this.navigationState.displayDimensionRenderInfo}computeHistograms(i,e){this.histogramGenerator.compute(i,this.offscreenFramebuffer.depthBuffer.texture,this.histogramInputTextures,e,this.chunkManager.chunkQueueManager.frameNumberCounter.frameNumber)}flushBackendProjectionParameters(){this.sharedProjectionParameters.flush()}forEachVisibleChunk(i,e,t){UE(this.projectionParameters.value,i.renderLayer.localPosition.value,i,e,()=>{t(i.curPositionInChunks.join())})}isReady(){if(!this.navigationState.valid)return!1;this.updateVisibleLayers.flush(),this.updateVisibleSources();let i=0,e=0;for(const{visibleSources:t}of this.visibleLayers.values())for(const n of t){const s=Mc(this.projectionParameters.value,n.chunkLayout),{source:r}=n,{chunks:o}=r;this.forEachVisibleChunk(n,s,a=>{const l=o.get(a);++e,l&&l.state===Ue.GPU_MEMORY&&++i})}return i===e}invalidateVisibleSources(){super.invalidateVisibleSources(),this.viewChanged.dispatch()}bindVisibleRenderLayer(i,e){e.push(i.localPosition.changed.add(()=>this.invalidateVisibleChunks())),e.push(i.redrawNeeded.add(this.viewChanged.dispatch)),e.push(i.transform.changed.add(this.updateVisibleLayers)),e.push(i.renderScaleTarget.changed.add(()=>this.invalidateVisibleSources()));const{renderScaleHistogram:t}=i;t!==void 0&&e.push(t.visibility.add(this.visibility)),e.push(i.dataHistogramSpecifications.producerVisibility.add(this.visibility))}updateVisibleLayersNow(){if(this.wasDisposed||!this.navigationState.valid)return!1;const i=Date.now(),{visibleLayers:e,visibleLayerList:t}=this,{displayDimensionRenderInfo:n}=this.projectionParameters.value,s=this.rpc,r={id:this.rpcId};let o=!1;t.length=0;for(const a of this.layerManager.readyRenderLayers())if(a instanceof Fc){t.push(a);let l=e.get(a);if(l===void 0){const c=[],d=new ai;l={messages:d,allSources:this.getTransformedSources(a,d),transformGeneration:a.transform.changed.count,visibleSources:[],disposers:c,lastSeenGeneration:i,displayDimensionRenderInfo:n},c.push(a.messages.addChild(l.messages)),e.set(a.addRef(),l),this.bindVisibleRenderLayer(a,c)}else{l.lastSeenGeneration=i;const c=a.transform.changed.count;if(l.transformGeneration===c&&l.displayDimensionRenderInfo===n)continue;const d=l.allSources;l.allSources=this.getTransformedSources(a,l.messages),Uc(a,d),l.visibleSources.length=0,l.displayDimensionRenderInfo=n,l.transformGeneration=c}r.layerId=a.rpcId,r.sources=ta(l.allSources),r.displayDimensionRenderInfo=n,this.flushBackendProjectionParameters(),s.invoke(VE,r),o=!0}for(const[a,l]of e)l.lastSeenGeneration!==i&&(r.layerId=a.rpcId,s.invoke(BE,r),e.delete(a),Uc(a,l.allSources),(0,T.$F)(l.disposers),a.dispose(),o=!0);return o&&(this.visibleSourcesStale=!0),this.viewChanged.dispatch(),o}invalidateVisibleChunks(){super.invalidateVisibleChunks(),this.viewChanged.dispatch()}get valid(){return this.navigationState.valid}getOffscreenFramebufferWithHistograms(i){const{offscreenFramebuffersWithHistograms:e}=this;let t=e[i];if(t===void 0){const{gl:n,histogramInputTextures:s,offscreenFramebuffer:r}=this;s.lengthi.getSources(n),e,i);for(const n of t)for(const s of n)i.addSource(s.source,s.chunkTransform);return t}};na=dT([Zt(OE)],na);class Lr extends on{constructor(e,t){super(e,t),this.spec=t.spec}static encodeSpec(e){return{chunkDataSize:Array.from(e.chunkDataSize),lowerVoxelBound:Array.from(e.lowerVoxelBound),upperVoxelBound:Array.from(e.upperVoxelBound)}}static encodeOptions(e){const t=on.encodeOptions(e);return t.spec=Lr.encodeSpec(e.spec),t}initializeCounterpart(e,t){t.spec=this.spec,super.initializeCounterpart(e,t)}async fetchChunk(e,t,n=Je.fx){const s=e.join(),r=this.chunks.get(s);if(r!==void 0&&r.state<=Ue.SYSTEM_MEMORY)return t(r);this.addRef();let{chunkRequesters:o}=this;o===void 0&&(o=this.chunkRequesters=new Map);let a,l=o.get(s);l===void 0&&(l=[],o.set(s,l));const c=new Promise(d=>{a=u=>d(t(u)),l.push(a)});try{return await this.rpc.promiseInvoke(FE,{source:this.rpcId,chunkGridPosition:e},n),await c}finally{const d=l.indexOf(a);l.splice(d,1),l.length===0&&o.delete(s),o.size===0&&(this.chunkRequesters=void 0),this.dispose()}}}class ug extends Jn{constructor(e,t){super(e),this.chunkGridPosition=t.chunkGridPosition,this.state=Ue.SYSTEM_MEMORY}}class ia extends T.O8{constructor(e,t){super(),this.gl=e,this.copyVertexPositionsBuffer=ur(this.gl),this.textureCoordinateAdjustment=new Float32Array(4);const n=new fn(e);n.addVarying("vec2","vTexCoord"),n.addUniform("sampler2D","uSampler"),n.addInitializer(s=>{e.uniform1i(s.uniform("uSampler"),0)}),n.addUniform("vec4","uColorFactor"),n.addUniform("vec4","uBackgroundColor"),n.addUniform("mat4","uProjectionMatrix"),n.addUniform("vec4","uTextureCoordinateAdjustment"),n.require(t),n.setFragmentMain(` +vec4 sampledColor = texture(uSampler, vTexCoord); +if (sampledColor.a == 0.0) { + sampledColor = uBackgroundColor; +} +emit(sampledColor * uColorFactor, 0u); +`),n.addAttribute("vec4","aVertexPosition"),n.setVertexMain(` +vTexCoord = uTextureCoordinateAdjustment.xy + 0.5 * (aVertexPosition.xy + 1.0) * uTextureCoordinateAdjustment.zw; +gl_Position = uProjectionMatrix * aVertexPosition; +`),this.shader=this.registerDisposer(n.build())}draw(e,t,n,s,r,o,a,l){const{gl:c,shader:d,textureCoordinateAdjustment:u}=this;u[0]=r,u[1]=o,u[2]=a-r,u[3]=l-o,d.bind(),c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,e),c.disable(WebGL2RenderingContext.BLEND),c.uniformMatrix4fv(d.uniform("uProjectionMatrix"),!1,t),c.uniform4fv(d.uniform("uColorFactor"),n),c.uniform4fv(d.uniform("uBackgroundColor"),s),c.uniform4fv(d.uniform("uTextureCoordinateAdjustment"),u);const h=d.attribute("aVertexPosition");this.copyVertexPositionsBuffer.bindToVertexAttrib(h,2),c.drawArrays(c.TRIANGLE_FAN,0,4),c.disableVertexAttribArray(h),c.bindTexture(c.TEXTURE_2D,null)}static get(e,t){return e.memoize.get(`sliceview/SliceViewRenderHelper:${xt(t)}`,()=>new ia(e,t))}}class fT{constructor(e){this.chunkManager=e}}function sa(i,e,t,n,s){n.clearMessages();const r=y=>(n.addMessage({severity:Tn.error,message:y}),[]);if(e.error!==void 0)return r(e.error);const o=e.rank,a=e.unpaddedRank,{displayDimensionIndices:l,displayRank:c,canonicalVoxelFactors:d}=i,u=Zh(e,l),{displayToLayerDimensionIndices:h}=u,p=new Float32Array(c*a),{modelToRenderLayerTransform:m}=e;for(let y=0;y{const{chunkSource:w}=S,{spec:b}=w,{lowerClipBound:x=b.lowerVoxelBound,upperClipBound:E=b.upperVoxelBound}=S,D=po(e,S.chunkToMultiscaleTransform),{chunkDataSize:I}=b,{channelToChunkDimensionIndices:L}=D,N=new Float32Array(a),k=new Float32Array(a);N.set(x),k.set(E);const O=L.length,{channelSpaceShape:V}=e;for(let be=0;beS.map(w=>y(w)))}catch(y){for(const x of g)for(const{chunkSource:E}of x)E.dispose();const{globalDimensionNames:S}=i,b=`Cannot render (${Array.from(i.displayDimensionIndices.filter(x=>x!==-1),x=>S[x]).join(",\xA0")}) cross section: ${y.message}`;return r(b)}}var gT=Object.defineProperty,mT=Object.getOwnPropertyDescriptor,$c=(i,e,t,n)=>{for(var s=n>1?void 0:n?mT(e,t):e,r=i.length-1,o;r>=0;r--)(o=i[r])&&(s=(n?o(e,t,s):o(s))||s);return n&&s&&gT(e,t,s),s};/** + * @license + * Copyright 2018 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function hg(i){let e=0;const{typeToIds:t}=i;for(const n of Xt)e+=Tr(n).pickIdsPerInstance*t[n].length;return e}class pg{constructor(e){this.bufferValid=!1,this.numPickIds=0,this.serializedAnnotations={data:e.data,typeToIds:e.typeToIds,typeToOffset:e.typeToOffset,typeToIdMaps:e.typeToIdMaps}}freeGPUMemory(e){const{buffer:t}=this;t!==void 0&&(t.dispose(),this.bufferValid=!1,this.buffer=void 0)}}class vT extends Jn{constructor(e,t){super(e),t.data!==void 0&&(this.data=new pg(t))}freeGPUMemory(e){super.freeGPUMemory(e);const{data:t}=this;t!==void 0&&t.freeGPUMemory(e)}dispose(){this.data=void 0}}class fg extends ug{constructor(e,t){super(e,t),t.data!==void 0&&(this.data=new pg(t))}freeGPUMemory(e){super.freeGPUMemory(e);const{data:t}=this;t!==void 0&&t.freeGPUMemory(e)}dispose(){this.data=void 0}}let ra=class extends Lr{constructor(i,e){super(i,e),this.immediateChunkUpdates=!0,(this.parent=e.parent).spatiallyIndexedSources.add(this);const{rank:n,chunkDataSize:s}=this.spec,r=this.multiscaleToChunkTransform=new Float32Array((n+1)**2);De.DI(r,n+1,this.spec.chunkToMultiscaleTransform,n+1,n+1);for(let o=0;ot&&(a+=n,i.typeToOffset[r]=a),s.set(i.data.subarray(o,o+i.typeToIds[r].length*e[r].serializedBytes),a)}return s}function Wc(i,e,t,n,s,r,o,a){const l=i.typeToOffset[t];let c=l,d=l;const{propertyGroupBytes:u}=e[t],h=u.length,p=i.typeToIds[t].length;for(let m=0;m0}getSources(e){throw new Error("not implemented")}initializeCounterpart(e,t){this.metadataChunkSource.initializeCounterpart(e,{});for(const n of this.segmentFilteredSources)n.initializeCounterpart(e,{});t.segmentFilteredSource=this.segmentFilteredSources.map(n=>n.addCounterpartRef()),t.metadataChunkSource=this.metadataChunkSource.addCounterpartRef(),t.chunkManager=this.chunkManager.rpcId,super.initializeCounterpart(e,t)}add(e,t=!0){e.id=Vl();const n=new Li(e.id);return n.value=e,this.references.set(n.id,n),n.registerDisposer(()=>{this.references.delete(n.id)}),this.applyLocalUpdate(n,!1,t,e),n}applyLocalUpdate(e,t,n,s){const{localUpdates:r}=this,{id:o}=e;let a=this.localUpdates.get(o);const l=e.value;if(l==null)throw new Error("Cannot create local update from null annotation");if(a===void 0?(a={type:l.type,reference:e.addRef(),existingAnnotation:t?l:void 0,pendingCommit:void 0,commitInProgress:void 0},r.set(o,a),this.forEachPossibleChunk(l,c=>{const{data:d}=c;if(d===void 0)return;const u=l.type;aa(d,u,o,this.annotationPropertySerializers)}),s!==null&&oa(this.temporary.data,s,this.annotationPropertySerializers)):(s===null?aa(this.temporary.data,l.type,l.id,this.annotationPropertySerializers):oa(this.temporary.data,s,this.annotationPropertySerializers),e.value=s),n)if(a.commitInProgress!==void 0)a.pendingCommit=s;else{if(s===null&&a.existingAnnotation===void 0){r.delete(o),a.reference.dispose();return}this.sendCommitRequest(a,s)}this.notifyChanged(e.id,s||void 0)}sendCommitRequest(e,t){this.updateCommitsInProgress(1),e.commitInProgress=t,this.rpc.invoke(JE,{id:this.rpcId,annotationId:e.existingAnnotation&&e.reference.id,newAnnotation:t})}delete(e){this.applyLocalUpdate(e,!0,!0,null)}update(e,t){this.applyLocalUpdate(e,!0,!1,t)}notifyChanged(e,t){const n=this.references.get(e),s=this.metadataChunkSource.chunks.get(e);s!==void 0&&(s.annotation=t||null),n!==void 0&&(n.value=t||null,n.changed.dispatch()),this.chunkManager.chunkQueueManager.visibleChunksChanged.dispatch()}commit(e){this.applyLocalUpdate(e,!0,!0,e.value)}getReference(e){let t=this.references.get(e);if(t!==void 0)return t.addRef();t=new Li(e),this.references.set(e,t),this.rpc.invoke(WE,{id:this.rpcId,annotation:e}),t.registerDisposer(()=>{this.references.delete(e),this.rpc.invoke(HE,{id:this.rpcId,annotation:e})});const n=this.metadataChunkSource.chunks.get(e);return n!==void 0&&(t.value=n.annotation),t}forEachPossibleChunk(e,t){const{relatedSegments:n}=e;if(n!==void 0){const l=n.length,{segmentFilteredSources:c}=this;for(let d=0;d{const{data:o}=r;o!==void 0&&oa(o,t,this.annotationPropertySerializers)});const{reference:n}=e,{id:s}=n;n.value=t||null,n.changed.dispatch(),n.dispose(),this.localUpdates.delete(s)}*[Symbol.iterator](){}}pt(jE,function(i){const e=this.get(i.id),t=i.annotationId,n=i.error;if(n!==void 0)e.handleFailedUpdate(t,n);else{const s=Lh(i.newAnnotation);e.handleSuccessfulUpdate(t,s)}});var kr=G(8795);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const mg={offset:0,completions:[]};function yi(i,e){return e.offset+=i,e}function Hc(i,e){const t=[];for(const n of e)n.startsWith(i)&&t.push({value:n});return t.sort((n,s)=>(0,kr.e)(n.value,s.value)),t}function Ht(i,e,t,n){const s=[];for(const r of e){const o=t(r);o.startsWith(i)&&s.push({value:o,description:n(r)})}return s.sort((r,o)=>(0,kr.e)(r.value,o.value)),s}async function bT(i,e,t){if(i.startsWith("{"))return mg;const s=i.match(/^(?:(.*)[&;])?([^&;]*)$/)[2],r=i.length-s.length,o=s.indexOf("=");if(o===-1){const a=await e(s);return{offset:a.offset+r,completions:a.completions.map(l=>({...l,value:`${l.value}=`}))}}return yi(r+o+1,await t(s.substring(0,o),s.substring(o+1)))}async function vg(i,e){return bT(i,async t=>{const n=[];for(const s of e){const r=s.key;r.value.startsWith(t)&&n.push(r)}return{offset:0,completions:n}},async(t,n)=>{for(const s of e)if(s.key.value===t)return{offset:0,completions:s.values.filter(r=>r.value.startsWith(n))};return mg})}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class Jc extends Error{constructor(e){super(`Redirected to: ${e}`),this.redirectTarget=e}}function yg(i,e){e===void 0&&(i.indexOf("/")===-1?e=":":e="/");const t=i.lastIndexOf(e);return t===-1?0:t+1}function CT(i,e){const t=yg(i,e);return i.substring(t)}var As=(i=>(i[i.annotations=0]="annotations",i[i.equivalences=1]="equivalences",i))(As||{});function Sg(){return{url:"",transform:void 0,enableDefaultSubsources:!0,subsources:new Map}}class Jt extends T.O8{normalizeUrl(e){return e.url}convertLegacyUrl(e){return e.url}async completeUrl(e){throw null}}const bg="local://annotations",jc="local://equivalences";class wT extends Jt{get description(){return"Local in-memory"}async get(e){switch(e.url){case bg:{const{transform:t}=e;let n;if(t===void 0){const s=e.globalCoordinateSpace.value,{rank:r,names:o,scales:a,units:l}=s,c=Oe({rank:r,scales:a,units:l,names:o.map((u,h)=>`${h}`)}),d=Oe({rank:r,scales:a,units:l,names:o});n={rank:r,sourceRank:r,inputSpace:c,outputSpace:d,transform:(0,De.DA)(Float64Array,r+1)}}else n=wt(ki);return{modelTransform:n,canChangeModelSpaceRank:!0,subsources:[{id:"default",default:!0,subsource:{local:0}}]}}case jc:return{modelTransform:wt(ki),canChangeModelSpaceRank:!1,subsources:[{id:"default",default:!0,subsource:{local:1}}]}}throw new Error("Invalid local data source URL")}async completeUrl(e){return{offset:0,completions:Ht(e.providerUrl,[{value:"annotations",description:"Annotations stored in the JSON state"},{value:"equivalences",description:"Segmentation equivalence graph stored in the JSON state"}],t=>t.value,t=>t.description)}}}const Cg=/^(?:([a-zA-Z][a-zA-Z0-9-+_]*):\/\/)?(.*)$/;class xT extends T.O8{constructor(e){super(),this.credentialsManager=e,this.dataSources=new Map([["local",new wT]])}register(e,t){this.dataSources.set(e,this.registerDisposer(t))}getProvider(e){const t=e.match(Cg);if(t===null||t[1]===void 0)throw new Error('Data source URL must have the form "://".');const[,n,s]=t,r=this.dataSources.get(n);if(r===void 0)throw new Error(`Unsupported data source: ${JSON.stringify(n)}.`);return[r,s,n]}async get(e){const t=new Set,{cancellationToken:n=Je.fx}=e;let s=e.url;for(;;){const[r,o,a]=this.getProvider(e.url);t.add(e.url);try{return r.get({...e,url:s,providerProtocol:a,providerUrl:o,registry:this,cancellationToken:n,credentialsManager:this.credentialsManager})}catch(l){if(l instanceof Jc){const c=l.redirectTarget;if(t.has(c))throw Error(`Layer source redirection contains loop: ${JSON.stringify(Array.from(t))}`);if(t.size>=10)throw Error(`Too many layer source redirections: ${JSON.stringify(Array.from(t))}`);s=c;continue}throw l}}}convertLegacyUrl(e){try{const[t,n,s]=this.getProvider(e.url);return t.convertLegacyUrl({...e,providerUrl:n,providerProtocol:s,registry:this})}catch{return e.url}}normalizeUrl(e){try{const[t,n,s]=this.getProvider(e.url);return t.normalizeUrl({...e,providerUrl:n,providerProtocol:s,registry:this})}catch{return e.url}}async completeUrl(e){const{url:t,cancellationToken:n=Je.fx}=e,s=t.match(Cg),r=s[1];if(r===void 0)return Promise.resolve({offset:0,completions:Ht(t,this.dataSources,([a])=>`${a}://`,([,a])=>a.description)});const o=this.dataSources.get(r);if(o!==void 0){const a=await o.completeUrl({registry:this,url:t,providerUrl:s[2],chunkManager:e.chunkManager,cancellationToken:n,credentialsManager:this.credentialsManager});return yi(r.length+3,a)}throw null}suggestLayerName(e){let[t,n]=this.getProvider(e);n.endsWith("/")&&(n=n.substring(0,n.length-1));const s=t.suggestLayerName;return s!==void 0?s(n):CT(n)}findSourceGroup(e){const[t,n,s]=this.getProvider(e);return(t.findSourceGroup||yg)(n)+s.length+3}}var la=G(4022);/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function ET(i){return typeof i=="boolean"?{enabled:i}:((0,f.Rf)(i),{enabled:(0,f.MM)(i,"enabled",f.aO)})}function Pr(i,e=void 0){return typeof i=="string"?{url:i,transform:e,enableDefaultSubsources:!0,subsources:new Map}:((0,f.Rf)(i),{url:(0,f.cQ)(i,"url",f.zr),transform:(0,f.cQ)(i,"transform",jh)||e,enableDefaultSubsources:(0,f.MM)(i,"enableDefaultSubsources",f.aO,!0),subsources:(0,f.MM)(i,"subsources",t=>(0,f.vS)(t,ET),new Map),state:(0,f.MM)(i,"state",f.Rf)})}function TT(i){return i.enabled}function wg(i){const e=Yh(i.transform),t={};let n=!0;for(const[s,r]of i.subsources){const o=TT(r);o!==void 0&&(t[s]=o,n=!1)}return e===void 0&&n&&i.enableDefaultSubsources===!0&&i.state===void 0?i.url:{url:i.url,transform:e,subsources:n?void 0:t,enableDefaultSubsources:i.enableDefaultSubsources===!0?void 0:!1,state:i.state}}class DT{constructor(e,t,n,s,r){this.loadedDataSource=e,this.subsourceEntry=t,this.subsourceSpec=n,this.subsourceIndex=s,this.activated=void 0,this.guardValues=[],this.messages=new ai,this.isActiveChanged=new j.IY;let o;n===void 0||n.enabled===void 0?o=t.default&&r:o=n.enabled;const a=e.dataSource.modelTransform.sourceRank;let{modelSubspaceDimensionIndices:l}=t;if(l===void 0){l=new Array(a);for(let d=0;dnew DT(this,r,s.get(r.id),o,this.enableDefaultSubsources))}get enabledSubsources(){return this.subsources.filter(e=>e.enabled)}get layer(){return this.layerDataSource.layer}disposed(){for(const e of this.subsources){const{activated:t}=e;t!==void 0&&(e.activated=void 0,t.dispose())}}}class IT extends T.O8{constructor(e,t=void 0){super(),this.layer=e,this.changed=new j.IY,this.messages=new ai,this.loadState_=void 0,this.specGeneration=-1,this.refCounted_=void 0,this.registerDisposer(this.changed.add(e.dataSourcesChanged.dispatch)),this.registerDisposer(e.messages.addChild(this.messages)),t===void 0?this.spec_=Sg():this.spec=t}get spec(){const{loadState:e}=this;if(e!==void 0&&e.error===void 0){const t=this.changed.count;t!==this.specGeneration&&(this.specGeneration=t,this.spec_={url:this.spec.url,transform:e.transform.spec,enableDefaultSubsources:e.enableDefaultSubsources,subsources:new Map(Array.from(e.subsources,n=>{const s=e.enableDefaultSubsources&&n.subsourceEntry.default;return[n.subsourceEntry.id,{enabled:n.enabled!==s?n.enabled:void 0}]})),state:this.spec.state})}return this.spec_}get loadState(){return this.loadState_}set spec(e){const{layer:t}=this;if(this.messages.clearMessages(),e.url.length===0){if(t.dataSources.length!==1){const l=t.dataSources.indexOf(this);if(l!==-1){t.dataSources.splice(l,1),t.dataSourcesChanged.dispatch(),this.dispose();return}}this.spec_=e,this.refCounted_!==void 0&&(this.refCounted_.dispose(),this.refCounted_=void 0,this.loadState_=void 0,this.changed.dispatch());return}const n=new T.O8,s=n.registerDisposer((0,T.K9)(t.markLoading()));this.refCounted_!==void 0&&(this.refCounted_.dispose(),this.loadState_=void 0),this.refCounted_=n,this.spec_=e;const r=t.manager.chunkManager,o=t.manager.dataSourceProviderRegistry,a=new Je.Qi;this.messages.addMessage({severity:Tn.info,message:"Loading data source"}),o.get({chunkManager:r,url:e.url,cancellationToken:a,globalCoordinateSpace:t.manager.root.coordinateSpace,transform:e.transform,state:e.state}).then(l=>{if(n.wasDisposed)return;this.messages.clearMessages();const c=n.registerDisposer(new Yc(this,l,e));c.registerDisposer(t.addCoordinateSpace(c.transform.outputSpace)),c.registerDisposer(c.transform.changed.add(this.changed.dispatch)),this.loadState_=c,c.registerDisposer(c.enabledSubsourcesChanged.add(this.changed.dispatch)),this.changed.dispatch(),l.state&&n.registerDisposer(l.state.changed.add(()=>{this.spec.state=l.state?.toJSON(),t.specificationChanged.dispatch()})),s()}).catch(l=>{this.wasDisposed||(this.loadState_={error:l},this.messages.clearMessages(),this.messages.addMessage({severity:Tn.error,message:l.message}),this.changed.dispatch())}),n.registerDisposer(()=>{a.cancel()}),this.changed.dispatch()}disposed(){const e=this.refCounted_;e!==void 0&&e.dispose()}toJSON(){const{loadState:e}=this;return e===void 0||e.error!==void 0?wg(this.spec):wg({url:this.spec.url,transform:e.transform.spec,enableDefaultSubsources:e.enableDefaultSubsources,subsources:new Map(Array.from(e.subsources,t=>{const n=e.enableDefaultSubsources&&t.subsourceEntry.default;return[t.subsourceEntry.id,{enabled:t.enabled!==n?t.enabled:void 0}]})),state:this.spec.state})}}/** + * @license + * Copyright 2021 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const Ui={side:"right",col:0,row:1/0,flex:1,size:300,minSize:100,visible:!1};class Si{constructor(e=Ui,t=e){this.defaultValue=e,this.value=t,this.changed=new j.HN,this.locationChanged=new j.HN,this.locationChanged.add(this.changed.dispatch);const n=this;this.watchableVisible={get value(){return n.visible},set value(s){n.visible=s},changed:n.locationChanged}}toJSON(e=this.defaultValue){const t={},{value:n}=this;for(const s in n)n[s]!==e[s]&&(t[s]=n[s]);return t}get visible(){return this.value.visible}set visible(e){const{value:t}=this;t.visible!==e&&(this.value={...t,visible:e},this.locationChanged.dispatch())}reset(){this.value!==this.defaultValue&&(this.value=this.defaultValue,this.locationChanged.dispatch())}restoreState(e,t=this.defaultValue){if(e===void 0)return;(0,f.Rf)(e);const n={side:(0,f.MM)(e,"side",s=>{if(s!=="left"&&s!=="right"&&s!=="top"&&s!=="bottom")throw new Error(`Expected "left", "right", "top", or "bottom", but received: ${JSON.stringify(s)}`);return s},t.side),col:(0,f.MM)(e,"col",f.zo,t.col),row:(0,f.MM)(e,"row",f.zo,t.row),flex:(0,f.MM)(e,"flex",f.zo,t.flex),size:(0,f.MM)(e,"size",f.We,t.size),visible:(0,f.MM)(e,"visible",f.aO,t.visible),minSize:t.minSize};this.value=n,this.locationChanged.dispatch()}}/** + * @license + * Copyright 2021 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const ca="tab",xg="tabs",Eg="panels",LT={...Ui,row:0},Tg={...Ui,visible:!0,row:0};class Ar extends T.O8{constructor(e){super(),this.panels=e,this.layer=this.panels.layer,this.location=new Si(Tg),this.tabsChanged=new j.HN,this.selectedTab=new _.B0(void 0),this.tabs=[]}initialize(){const{panels:e}=this;this.tabsChanged.add(e.specificationChanged.dispatch),this.selectedTab.changed.add(e.specificationChanged.dispatch),this.location.changed.add(()=>{e.specificationChanged.dispatch();const{layer:t}=this,{selectedLayer:n}=t.manager.root;if(n.layer?.layer!==t||this!==t.panels.panels[0])return;const s=this.location.value;n.location.value!==s&&(n.location.value=s,n.location.locationChanged.dispatch())}),this.location.locationChanged.add(()=>{this.location.visible||this!==this.panels.panels[0]&&this.panels.removePanel(this)});for(const t of this.tabs){const{hidden:n}=this.layer.tabs.options.get(t);n&&this.registerDisposer(n.changed.add(()=>{this.panels.updateTabs(),this.tabsChanged.dispatch()}))}}normalizeTabs(){const{tabs:e}=this;if(e.length===0){this.selectedTab.value=void 0;return}const t=this.layer.tabs.options,n=o=>t.get(o).order??0;e.sort((o,a)=>n(o)-n(a));const{selectedTab:s}=this,r=s.value;(r===void 0||!e.includes(r))&&(s.value=e[0])}pin(){const{layer:e}=this,{selectedLayer:t}=e.manager.root;if(t.layer?.layer!==e||this!==e.panels.panels[0]||this.tabs.length===0)return;const{panels:n}=this,s=e.registerDisposer(new Ar(n));n.panels.splice(0,1,s),n.panels.push(this),n.updateTabs(),s.initialize(),t.layerManager.layersChanged.dispatch(),this.panels.specificationChanged.dispatch()}unpin(){const{panels:e}=this,t=e.panels.indexOf(this);if(t===-1||t===0)return;const{layer:n}=this,{selectedLayer:s}=n.manager.root,r=s.layer?.layer;s.visible&&r!=null&&r!==n&&r.panels.panels[0].pin(),e.panels.splice(t,1);const[o]=e.panels.splice(0,1,this);if(this.explicitTabs===void 0)n.unregisterDisposer(o);else{e.panels.push(o);for(let a=1,l=e.panels.length;a(0,f.$v)(o,a=>{(0,f.Rf)(a);const l=new Ar(this);l.location.restoreState(a),l.location.visible&&(l.selectedTab.value=(0,f.MM)(a,ca,f.zr),l.explicitTabs=(0,f.MM)(a,xg,c=>{const d=new Set;for(const u of(0,f.si)(c))r.has(u)&&(r.delete(u),d.add(u));return d}),l.explicitTabs===void 0?(l.tabs=Array.from(r),r.clear()):l.tabs=Array.from(l.explicitTabs),l.tabs.length!==0&&(l.normalizeTabs(),n.registerDisposer(l),l.initialize(),t.push(l)))})),t[0].tabs=Array.from(r),t[0].normalizeTabs(),this.panels[0].initialize()}removePanel(e){if(this.updating)return;const t=this.panels.indexOf(e);this.panels.splice(t,1),this.layer.unregisterDisposer(e),this.updateTabs()}updateTabs(){const{layer:e}=this,{tabs:t}=e,n=new Set(t.options.keys()),{panels:s}=this;this.updating=!0;const r=o=>{const a=o.tabs;if(o.explicitTabs===void 0)o.tabs=Array.from(n),n.clear();else{o.tabs=Array.from(o.explicitTabs);for(const l of o.tabs)n.delete(l)}(0,F.r1)(a,o.tabs)||(o.normalizeTabs(),o.tabsChanged.dispatch())};for(let o=1;o1){const n=[];for(let s=1,r=e.length;sthis.updateDataSubsourceActivations()),this.messages.changed.add(this.layersChanged.dispatch);for(const t of Ag)this.tabs.add(t.id,{label:t.label,order:t.order,getter:()=>t.getter(this)})}get localPosition(){return this.managedLayer.localPosition}get localVelocity(){return this.managedLayer.localVelocity}get localCoordinateSpaceCombiner(){return this.managedLayer.localCoordinateSpaceCombiner}get localCoordinateSpace(){return this.managedLayer.localCoordinateSpace}get type(){return this.constructor.type}dispatchLayerEvent(e){this.layerEventListeners.get(e)?.dispatch()}registerLayerEvent(e,t){const{layerEventListeners:n}=this;let s=n.get(e);s||(s=new j.HN,n.set(e,s));const r=s.add(t);return()=>r()}initializeSelectionState(e){e.generation=-1,e.localPositionValid=!1,e.localPosition=ps,e.localCoordinateSpace=void 0,e.annotationId=void 0,e.annotationType=void 0,e.annotationBuffer=void 0,e.annotationIndex=void 0,e.annotationCount=void 0,e.annotationSourceIndex=void 0,e.annotationSubsource=void 0,e.annotationPartIndex=void 0,e.value=void 0}resetSelectionState(e){e.localPositionValid=!1,e.annotationId=void 0,e.value=void 0}selectionStateFromJson(e,t){const n=e.localCoordinateSpace=this.localCoordinateSpace.value,{rank:s}=n;if(s!==0){const o=(0,f.MM)(t,Qc,a=>(0,f.Xu)(new Float32Array(s),a,f.zo));o===void 0?e.localPositionValid=!1:(e.localPositionValid=!0,e.localPosition=o)}(e.annotationId=(0,f.MM)(t,"annotationId",f.zr))!==void 0&&(e.annotationSourceIndex=(0,f.MM)(t,"annotationSource",f.bX,0),e.annotationPartIndex=(0,f.MM)(t,"annotationPart",f.bX),e.annotationSubsource=(0,f.MM)(t,"annotationSubsource",f.zr)),e.value=t.value}displaySelectionState(e,t,n){return!1}selectionStateToJson(e,t){const n={};if(e.localPositionValid){const{localPosition:s}=e;s.length>0&&(n.localPosition=Array.from(s))}return e.annotationId!==void 0&&(n.annotationId=e.annotationId,n.annotationPart=e.annotationPartIndex,n.annotationSource=e.annotationSourceIndex,n.annotationSubsource=e.annotationSubsource),e.value!=null&&(n.value=e.value),n}captureSelectionState(e,t){e.localCoordinateSpace=this.localCoordinateSpace.value;const n=this.localPosition.value,{localPosition:s}=e;s.length!==n.length?e.localPosition=n.slice():s.set(n),e.localPositionValid=!0,e.value=this.getValueAt(t.position,t)}copySelectionState(e,t){e.generation=t.generation,e.localPositionValid=t.localPositionValid,e.localCoordinateSpace=t.localCoordinateSpace;const n=t.localPosition,{localPosition:s}=e;s.length!==n.length?e.localPosition=n.slice():e.localPosition.set(n),e.annotationId=t.annotationId,e.annotationType=t.annotationType,e.annotationBuffer=t.annotationBuffer,e.annotationIndex=t.annotationIndex,e.annotationCount=t.annotationCount,e.annotationSourceIndex=t.annotationSourceIndex,e.annotationSubsource=t.annotationSubsource,e.annotationPartIndex=t.annotationPartIndex,e.value=t.value}get isReady(){return this.loadingCounter===0}get manager(){return this.managedLayer.manager}canAddDataSource(){return!0}addDataSource(e){const t=new IT(this,e);return this.dataSources.push(t),this.dataSourcesChanged.dispatch(),t}activateDataSubsources(e){}updateDataSubsourceActivations(){function*e(){for(const t of this.dataSources){const{loadState:n}=t;if(!(n===void 0||n.error!==void 0))for(const s of n.subsources)if(s.enabled)yield s;else{const{activated:r}=s;s.messages.clearMessages(),r!==void 0&&(r.dispose(),s.activated=void 0,n.activatedSubsourcesChanged.dispatch())}}}this.activateDataSubsources(e.call(this))}decrementLoadingCounter(){--this.loadingCounter===0&&this.readyStateChanged.dispatch()}markLoading(){const e=this.localCoordinateSpaceCombiner.retain(),t=this.manager.root.coordinateSpaceCombiner.retain();return++this.loadingCounter===1&&this.readyStateChanged.dispatch(),()=>{e(),t(),this.decrementLoadingCounter()}}addCoordinateSpace(e){const t=this.manager.root.coordinateSpaceCombiner.bind(e),n=this.localCoordinateSpaceCombiner.bind(e);return()=>{t(),n()}}initializationDone(){const e=this.selectionState={};this.initializeSelectionState(e),this.decrementLoadingCounter()}getLegacyDataSourceSpecifications(e,t,n,s){return e===void 0?[]:[Pr(e,n)]}getDataSourceSpecifications(e){let t,n=(0,f.cQ)(e,kg,r=>Array.isArray(r)?r.map(o=>Pr(o)):typeof r=="object"?[Pr(r)]:(t=r,[]));const s=(0,f.cQ)(e,AT,PC);return n.push(...this.getLegacyDataSourceSpecifications(t,e,s,n)),n=n.filter(r=>r.url),n.length===0&&n.push(Sg()),n}restoreState(e){this.tool.restoreState(e[Dg]),this.panels.restoreState(e),this.localCoordinateSpace.restoreState(e[Rg]),this.localPosition.restoreState(e[Qc]),this.localVelocity.restoreState(e[Lg]),this.toolBinder.restoreState(e[Ig]),this.constructor.supportsPickOption&&this.pick.restoreState(e[Pg]);for(const t of this.getDataSourceSpecifications(e))this.addDataSource(t)}addRenderLayer(e){this.renderLayers.push(e);const{layersChanged:t}=this;return e.layerChanged.add(t.dispatch),e.userLayer=this,t.dispatch(),()=>this.removeRenderLayer(e)}removeRenderLayer(e){const{renderLayers:t,layersChanged:n}=this,s=t.indexOf(e);if(s===-1)throw new Error("Attempted to remove invalid RenderLayer");t.splice(s,1),e.layerChanged.remove(n.dispatch),e.userLayer=void 0,e.dispose(),n.dispatch()}disposed(){const{layersChanged:e}=this;(0,T.$F)(this.dataSources);for(const t of this.renderLayers)t.layerChanged.remove(e.dispatch),t.dispose();this.renderLayers.length=0,super.disposed()}getValueAt(e,t){let n;const{renderLayers:s}=this,{pickedRenderLayer:r}=t;if(r!==null&&s.indexOf(r)!==-1&&(n=r.transformPickedValue(t),n=this.transformPickedValue(n),n!=null))return n;for(const o of s)if(n=o.getValueAt(e),n!=null)break;return this.transformPickedValue(n)}transformPickedValue(e){return e}toJSON(){return{type:this.type,[kg]:NT(this.dataSources),[Dg]:this.tool.toJSON(),[Ig]:this.toolBinder.toJSON(),[Rg]:this.localCoordinateSpace.toJSON(),[Qc]:this.localPosition.toJSON(),[Lg]:this.localVelocity.toJSON(),[Pg]:this.pick.toJSON(),...this.panels.toJSON()}}handleAction(e,t){}selectedValueToJson(e){return e}selectedValueFromJson(e){return e}setLayerPosition(e,t){const{globalPosition:n}=this.manager.root,{localPosition:s}=this;(0,F.b8)(n.value,t,e.globalToRenderLayerDimensions),(0,F.b8)(s.value,t,e.localToRenderLayerDimensions),s.changed.dispatch(),n.changed.dispatch()}}Rn.supportsPickOption=!1;function NT(i){if(i.length!==0)return i.length===1?i[0].toJSON():i.map(e=>e.toJSON())}class Kc extends T.O8{constructor(e,t){super(),this.manager=t,this.localCoordinateSpace=new zl,this.localCoordinateSpaceCombiner=new Ql(this.localCoordinateSpace,rr),this.localPosition=this.registerDisposer(new ui(this.localCoordinateSpace)),this.localVelocity=this.registerDisposer(new gc(this.localCoordinateSpace)),this.nonArchivedLayerIndex=-1,this.readyStateChanged=new j.IY,this.layerChanged=new j.IY,this.specificationChanged=new j.IY,this.containers=new Set,this.layer_=null,this.visible=!0,this.archived=!1,this.name_=e,this.registerDisposer(new mc(this.manager.root.display,this.localPosition,this.localVelocity))}get layer(){return this.layer_}set layer(e){const t=this.layer_;if(t!=null&&(this.unregisterUserLayer(),t.dispose()),this.layer_=e,e!=null){const n=[e.layersChanged.add(this.layerChanged.dispatch),e.readyStateChanged.add(this.readyStateChanged.dispatch),e.specificationChanged.add(this.specificationChanged.dispatch)];this.unregisterUserLayer=()=>{n.forEach(s=>s())},this.readyStateChanged.dispatch(),this.layerChanged.dispatch()}}isReady(){const{layer:e}=this;return e?.isReady}get name(){return this.name_}set name(e){e!==this.name_&&(this.name_=e,this.layerChanged.dispatch())}get supportsPickOption(){const e=this.layer;return e!==null&&e.constructor.supportsPickOption}get pickEnabled(){const e=this.layer;return e!==null&&e.constructor.supportsPickOption&&e.pick.value}set pickEnabled(e){const t=this.layer;t!==null&&t.constructor.supportsPickOption&&(t.pick.value=e)}toJSON(){const e=this.layer;if(e===null)return;const t=e.toJSON();return t.name=this.name,this.visible||(this.archived?t.archived=!0:t.visible=!1),t}setVisible(e){if(e!==this.visible){if(e&&this.archived){this.visible=!0,this.setArchived(!1);return}this.visible=e,this.layerChanged.dispatch()}}setArchived(e){if(this.archived!==e){if(e===!0){this.visible=!1,this.archived=!0;for(const{layerManager:t}of this.manager.root.subsets)t.has(this)&&t.removeManagedLayer(this)}else{for(const{layerManager:t}of this.manager.root.subsets)t.has(this)||t.addManagedLayer(this.addRef());this.archived=!1}this.layerChanged.dispatch()}}disposed(){this.layer=null,super.disposed()}}class Mg extends T.O8{constructor(){super(),this.managedLayers=new Array,this.layerSet=new Set,this.layersChanged=new j.IY,this.readyStateChanged=new j.IY,this.specificationChanged=new j.IY,this.boundPositions=new WeakSet,this.numDirectUsers=0,this.nonArchivedLayerIndexGeneration=-1,this.renderLayerToManagedLayerMapGeneration=-1,this.renderLayerToManagedLayerMap_=new Map,this.scheduleRemoveLayersWithSingleRef=this.registerCancellable((0,Fe.A)(()=>this.removeLayersWithSingleRef(),0)),this.layersChanged.add(this.scheduleRemoveLayersWithSingleRef)}updateNonArchivedLayerIndices(){const e=this.layersChanged.count;if(e===this.nonArchivedLayerIndexGeneration)return;this.nonArchivedLayerIndexGeneration=e;let t=0;for(const n of this.managedLayers)n.archived||(n.nonArchivedLayerIndex=t++);for(const n of this.managedLayers)n.archived&&(n.nonArchivedLayerIndex=t++)}getLayerByNonArchivedIndex(e){let t=0;for(const n of this.managedLayers)if(!n.archived){if(t===e)return n;++t}}get renderLayerToManagedLayerMap(){const e=this.layersChanged.count,t=this.renderLayerToManagedLayerMap_;if(this.renderLayerToManagedLayerMapGeneration!==e){this.renderLayerToManagedLayerMapGeneration=e,t.clear();for(const n of this.managedLayers){const s=n.layer;if(s!==null)for(const r of s.renderLayers)t.set(r,n)}}return t}filter(e){let t=!1;this.managedLayers=this.managedLayers.filter(n=>e(n)?!0:(this.unbindManagedLayer(n),this.layerSet.delete(n),t=!0,!1)),t&&this.layersChanged.dispatch()}removeLayersWithSingleRef(){this.numDirectUsers>0||this.filter(e=>e.refCount!==1||e.archived)}updateSignalBindings(e,t){t(e.layerChanged,this.layersChanged.dispatch),t(e.readyStateChanged,this.readyStateChanged.dispatch),t(e.specificationChanged,this.specificationChanged.dispatch)}useDirectly(){return++this.numDirectUsers===1&&this.layersChanged.remove(this.scheduleRemoveLayersWithSingleRef),()=>{--this.numDirectUsers===0&&(this.layersChanged.add(this.scheduleRemoveLayersWithSingleRef),this.scheduleRemoveLayersWithSingleRef())}}addManagedLayer(e,t){return this.updateSignalBindings(e,PT),this.layerSet.add(e),e.containers.add(this),t===void 0&&(t=this.managedLayers.length),this.managedLayers.splice(t,0,e),this.layersChanged.dispatch(),this.readyStateChanged.dispatch(),e}*readyRenderLayers(){for(const e of this.managedLayers)!e.visible||!e.layer||(yield*e.layer.renderLayers)}unbindManagedLayer(e){this.updateSignalBindings(e,kT),e.containers.delete(this),e.manager.rootLayers.layersChanged.dispatch(),e.dispose()}clear(){for(const e of this.managedLayers)this.unbindManagedLayer(e);this.managedLayers.length=0,this.layerSet.clear(),this.layersChanged.dispatch()}remove(e){const t=this.managedLayers[e];this.unbindManagedLayer(t),this.managedLayers.splice(e,1),this.layerSet.delete(t),this.layersChanged.dispatch()}removeManagedLayer(e){const t=this.managedLayers.indexOf(e);if(t===-1)throw new Error("Internal error: invalid managed layer.");this.remove(t)}reorderManagedLayer(e,t){const n=this.managedLayers.length;if(e===t||e<0||e>=n||t<0||t>=n)return;const[s]=this.managedLayers.splice(e,1);this.managedLayers.splice(t,0,s),this.layersChanged.dispatch()}disposed(){this.clear(),super.disposed()}getLayerByName(e){return this.managedLayers.find(t=>t.name===e)}getUniqueLayerName(e){let t=e,n=0;for(;this.getLayerByName(t)!==void 0;)t=e+ ++n;return t}has(e){return this.layerSet.has(e)}get renderLayers(){const e=this;return{*[Symbol.iterator](){for(const t of e.managedLayers)if(t.layer!==null)for(const n of t.layer.renderLayers)yield n}}}get visibleRenderLayers(){const e=this;return{*[Symbol.iterator](){for(const t of e.managedLayers)if(!(t.layer===null||!t.visible))for(const n of t.layer.renderLayers)yield n}}}invokeAction(e){const t=new MT;for(const n of this.managedLayers){if(n.layer===null||!n.visible)continue;const s=n.layer;s.handleAction(e,t);for(const r of s.renderLayers)r.handleAction(e)}for(const n of t.callbacks)n()}}class OT{constructor(){this.changed=new j.IY,this.coordinateSpace=Fn,this.position=ps,this.unsnappedPosition=ps,this.active=!1,this.displayDimensions=void 0,this.pickedRenderLayer=null,this.pickedValue=new P.R(0,0),this.pickedOffset=0,this.pickedAnnotationLayer=void 0,this.pickedAnnotationId=void 0,this.pickedAnnotationBuffer=void 0,this.pickedAnnotationBufferBaseOffset=void 0,this.pickedAnnotationIndex=void 0,this.pickedAnnotationCount=void 0,this.pickedAnnotationType=void 0,this.forcerFunction=void 0}removeForcer(e){e===this.forcerFunction&&(this.forcerFunction=void 0,this.setActive(!1))}setForcer(e){this.forcerFunction=e,e===void 0&&this.setActive(!1)}updateUnconditionally(){const{forcerFunction:e}=this;return e===void 0?!1:(e(),this.active)}setActive(e){(this.active!==e||e===!0)&&(this.active=e,this.changed.dispatch())}}class _T extends T.O8{constructor(e,t){super(),this.layerManager=e,this.mouseState=t,this.changed=new j.IY,this.needsUpdate=!0,this.registerDisposer(t.changed.add(()=>{this.handleChange()})),this.registerDisposer(e.layersChanged.add(()=>{this.handleLayerChange()}))}handleLayerChange(){this.mouseState.active&&this.handleChange()}handleChange(){this.needsUpdate=!0,this.changed.dispatch()}update(){if(!this.needsUpdate)return;this.needsUpdate=!1;const e=this.mouseState,t=this.changed.count;if(e.active)for(const n of this.layerManager.managedLayers){const s=n.layer;if(n.visible&&s!==null){const{selectionState:r}=s;s.resetSelectionState(r),r.generation=t,s.captureSelectionState(r,e)}}}get(e){this.update();const{selectionState:t}=e;if(t.generation===this.changed.count)return t}toJSON(){this.update();const e={};for(const t of this.layerManager.managedLayers){const n=t.layer;if(n){const s=this.get(n);s!==void 0&&(e[t.name]=n.selectionStateToJson(s,!0))}}return e}}const Ng=10,qc={...Ui,minSize:150,row:1},Og={...qc,visible:!0};class VT extends T.O8{constructor(e,t){super(),this.coordinateSpace=e,this.layerSelectedValues=t,this.changed=new j.IY,this.history=[],this.historyIndex=0,this.location=new Si(qc),this.pin=new _.B0(!0),this.registerDisposer((0,_.no)((n,s)=>{s||(this.capture(!0),n.registerDisposer(t.changed.add(n.registerCancellable((0,la.A)(()=>this.capture(!0),100,{leading:!0,trailing:!0})))))},this.pin)),this.pin.changed.add(this.changed.dispatch),this.location.changed.add(this.changed.dispatch)}get value(){return this.value_}goBack(){const e=this.pin.value?this.historyIndex:this.history.length;e>0&&(this.historyIndex=e-1,this.value_=this.history[e-1],this.pin.value=!0,this.changed.dispatch())}canGoBack(){return(this.pin.value?this.historyIndex:this.history.length)>0}canGoForward(){return this.pin.value?this.historyIndex+1Ng&&t.splice(0,t.length-Ng),this.historyIndex=t.length-1}this.changed.dispatch()}}captureSingleLayerState(e,t,n=!0){if(n===!1&&(!this.location.visible||this.pin.value))return;const s={};e.initializeSelectionState(s),t(s)&&(this.location.visible=!0,n===!0?this.pin.value=!0:n==="toggle"&&(this.pin.value=!this.pin.value),this.value={layers:[{layer:e,state:s}],coordinateSpace:this.coordinateSpace.value,position:void 0})}reset(){this.location.reset(),this.pin.value=!1,this.value=void 0}toJSON(){const{value:e}=this;let t;if(this.location.visible){if(t=this.location.toJSON(Og),this.pin.value&&e!==void 0){const n={};for(const s of e.layers){const{layer:r}=s;let o=r.selectionStateToJson(s.state,!1);Object.keys(o).length===0&&(o=void 0),n[s.layer.managedLayer.name]=o}e.position!==void 0&&(t.position=Array.from(e.position)),t.layers=n}}else t=this.location.toJSON(qc),t=(0,f.Zu)(t),t!==void 0&&(t.visible=!1);return t}select(){const{pin:e}=this;this.location.visible=!0,e.value=!e.value,e.value&&this.capture()}capture(e=!1){const t=BT(this.layerSelectedValues);e&&t===void 0||(this.value=t)}restoreState(e){if(e===void 0){this.pin.value=!0,this.value=void 0;return}if(e===null){this.pin.value=!1,this.location.visible=!0,this.value=void 0;return}(0,f.Rf)(e),this.location.restoreState(e,Og);const t=this.coordinateSpace.value,n=(0,f.MM)(e,"position",r=>(0,f.Xu)(new Float32Array(t.rank),r,f.zo)),s=[];(0,f.MM)(e,"layers",r=>{(0,f.Rf)(r);const{layerManager:o}=this.layerSelectedValues;for(const[a,l]of Object.entries(r)){const c=o.getLayerByName(a);if(c===void 0)return;const d=c.layer;if(d===null)return;(0,f.Rf)(l);const u={};d.initializeSelectionState(u),d.selectionStateFromJson(u,l),s.push({layer:d,state:u})}}),this.pin.value=s.length>0||n!==void 0,this.value={position:n,coordinateSpace:t,layers:s}}}function BT(i){const{mouseState:e}=i;if(!e.active)return;const t=[];for(const n of i.layerManager.managedLayers){const s=n.layer;if(s===null)continue;const r=i.get(s);if(r===void 0)continue;const o={};s.initializeSelectionState(o),s.copySelectionState(o,r),t.push({layer:s,state:o})}return{position:e.position.slice(),coordinateSpace:e.coordinateSpace,layers:t}}class FT extends T.O8{constructor(e){super(),this.view=e,this.messages=new ai,this.seenGeneration=-1,this.state=void 0}}let UT=0;class $T extends T.O8{constructor(e,t,n,s,r,o){super(),this.layerManager=e,this.renderLayerType=t,this.view=n,this.roles=s,this.layerAdded=r,this.visibility=o,this.visibleLayers_=new Map,this.debouncedUpdateVisibleLayers=this.registerCancellable((0,Fe.A)(()=>this.updateVisibleLayers(),0)),this.registerDisposer(e.layersChanged.add(this.debouncedUpdateVisibleLayers)),this.registerDisposer(s.changed.add(this.debouncedUpdateVisibleLayers)),this.updateVisibleLayers()}disposed(){this.visibleLayers.forEach(e=>e.dispose()),this.visibleLayers.clear(),super.disposed()}updateVisibleLayers(){const e=++UT,{visibleLayers_:t,renderLayerType:n,layerAdded:s,roles:r}=this;for(const o of this.layerManager.readyRenderLayers())if(o instanceof n&&r.has(o.role)){const a=o;let l=t.get(a);l===void 0&&(l=new FT(this.view),l.registerDisposer(a.messages.addChild(l.messages)),l.registerDisposer(a.addRef()),l.registerDisposer(a.visibility.add(this.visibility)),t.set(a,l),s(a,l),a.attach(l)),l.seenGeneration=e}for(const[o,a]of t)a.seenGeneration!==e&&(t.delete(o),a.dispose())}get visibleLayers(){return this.debouncedUpdateVisibleLayers.flush(),this.visibleLayers_}}function _g(i,e,t,n,s){return n.registerDisposer(new $T(i,e,n,t,(r,o)=>{o.registerDisposer(r.redrawNeeded.add(()=>n.scheduleRedraw()));const{backend:a}=r;a&&(a.rpc.invoke(go.sC,{layer:a.rpcId,view:n.rpcId}),o.registerDisposer(()=>a.rpc.invoke(go.lG,{layer:a.rpcId,view:n.rpcId}))),s!==void 0&&s(r,o),n.scheduleRedraw(),o.registerDisposer(()=>n.scheduleRedraw())},n.visibility))}class GT extends T.O8{constructor(e){super(),this.layerManager=e,this.changed=new j.IY,this.location=new Si(LT),this.registerDisposer(e),this.location.changed.add(()=>{this.changed.dispatch();const t=this.layer?.layer??void 0;if(t!==void 0){const n=this.location.value;if(n.visible){const s=t.panels.panels[0];s.location.value!==n&&(s.location.value=n,s.location.locationChanged.dispatch())}}})}get layer(){return this.layer_}get visible(){return this.location.visible}toggle(e){this.layer===e&&this.visible?this.visible=!1:(this.layer=e,this.visible=!0)}set visible(e){let t=this.layer_;if(e===!0&&t===void 0){const{managedLayers:n}=this.layerManager;n.length>0?t=this.layer=n[0]:e=!1}if(e===!0&&t!==void 0){const n=t.layer;(n===null||n.panels.panels[0].tabs.length===0)&&(e=!1)}this.visible!==e&&(this.location.visible=e,!e&&t!==void 0&&this.maybeDeleteNewLayer(t),this.changed.dispatch())}maybeDeleteNewLayer(e){if(e.wasDisposed)return;const t=e.layer;t!==null&&t instanceof jn&&(t.dataSources.some(n=>n.spec.url.length!==0)||Ms(e))}set layer(e){if(e===this.layer_)return;const t=this.layer_;if(t!==void 0&&(this.existingLayerDisposer(),this.existingLayerDisposer=void 0,this.maybeDeleteNewLayer(t)),this.layer_=e,e!==void 0){const n=()=>{this.layer_=void 0,this.visible=!1,this.existingLayerDisposer=void 0,this.changed.dispatch()};e.registerDisposer(n);const s=e.specificationChanged.add(()=>{this.changed.dispatch()});this.existingLayerDisposer=()=>{const r=e.layer;if(r!==null){const o=r.tool.value;o!==void 0&&o.deactivate()}e.unregisterDisposer(n),s()}}else this.location.visible=!1;this.changed.dispatch()}toJSON(){const e=this.location.toJSON();return this.layer!==void 0&&(e.layer=this.layer.name),(0,f.Zu)(e)}restoreState(e){if(e===void 0){this.reset();return}(0,f.Rf)(e),this.location.restoreState(e);const t=(0,f.cQ)(e,"layer",f.z$),n=t!==void 0?this.layerManager.getLayerByName(t):void 0;n===void 0&&(this.visible=!1),this.layer=n}reset(){this.location.reset(),this.layer=void 0}}class zT extends T.O8{constructor(e,t){super(),this.layerManager=e,this.filter=t,this.changed=new j.IY,this.validate=(0,Fe.A)(()=>{const{layerName_:n}=this;if(n!==void 0){const s=this.layerManager.getLayerByName(n);s!==void 0&&this.filter(s)?(this.layer_=s,this.changed.dispatch()):(this.layer_=void 0,this.layerName_=void 0,this.changed.dispatch())}},0),this.registerDisposer(e),this.registerDisposer(e.specificationChanged.add(()=>{const{layer_:n}=this;if(n!==void 0)if(!this.layerManager.layerSet.has(n)||!this.filter(n))this.layer_=void 0,this.layerName_=void 0,this.changed.dispatch();else{const{name:s}=n;s!==this.layerName_&&(this.layerName_=s,this.changed.dispatch())}}))}get layer(){return this.layer_}get layerName(){return this.layerName_}set layer(e){this.layer_!==e&&(e!==void 0&&this.layerManager.layerSet.has(e)&&this.filter(e)?(this.layer_=e,this.layerName_=e.name):(this.layer_=void 0,this.layerName_=void 0),this.changed.dispatch())}set layerName(e){e!==this.layerName_&&(this.layer_=void 0,this.layerName_=e,this.changed.dispatch(),this.validate())}restoreState(e){const t=(0,f.z$)(e);this.layerName=t}toJSON(){const{layer_:e}=this;return e!==void 0?e.name:this.layerName_}reset(){this.layerName_=void 0,this.layer_=void 0,this.changed.dispatch()}}class Vg extends T.O8{constructor(e,t,n,s){super(),this.layerManager=e,this.layer=t,this.predicate=n,this.getGroup=s,this.linkedLayers_=new Set,this.changed=new j.IY,this.linkedLayersChanged=new j.IY,this.root_=t;const r=this;this.root={get value(){return r.root_},changed:r.changed}}get linkedLayers(){return this.linkedLayers_}get rootGroup(){return this.getGroup(this.root.value)}reset(){this.isolate()}restoreState(e){if(e===void 0)return;const t=(0,f.zr)(e);this.linkByName(t)}toJSON(){const{root:{value:e}}=this;if(e!==this.layer)return e.managedLayer.name}isolate(e=!0){const{getGroup:t,layer:n,root_:s}=this;if(s===n){const{linkedLayers_:o}=this;if(o.size!==0){for(const a of o){const l=t(a);l.root_=a,l.changed.dispatch()}o.clear(),this.linkedLayersChanged.dispatch()}return}const r=t(s);r.linkedLayers_.delete(n),r.linkedLayersChanged.dispatch(),this.root_=n,e&&this.changed.dispatch()}linkByName(e){const{layer:t}=this,{managedLayer:n}=t,{layerManager:s}=this,r=s.getLayerByName(e);if(r===void 0||r===n)return;const o=r.layer;o!==null&&this.predicate(o)&&this.linkToLayer(o)}linkToLayer(e){if(e===this.layer||this.root_===e)return;this.root_!==this.layer&&this.isolate(!1);const{getGroup:t}=this,n=t(e).root_;if(n===this.layer)return;const s=t(n);s.linkedLayers_.add(this.layer),s.linkedLayersChanged.dispatch(),this.root_=n,this.changed.dispatch()}disposed(){this.isolate(!1)}}function Bg(i,e){const t=(0,f.MM)(e,"type",f.zr,"auto");i.archived=(0,f.MM)(e,"archived",f.aO,!1),i.archived?i.visible=!1:i.visible=(0,f.MM)(e,"visible",f.aO,!0);const n=Mr.get(t)||jn;return i.layer=new n(i),e}function Fg(i,e){try{const t=i.layer;if(t===null)return;t.restoreState(e),t.initializationDone()}catch(t){throw Ms(i),t}}function Ug(i,e){try{(0,f.Rf)(e),Bg(i,e),Fg(i,e)}catch(t){throw Ms(i),t}}function WT(i,e){try{Ug(i,e)}catch(t){new pe().setErrorMessage(t instanceof Error?t.message:""+t)}}function $g(i,e,t){const n=new Kc(e,i);return Ug(n,t),n}class Gg extends T.O8{constructor(){super(...arguments),this.changed=new j.IY}}class HT extends Gg{constructor(e,t,n,s,r,o,a,l,c){super(),this.display=e,this.dataSourceProviderRegistry=t,this.layerManager=n,this.chunkManager=s,this.selectionState=r,this.selectedLayer=o,this.coordinateSpace=a,this.globalPosition=l,this.toolBinder=c,this.coordinateSpaceCombiner=new Ql(this.coordinateSpace,DC),this.subsets=new Set,this.layerSelectedValues=this.selectionState.layerSelectedValues,this.registerDisposer(n.layersChanged.add(this.changed.dispatch)),this.registerDisposer(n.specificationChanged.add(this.changed.dispatch))}get rpc(){return this.chunkManager.rpc}get root(){return this}reset(){this.layerManager.clear()}restoreState(e){this.layerManager.clear();let t;Array.isArray(e)?t=e:((0,f.Rf)(e),t=Object.entries(e).map(([s,r])=>typeof r=="string"?{name:s,source:r}:((0,f.Rf)(r),{...r,name:s})));const n=[];for(const s of t){(0,f.Rf)(s);const r=this.layerManager.getUniqueLayerName((0,f.cQ)(s,"name",f.zr)),o=new Kc(r,this);try{Bg(o,s),this.layerManager.addManagedLayer(o),n.push({managedLayer:o,spec:s})}catch(a){o.dispose(),new pe().setErrorMessage(`Error creating layer ${JSON.stringify(r)}: `+(a instanceof Error)?a.message:""+a)}}for(const{managedLayer:s,spec:r}of n)try{Fg(s,r)}catch(o){new pe().setErrorMessage(`Error creating layer ${JSON.stringify(name)}: `+(o instanceof Error)?o.message:""+o)}}add(e,t){this.layerManager.managedLayers.indexOf(e)===-1&&(e.name=this.layerManager.getUniqueLayerName(e.name)),this.layerManager.addManagedLayer(e,t)}toJSON(){const e=[];let t=0;for(const n of this.layerManager.managedLayers){const s=n.toJSON();s!=null&&(e.push(s),++t)}if(t!==0)return e}get rootLayers(){return this.layerManager}}class zg extends Gg{constructor(e){super(),this.master=e,this.changed=new j.IY,this.layerManager=this.registerDisposer(new Mg),this.registerDisposer(e);const{layerManager:t}=this;this.registerDisposer(t.layersChanged.add(this.changed.dispatch)),this.registerDisposer(t.specificationChanged.add(this.changed.dispatch)),e.subsets.add(this)}get rpc(){return this.master.rpc}get dataSourceProviderRegistry(){return this.master.dataSourceProviderRegistry}get chunkManager(){return this.master.chunkManager}get layerSelectedValues(){return this.master.layerSelectedValues}get root(){return this.master}disposed(){super.disposed(),this.master.subsets.delete(this)}reset(){this.layerManager.clear()}restoreState(e){const t=this.master.layerManager,n=[];for(const s of new Set((0,f.$v)(e,f.zr))){const r=t.getLayerByName(s);if(r===void 0)throw new Error(`Undefined layer referenced in subset specification: ${JSON.stringify(s)}`);r.archived||n.push(r)}this.layerManager.clear();for(const s of n)this.layerManager.addManagedLayer(s.addRef())}toJSON(){return this.layerManager.managedLayers.map(e=>e.name)}add(e,t){this.master.layerManager.managedLayers.indexOf(e)===-1&&(e.name=this.master.layerManager.getUniqueLayerName(e.name),this.master.layerManager.addManagedLayer(e.addRef())),this.layerManager.addManagedLayer(e,t)}get rootLayers(){return this.master.rootLayers}}const Mr=new Map,Xc=new Map,Wg=[i=>{const{volume:e}=i;if(e===void 0)return;const t=Xc.get(e.volumeType);if(t!==void 0)return{layerConstructor:t,priority:0}}];function $i(i,e=i.type){Mr.set(e,i)}function da(i){Wg.push(i)}function Hg(i,e){Xc.set(i,e)}function Zc(i,e){const t=i.layer;if(t===null)return;const n=t.toJSON(),s=new e(i);s.restoreState(n),s.initializationDone(),i.layer=s}function Jg(i,e){return e!==i.name?(e=i.manager.root.layerManager.getUniqueLayerName(e),i.name=e,i.layerChanged.dispatch(),!0):!1}function Ms(i){if(!i.wasDisposed)for(const e of i.containers)e.removeManagedLayer(i)}function ua(i,e){return i===void 0?e:e===void 0?i:i.priority{r&&o.appendChild(sm(a,e,n,t))},t)).element}function gd(i,e){const{toolJson:t}=e,n=typeof t=="string"?t:t.type;sn(i,n,s=>new im(s,e))}/** + * @license + * Copyright 2021 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function Nr(i){return{makeControl:(e,t)=>{const n=i(e),s=t.registerDisposer(new pn(n));return{control:s,controlElement:s.element}},activateTool:(e,t)=>{t.model.value=!t.model.value}}}/** + * @license + * Copyright 2021 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const QT=Ae.fromObject({"at:shift+wheel":{action:"adjust-via-wheel"}});function md(i){return{makeControl:(e,t)=>{const n=i(e),s=t.registerDisposer(new Bo(n));return{control:s,controlElement:s.element}},activateTool:(e,t)=>{e.bindInputEventMap(QT),e.bindAction("adjust-via-wheel",n=>{n.stopPropagation(),n.preventDefault(),t.adjustViaWheel(n.detail)})}}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class KT extends T.O8{constructor(e,{min:t=0,max:n=1,step:s=.01}={}){super(),this.value=e,this.element=document.createElement("label"),this.inputElement=document.createElement("input"),this.numericInputElement=document.createElement("input");const{element:r,inputElement:o,numericInputElement:a}=this;r.className="range-slider";const l=d=>{d.min=""+t,d.max=""+n,d.step=""+s,d.valueAsNumber=this.value.value,this.registerEventListener(d,"change",()=>this.inputValueChanged(d)),this.registerEventListener(d,"input",()=>this.inputValueChanged(d)),this.registerEventListener(d,"wheel",u=>{this.adjustViaWheel(d,u)})};o.type="range",l(o),a.type="number";const c=Math.max(t.toString().length,n.toString().length,Math.min(n,t+s).toString().length,Math.max(t,n-s).toString().length);a.style.width=c+2+"ch",l(a),r.appendChild(o),r.appendChild(a),e.changed.add(()=>{this.inputElement.valueAsNumber=this.value.value,this.numericInputElement.valueAsNumber=this.value.value})}inputValueChanged(e){this.value.value=e.valueAsNumber}adjustViaWheel(e,t){const n=this.inputElement,{deltaY:s}=t;s>0?(n.stepUp(),this.inputValueChanged(e)):s<0&&(n.stepDown(),this.inputValueChanged(e))}disposed(){at(this.element),super.disposed()}}/** + * @license + * Copyright 2021 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const qT=Ae.fromObject({"at:shift+wheel":{action:"adjust-via-wheel"}});function Yn(i){return{makeControl:(e,t)=>{const{value:n,options:s}=i(e),r=t.registerDisposer(new KT(n,s));return{control:r,controlElement:r.element}},activateTool:(e,t)=>{e.bindInputEventMap(qT),e.bindAction("adjust-via-wheel",n=>{n.stopPropagation(),n.preventDefault(),t.adjustViaWheel(t.inputElement,n.detail)})}}}/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function rm(i,e){let t="";for(let n=0;n<=e&&(t=i.toFixed(n),parseFloat(t)!==i);++n);return t}/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const XT=200,om=Ae.fromObject({mousedown0:{action:"set"},wheel:{action:"adjust-via-wheel"},dblclick0:{action:"reset"}});function ZT(i){if(i<1||i>1024){const e=Math.log2(i)|0,t=i/2**e;return`${rm(t,1)}p${e}`}return Math.round(i)+""}class ga extends T.O8{constructor(e,t){super(),this.histogram=e,this.target=t,this.label=document.createElement("div"),this.element=document.createElement("div"),this.canvas=document.createElement("canvas"),this.legend=document.createElement("div"),this.legendRenderScale=document.createElement("div"),this.legendSpatialScale=document.createElement("div"),this.legendChunks=document.createElement("div"),this.logScaleOrigin=ks,this.unitOfTarget="px",this.ctx=this.canvas.getContext("2d"),this.hoverTarget=new _.B0(void 0),this.throttledUpdateView=this.registerCancellable((0,la.A)(()=>this.debouncedUpdateView(),XT,{leading:!0,trailing:!0})),this.debouncedUpdateView=this.registerCancellable((0,Fe.A)(()=>this.updateView(),0));const{canvas:n,label:s,element:r,legend:o,legendRenderScale:a,legendSpatialScale:l,legendChunks:c}=this;s.className="neuroglancer-render-scale-widget-prompt",r.className="neuroglancer-render-scale-widget",r.title=om.describe(),o.className="neuroglancer-render-scale-widget-legend",r.appendChild(s),r.appendChild(n),r.appendChild(o),a.title="Target resolution of data in screen pixels",c.title="Number of chunks rendered",o.appendChild(a),o.appendChild(c),o.appendChild(l),this.registerDisposer(e.changed.add(this.throttledUpdateView)),this.registerDisposer(e.visibility.changed.add(this.debouncedUpdateView)),this.registerDisposer(t.changed.add(this.debouncedUpdateView)),this.registerDisposer(new tn(n,om)),this.registerDisposer(t.changed.add(this.debouncedUpdateView)),this.registerDisposer(this.hoverTarget.changed.add(this.debouncedUpdateView));const d=h=>{const p=h.offsetX/n.width*mt;return aT(p,this.logScaleOrigin)};this.registerEventListener(n,"pointermove",h=>{this.hoverTarget.value=[d(h),h.offsetY]}),this.registerEventListener(n,"pointerleave",()=>{this.hoverTarget.value=void 0}),this.registerDisposer(Z(n,"set",h=>{this.target.value=d(h.detail)})),this.registerDisposer(Z(n,"adjust-via-wheel",h=>{this.adjustViaWheel(h.detail)})),this.registerDisposer(Z(n,"reset",h=>{this.reset(),h.preventDefault()}));const u=new ResizeObserver(()=>this.debouncedUpdateView());u.observe(n),this.registerDisposer(()=>u.disconnect()),this.updateView()}adjustViaWheel(e){const t=this.getWheelMoveValue(e);if(t===0)return;this.hoverTarget.value=void 0;const n=Math.round(this.logScaleOrigin+mt*Ir),s=Pe([2**this.logScaleOrigin,2**(n-1)],this.target.value*2**Math.sign(t));this.target.value=s,e.preventDefault()}getWheelMoveValue(e){return e.deltaY}reset(){this.hoverTarget.value=void 0,this.target.reset()}updateView(){const{ctx:e}=this,{canvas:t}=this,n=t.width=t.offsetWidth,s=t.height=t.offsetHeight,r=this.target.value,o=this.hoverTarget.value;{const{legendRenderScale:E}=this,D=o===void 0?r:o[0],I=ZT(D);E.textContent=I+" "+this.unitOfTarget}function a(E){return E*n/mt}e.clearRect(0,0,n,s);const{histogram:l}=this,{value:c,spatialScales:d}=l;l.visibility.visible||c.fill(0);const u=Array.from(d.keys());u.sort();const h=C.eR.create();let p=1;const m=d.size;let g=0,v=0;for(let E=0;E=0&&E=0;--L){const N=u[L],O=2*d.get(N)*mt+E,V=c[O]+c[O+mt];if(V===0)continue;const z=Math.round(w(D));if(D+=V,Math.round(w(D))<=I&&I<=z){b=N;break}}}}if(b!==void 0){g=0,v=0;const D=2*d.get(b)*mt;for(let I=0;I{const D=E===b?.5:1;let I;Number.isFinite(E)?I=(Math.log2(E)*.1%1+1)%1:I=0,Mo(h,I,D,1);const L=Ge(h);Mo(h,I,D,.5);const N=Ge(h);return[L,N]});for(let E=0;E=0;--I){const L=u[I],k=d.get(L)*mt*2+E,O=c[k],V=c[k+mt],z=O+V;if(z===0)continue;const Y=Math.round(a(E)),Q=Math.round(a(E+1)),X=Math.round(w(D));D+=z;const ce=Math.round(w(D)),oe=(O*ce+V*X)/z;e.fillStyle=x[I][1],e.fillRect(Y,ce,Q-Y,oe-ce),e.fillStyle=x[I][0],e.fillRect(Y,oe,Q-Y,X-oe)}}{const E=r;e.fillStyle="#fff";const D=a(ea(E,this.logScaleOrigin));e.fillRect(Math.floor(D),0,1,s)}if(o!==void 0){const E=o[0];e.fillStyle="#888";const D=a(ea(E,this.logScaleOrigin));e.fillRect(Math.floor(D),0,1,s)}}}class eD extends ga{constructor(){super(...arguments),this.unitOfTarget="samples",this.logScaleOrigin=1}getWheelMoveValue(e){return-e.deltaY}}const tD=Ae.fromObject({"at:shift+wheel":{action:"adjust-via-wheel"},"at:shift+dblclick0":{action:"reset"}});function ma(i,e=ga){return{makeControl:(t,n)=>{const{histogram:s,target:r}=i(t),o=n.registerDisposer(new e(s,r));return{control:o,controlElement:o.element}},activateTool:(t,n)=>{t.bindInputEventMap(tD),t.bindAction("adjust-via-wheel",s=>{s.stopPropagation(),s.preventDefault(),n.adjustViaWheel(s.detail)}),t.bindAction("reset",s=>{s.stopPropagation(),s.preventDefault(),n.reset()})}}}var nD=G(8682);/** + * @license + * Copyright 2021 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const iD=Ae.fromObject({"at:shift+wheel":{action:"adjust-hue-via-wheel"}});function am(i){return{makeControl:(e,t)=>{const n=i(e),s=t.registerDisposer(new hi(n));return{control:s,controlElement:s.element}},activateTool:(e,t)=>{e.bindInputEventMap(iD),e.bindAction("adjust-via-wheel",n=>{n.stopPropagation(),n.preventDefault(),t.adjustHueViaWheel(n.detail)})}}}/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class lm extends T.O8{constructor(e){super(),this.model=e,this.element=document.createElement("input"),this.registerDisposer(e.changed.add(()=>this.updateView()));const{element:t}=this;t.type="text",this.registerEventListener(t,"change",()=>this.updateModel()),this.updateView()}disposed(){at(this.element)}updateView(){this.element.value=(this.model.value??"")+""}updateModel(){try{this.model.restoreState(this.element.value)}catch{}this.updateView()}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function va(i,e){e?i.displayState.segmentDefaultColor.value=C.eR.fromValues(1,0,0):i.displayState.segmentDefaultColor.value=void 0}function sD(){const i=e=>{e.displayState.segmentationColorGroupState.value.segmentColorHash.randomize()};return{makeControl:(e,t,{labelTextContainer:n})=>{const s=document.createElement("input");s.type="radio",s.addEventListener("change",()=>{va(e,!s.checked)}),n.prepend(s);const r=document.createElement("div");r.classList.add("neuroglancer-segmentation-color-seed-control");const o=t.registerDisposer(new lm(e.displayState.segmentColorHash));r.appendChild(o.element);const a=Ne({svg:nD,title:"Randomize",onClick:()=>i(e)});return r.appendChild(a),t.registerDisposer((0,_.W1)(l=>{const c=l===void 0;r.style.visibility=c?"":"hidden",s.checked=c},e.displayState.segmentDefaultColor)),{controlElement:r,control:o}},activateTool:e=>{const{layer:t}=e.tool;va(t,!1),i(t)}}}function rD(){const i=am(e=>e.displayState.segmentDefaultColor);return{...i,makeControl:(e,t,n)=>{const s=i.makeControl(e,t,n),{controlElement:r}=s,o=document.createElement("input");return o.type="radio",o.addEventListener("change",()=>{va(e,o.checked),o.checked&&r.click()}),n.labelTextContainer.prepend(o),t.registerDisposer((0,_.W1)(a=>{const l=a!==void 0;r.style.visibility=l?"":"hidden",o.checked=l},e.displayState.segmentDefaultColor)),s},activateTool:(e,t)=>{va(e.tool.layer,!0),i.activateTool(e,t)}}}const cm=[{label:"Color seed",title:"Color segments based on a hash of their id",toolJson:dd,...sD()},{label:"Fixed color",title:"Use a fixed color for all segments without an explicitly-specified color",toolJson:fd,...rD()},{label:"Saturation",toolJson:sd,title:"Saturation of segment colors",...Yn(i=>({value:i.displayState.saturation}))},{label:"Opacity (on)",toolJson:td,isValid:i=>i.has2dLayer,title:"Opacity in cross-section views of segments that are selected",...Yn(i=>({value:i.displayState.selectedAlpha}))},{label:"Opacity (off)",toolJson:nd,isValid:i=>i.has2dLayer,title:"Opacity in cross-section views of segments that are not selected",...Yn(i=>({value:i.displayState.notSelectedAlpha}))},{label:"Resolution (slice)",toolJson:hd,isValid:i=>i.has2dLayer,...ma(i=>({histogram:i.sliceViewRenderScaleHistogram,target:i.sliceViewRenderScaleTarget}))},{label:"Resolution (mesh)",toolJson:ud,isValid:i=>i.has3dLayer,...ma(i=>({histogram:i.displayState.renderScaleHistogram,target:i.displayState.renderScaleTarget}))},{label:"Opacity (3d)",toolJson:id,isValid:i=>i.has3dLayer,title:"Opacity of meshes and skeletons",...Yn(i=>({value:i.displayState.objectAlpha}))},{label:"Silhouette (3d)",toolJson:pd,isValid:i=>i.has3dLayer,title:"Set to a non-zero value to increase transparency of object faces perpendicular to view direction",...Yn(i=>({value:i.displayState.silhouetteRendering,options:{min:0,max:oD,step:.1}}))},{label:"Hide segment ID 0",toolJson:od,title:"Disallow selection and display of segment id 0",...Nr(i=>i.displayState.hideSegmentZero)},{label:"Base segment coloring",toolJson:ad,title:"Color base segments individually",...Nr(i=>i.displayState.baseSegmentColoring)},{label:"Show all by default",title:"Show all segments if none are selected",toolJson:ld,...Nr(i=>i.displayState.ignoreNullVisibleSet)},{label:"Highlight on hover",toolJson:rd,title:"Highlight the segment under the mouse pointer",...Nr(i=>i.displayState.hoverHighlight)},...dm("2d"),...dm("3d")],oD=10;function dm(i){return[{label:`Skeleton mode (${i})`,toolJson:`${pa}.mode${i}`,isValid:e=>e.hasSkeletonsLayer,...md(e=>e.displayState.skeletonRenderingOptions[`params${i}`].mode)},{label:`Line width (${i})`,toolJson:`${pa}.lineWidth${i}`,isValid:e=>e.hasSkeletonsLayer,toolDescription:`Skeleton line width (${i})`,title:`Skeleton line width (${i})`,...Yn(e=>({value:e.displayState.skeletonRenderingOptions[`params${i}`].lineWidth,options:{min:1,max:40,step:1}}))}]}function aD(i){for(const e of cm)gd(i,e)}var bn=G(3708);/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function lD(i,e,t){return i&1|e<<1&2|t<<2&4}function jV(i,e,t,n){const s=Math.max(e,t,n);let r=0,o=i.low,a=0,l=0,c=0;for(let d=0;d>>r&1;a|=u<>>r&1;l|=u<>>r&1;c|=u<>>0,c=0,l=0,d=!0)}for(let h=0;h>h&1),h>h&1),h>h&1);return d?i.high=c>>>0:(i.high=0,i.low=c>>>0),i}function QV(i,e,t){let n=0;const s=e.length;let r=0,o=!1;function a(l){r|=(l&1)<>>0,r=0,n=0,o=!0)}for(let l=0;l<32;++l)for(let c=0;c>>l&&a(e[c]>>>l);return o?i.high=r>>>0:(i.high=0,i.low=r>>>0),i}function um(i,e){return i0?0:1,D=w>0?0:1,I=b>0?0:1,L=t[4*4],N=t[4*4+1],k=t[4*4+2],O=t[4*4+3];function V(dt,be,Ye){return S*dt+w*be+b*Ye+x}function z(dt,be,Ye,bt,ni,oo){return V(dt+E*(bt-dt),be+D*(ni-be),Ye+I*(oo-Ye))}const Y=V(-O*L,-O*N,-O*k),Q=i.clipLowerBound[0],X=i.clipLowerBound[1],ce=i.clipLowerBound[2],oe=i.clipUpperBound[0],Se=i.clipUpperBound[1],Ke=i.clipUpperBound[2],$e=Math.sqrt((h*s)**2+(g*r)**2),Tt=Math.sqrt((p*s)**2+(v*r)**2),we=Math.sqrt((m*s)**2+(y*r)**2),xe=Math.max($e,Tt,we);function ct(dt,be,Ye){const bt=1<>>31),dt>0&&(nr===0||bh*n>>0;for(let Ch=Sh;Ch{if(!b&&!o(y,S,w)){g=Math.max(y,g);return}if(y=e)throw new Error("Invalid node reference");const r=i[s*5],o=i[s*5+1],a=i[s*5+2],l=i[s*5+3],c=i[s*5+4];if(l<0||c<0||ce||l+8>>1!==r||h>>>1!==o||p>>>1!==a)throw new Error("invalid child");n(d)}}if(e!==0&&(n(e-1),t.size!==e))throw new Error("Orphan nodes in octree")}function pm(i,e,t){return`${i}/${e}:${t}`}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class Gi extends vp{draw(e,t){}isReady(e,t){return!0}get transparentPickEnabled(){return!0}}var Sa=G(9254);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const vd=3,uD=.8,bi=!1;let kn=0,Pn=0,fm=0,gm=0;class Or{constructor(e=Or.generateHashSeeds(vd)){this.hashSeeds=e,this.loadFactor=uD,this.size=0,this.emptyLow=4294967295,this.emptyHigh=4294967295,this.maxRehashAttempts=5,this.maxAttempts=5,this.generation=0,this.mungedEmptyKey=-1;let t=8;for(;t<2*e.length;)t*=2;this.allocate(t)}updateHashFunctions(e){this.hashSeeds=Or.generateHashSeeds(e),this.mungedEmptyKey=-1}tableWithMungedEmptyKey(e){const t=this.hashSeeds.length,n=new Array(t);for(let l=0;l>>0;for(let l=0;l>>0,o=Math.random()*4294967296>>>0,!(!(r===e&&o===t)&&!this.hasPair(r,o)););this.emptyLow=r,this.emptyHigh=o;for(let a=0,l=n.length;athis.capacity?(this.backupPending(),this.grow(e),this.restorePending(),!0):!1}swapPending(e,t){const n=kn,s=Pn;this.storePending(e,t),e[t]=n,e[t+1]=s}storePending(e,t){kn=e[t],Pn=e[t+1]}backupPending(){fm=kn,gm=Pn}restorePending(){kn=fm,Pn=gm}tryToInsert(){bi&&console.log(`tryToInsert: ${kn}, ${Pn}`);let e=0;const{emptyLow:t,emptyHigh:n,maxAttempts:s,table:r}=this,o=this.hashSeeds.length;let a=Math.floor(Math.random()*o);for(;;){const l=this.getHash(a,kn,Pn);if(this.swapPending(r,l),kn===t&&Pn===n)return!0;if(++e===s)break;a=(a+Math.floor(Math.random()*(o-1))+1)%o}return!1}allocate(e){this.tableSize=e;const{entryStride:t}=this;this.table=new Uint32Array(e*t),this.maxAttempts=e,this.clearTable(),this.capacity=e*this.loadFactor,this.mungedEmptyKey=-1}rehash(e,t){bi&&console.log("rehash begin"),this.allocate(t),this.updateHashFunctions(this.hashSeeds.length);const{emptyLow:n,emptyHigh:s,entryStride:r}=this;for(let o=0,a=e.length;othis.capacity&&(this.backupPending(),this.grow(this.tableSize*2),this.restorePending());!this.tryToInsert();)this.backupPending(),this.grow(this.tableSize),this.restorePending()}}class mm extends Or{add(e){const{low:t,high:n}=e;return this.hasPair(t,n)?!1:(bi&&console.log(`add: ${t},${n}`),kn=t,Pn=n,this.insertInternal(),!0)}[Symbol.iterator](){return this.unsafeKeys()}}mm.prototype.entryStride=2;let _r=0,Vr=0,vm=0,ym=0;class yd extends Or{set(e,t){const{low:n,high:s}=e;return this.hasPair(n,s)?!1:(bi&&console.log(`add: ${n},${s} -> ${t.low},${t.high}`),kn=n,Pn=s,_r=t.low,Vr=t.high,this.insertInternal(),!0)}get(e,t){const n=this.indexOf(e);if(n===-1)return!1;const{table:s}=this;return t.low=s[n+2],t.high=s[n+3],!0}swapPending(e,t){const n=_r,s=Vr;super.swapPending(e,t),e[t+2]=n,e[t+3]=s}storePending(e,t){super.storePending(e,t),_r=e[t+2],Vr=e[t+3]}backupPending(){super.backupPending(),vm=_r,ym=Vr}restorePending(){super.restorePending(),_r=vm,Vr=ym}[Symbol.iterator](){return this.unsafeEntries()}*entries(){const{emptyLow:e,emptyHigh:t,entryStride:n}=this,{table:s}=this;for(let r=0,o=s.length;r4)break;return i.texelsPerElement=1,i.textureInternalFormat=pD[t],i.textureFormat=zi[t],i.texelType=WebGL2RenderingContext.UNSIGNED_BYTE,i.arrayElementsPerTexel=t,i.arrayConstructor=Uint8Array,i.samplerPrefix="u",i;case R.INT8:if(t<1||t>4)break;return i.texelsPerElement=1,i.textureInternalFormat=fD[t],i.textureFormat=zi[t],i.texelType=WebGL2RenderingContext.BYTE,i.arrayElementsPerTexel=t,i.arrayConstructor=Int8Array,i.samplerPrefix="i",i;case R.UINT16:if(t<1||t>4)break;return i.texelsPerElement=1,i.textureInternalFormat=gD[t],i.textureFormat=zi[t],i.texelType=WebGL2RenderingContext.UNSIGNED_SHORT,i.arrayElementsPerTexel=t,i.arrayConstructor=Uint16Array,i.samplerPrefix="u",i;case R.INT16:if(t<1||t>4)break;return i.texelsPerElement=1,i.textureInternalFormat=mD[t],i.textureFormat=zi[t],i.texelType=WebGL2RenderingContext.SHORT,i.arrayElementsPerTexel=t,i.arrayConstructor=Int16Array,i.samplerPrefix="i",i;case R.UINT32:if(t<1||t>4)break;return i.texelsPerElement=1,i.textureInternalFormat=Sm[t],i.textureFormat=zi[t],i.texelType=WebGL2RenderingContext.UNSIGNED_INT,i.arrayElementsPerTexel=1,i.arrayConstructor=Uint32Array,i.samplerPrefix="u",i;case R.INT32:if(t<1||t>4)break;return i.texelsPerElement=1,i.textureInternalFormat=vD[t],i.textureFormat=zi[t],i.texelType=WebGL2RenderingContext.INT,i.arrayElementsPerTexel=1,i.arrayConstructor=Int32Array,i.samplerPrefix="i",i;case R.UINT64:if(t<1||t>2)break;return i.texelsPerElement=1,i.textureInternalFormat=Sm[t*2],i.textureFormat=zi[t*2],i.texelType=WebGL2RenderingContext.UNSIGNED_INT,i.arrayElementsPerTexel=2*t,i.arrayConstructor=Uint32Array,i.samplerPrefix="u",i;case R.FLOAT32:if(t<1||t>4)break;return i.texelsPerElement=1,i.textureInternalFormat=yD[t],i.textureFormat=hD[t],i.texelType=WebGL2RenderingContext.FLOAT,i.arrayElementsPerTexel=t,i.arrayConstructor=Float32Array,i.samplerPrefix="",i}throw new Error(`No supported texture format for ${R[e]}[${t}].`)}function wa(i,e,t){const{arrayConstructor:n,arrayElementsPerTexel:s,textureInternalFormat:r,textureFormat:o,texelsPerElement:a}=e,{maxTextureSize:l}=i,c=t.length/s;if(c*a>l*l)throw new Error("Number of elements exceeds maximum texture size: "+a+" * "+c);const d=Math.ceil(c/l),u=Math.ceil(Math.log2(d)),h=(1<> log2width); + highp int x = int((index - (uint(y) << log2width)) * ${e}u); +`;for(let s=0;s> 17u); + value *= 0x1b873593u; + state ^= value; + state = (state << 13u) | (state >> 19u); + state = (state * 5u) + 0xe6546b64u; + return state; +} +highp uint hashCombine(highp uint state, uint64_t x) { + state = hashCombine(state, x.value[0]); + return hashCombine(state, x.value[1]); +} +`],xD=Wi(new Ns,R.UINT64,1);class Hi extends T.O8{constructor(e,t){super(),this.gl=e,this.hashTable=t,this.generation=-1,this.texture=null,this.texture=e.createTexture()}copyToGPU(){const{hashTable:e}=this,{generation:t}=e;if(this.generation===t)return;const{gl:n,texture:s}=this;this.generation=t,n.activeTexture(WebGL2RenderingContext.TEXTURE0+n.tempTextureUnit),n.bindTexture(WebGL2RenderingContext.TEXTURE_2D,s),e.tableWithMungedEmptyKey(r=>{wa(this.gl,xD,r)}),n.bindTexture(WebGL2RenderingContext.TEXTURE_2D,null)}disposed(){const{gl:e}=this;e.deleteTexture(this.texture),this.texture=null,this.gl=void 0,this.hashTable=void 0,super.disposed()}static get(e,t){return e.memoize.get(t,()=>new Hi(e,t))}}class wm{constructor(e,t=vd){this.prefix=e,this.numAlternatives=t,this.textureUnitSymbol=Symbol.for(`gpuhashtable:${this.prefix}`),this.accessHelper=new xa(`gpuhashtable_${this.prefix}`),this.samplerName=this.prefix+"_sampler",this.hashSeedsName=this.prefix+"_seeds",this.hashKeyMask=this.prefix+"_keyMask",this.readTable=this.prefix+"_readTable"}defineShader(e){const{hashSeedsName:t,samplerName:n,numAlternatives:s,hashKeyMask:r}=this;e.addUniform("highp uint",t,s),e.addUniform("highp uint",r),e.addTextureSampler("usampler2D",n,this.textureUnitSymbol),e.addFragmentCode(Cm),e.addFragmentCode(gt),e.addFragmentCode(Tp),this.accessHelper.defineShader(e),e.addFragmentCode(this.accessHelper.getAccessor(this.readTable,this.samplerName,R.UINT64,1));let o="";o+=` +bool ${this.hasFunctionName}(uint64_t x) { +`;for(let a=0;a>= 8u; +`;n+=` + vec3 hsv = vec3(v.x, 0.5 + v.y * 0.5, 1.0); + return hsvToRgb(hsv); +} +`,e.addFragmentCode(n)}enable(e,t,n){e.uniform1ui(t.uniform(this.seedName),n)}}const Tm=new Float32Array(3);function Dm(i){return`rgb(${i[0]*100}%,${i[1]*100}%,${i[2]*100}%)`}class Sd{constructor(e=ut()){this.hashSeed=e,this.changed=new j.IY}static getDefault(){return new Sd(0)}get value(){return this.hashSeed}set value(e){e!==this.hashSeed&&(this.hashSeed=e,this.changed.dispatch())}compute(e,t){let n=(0,Sa._)(this.hashSeed,t.low);n=(0,Sa._)(n,t.high);const s=(n&255)/255,r=(n>>8&255)/255;return Mo(e,s,.5+.5*r,1),e}computeCssColor(e){return this.compute(Tm,e),Dm(Tm)}randomize(){this.hashSeed=ut(),this.changed.dispatch()}toString(){return`new SegmentColorHash(${this.hashSeed})`}toJSON(){return this.hashSeed===0?void 0:this.hashSeed}reset(){this.restoreState(0)}restoreState(e){const t=e>>>0;t!==this.hashSeed&&(this.hashSeed=t,this.changed.dispatch())}}class TD{constructor(e){this.prefix=e,this.hashMapShaderManager=new xm("segmentStatedColorHash")}defineShader(e){this.hashMapShaderManager.defineShader(e);const t=` +bool ${this.getFunctionName}(uint64_t x, out vec4 value) { + uint64_t uint64Value; + if (${this.hashMapShaderManager.getFunctionName}(x, uint64Value)) { + uint uintValue = uint64Value.value[0]; + value.r = float((uintValue & 0x0000ffu)) / 255.0; + value.g = float((uintValue & 0x00ff00u) >> 8) / 255.0; + value.b = float((uintValue & 0xff0000u) >> 16) / 255.0; + value.a = float((uintValue & 0xff000000u) >> 24) / 255.0; + return true; + } + return false; +} +`;e.addFragmentCode(t)}get getFunctionName(){return`${this.prefix}_get`}enable(e,t,n){this.hashMapShaderManager.enable(e,t,n)}disable(e,t){this.hashMapShaderManager.disable(e,t)}}/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */let bd;function DD(){if(bd===void 0){const i=new Ae;i.set("keyl","recolor"),i.set("keyx","clear-segments"),i.set("keys","toggle-show-slices"),i.set("keyb","toggle-scale-bar"),i.set("keyv","toggle-default-annotations"),i.set("keya","toggle-axis-lines"),i.set("keyo","toggle-orthographic-projection");for(let e=1;e<=9;++e)i.set("digit"+e,"toggle-layer-"+e),i.set("control+digit"+e,"select-layer-"+e),i.set("alt+digit"+e,"toggle-pick-layer-"+e);for(let e=0;e<26;++e){const t=String.fromCharCode(97+e),n=String.fromCharCode(65+e);i.set(`alt?+control?+shift+key${t}`,`tool-${n}`)}i.set("keyn","add-layer"),i.set("keyh","help"),i.set("space","toggle-layout"),i.set("shift+space","toggle-layout-alternative"),i.set("backslash","toggle-show-statistics"),i.set("alt+arrowup","select-previous"),i.set("alt+arrowdown","select-next"),bd=i}return bd}let Cd;function Br(){return Cd===void 0&&(Cd=Ae.fromObject({"control+mousedown2":"select-position"})),Cd}let wd;function Im(){return wd===void 0&&(wd=Ae.fromObject({click0:"pin-annotation",mousedown2:"move-to-annotation"},{parents:[[Br(),0]]})),wd}let xd;function Lm(){return xd===void 0&&(xd=Ae.fromObject({arrowleft:"x-",arrowright:"x+",arrowup:"y-",arrowdown:"y+",comma:"z-",period:"z+",bracketleft:"t-",bracketright:"t+",keyz:"snap","control+equal":"zoom-in","alt+equal":"depth-range-decrease","control+shift+equal":"zoom-in","alt+shift+equal":"depth-range-decrease","control+minus":"zoom-out","alt+minus":"depth-range-increase",keyr:"rotate-relative-z-",keye:"rotate-relative-z+","shift+arrowdown":"rotate-relative-x-","shift+arrowup":"rotate-relative-x+","shift+arrowleft":"rotate-relative-y-","shift+arrowright":"rotate-relative-y+","control+wheel":{action:"zoom-via-wheel",preventDefault:!0},"alt+wheel":{action:"adjust-depth-range-via-wheel",preventDefault:!0},"at:wheel":{action:"z+1-via-wheel",preventDefault:!0},"at:shift+wheel":{action:"z+10-via-wheel",preventDefault:!0},"at:dblclick0":"select","at:shift+dblclick0":"star","at:control+mousedown0":"annotate","at:mousedown2":"move-to-mouse-position","at:alt+mousedown0":"move-annotation","at:control+alt+mousedown2":"delete-annotation","at:touchpinch":"zoom-via-touchpinch","at:touchrotate":"rotate-in-plane-via-touchrotate","at:touchtranslate2":"translate-in-plane-via-touchtranslate","at:touchhold1":"move-to-mouse-position","at:touchtap1x2":"select","at:touchtap2x3":"snap"},{label:"All Data Panels",parents:[[Br(),0]]})),xd}let Ed;function ID(){return Ed===void 0&&(Ed=Ae.fromObject({"at:mousedown0":{action:"rotate-via-mouse-drag",stopPropagation:!0},"at:shift+mousedown0":{action:"translate-via-mouse-drag",stopPropagation:!0},"at:touchtranslate1":"rotate-out-of-plane-via-touchtranslate"},{parents:[[Lm(),Number.NEGATIVE_INFINITY]]})),Ed}let Td;function LD(){return Td===void 0&&(Td=Ae.fromObject({"at:mousedown0":{action:"translate-via-mouse-drag",stopPropagation:!0},"at:shift+mousedown0":{action:"rotate-via-mouse-drag",stopPropagation:!0},"at:touchtranslate1":"translate-z-via-touchtranslate"},{parents:[[Lm(),Number.NEGATIVE_INFINITY]]})),Td}function RD(i){i.global.addParent(DD(),Number.NEGATIVE_INFINITY),i.sliceView.addParent(LD(),Number.NEGATIVE_INFINITY),i.perspectiveView.addParent(ID(),Number.NEGATIVE_INFINITY)}/** + * @license + * Copyright 2021 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */let Os;const Fr=[];function kD(){if(Os===void 0){const i=Os=document.createElement("div");i.classList.add("neuroglancer-drag-status"),document.body.appendChild(i)}return Os}function PD(){Os!==void 0&&(Me(Os),Os.style.display="none")}function Rm(i){const e=kD();Me(e),typeof i=="string"?e.appendChild(document.createTextNode(i)):e.appendChild(i()),e.style.display=""}function km(i,e){(0,F.U8)(Fr,t=>!(t.target===i&&t.operation===e))}function Cn(i,e,t){km(i,e),Fr.push({target:i,operation:e,status:t}),Rm(t)}function kt(i,e){km(i,e);const t=Fr.length===0?void 0:Fr[Fr.length-1];t===void 0?PD():Rm(t.status)}/** + * @license + * Copyright 2021 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const _s="neuroglancer-drag-over",Pm={row:"row",column:"col"},AD={left:"right",right:"left",top:"bottom",bottom:"top"},Ci={left:"column",right:"column",top:"row",bottom:"row"},Ea={left:"row",right:"row",top:"column",bottom:"column"},Ji={row:"width",column:"height"},Am={row:"left",column:"top"},MD={row:"right",column:"bottom"},Mm={left:"marginLeft",right:"marginRight",top:"marginTop",bottom:"marginBottom"},Ta={left:-1,right:1,top:-1,bottom:1};class ji extends T.O8{constructor(e,t=new Si){super(),this.sidePanelManager=e,this.location=t,this.element=document.createElement("div"),this.visibility=new vt(vt.VISIBLE);const{element:n}=this;n.classList.add("neuroglancer-side-panel"),n.draggable=!0,n.addEventListener("dragstart",s=>{this.sidePanelManager.startDrag(this.makeDragSource(),s),n.style.backgroundColor="black",setTimeout(()=>{n.style.backgroundColor=""},0),Cn(n,"drag",()=>document.createTextNode("Drag side panel to move it to the left/right/top/bottom of another panel"))}),n.addEventListener("dragend",s=>{this.sidePanelManager.endDrag(),kt(n,"drag")})}makeDragSource(){return{dropAsNewPanel:e=>{const t=this.location.value;this.location.value={...t,...e},this.location.locationChanged.dispatch()}}}close(){this.location.visible=!1}addTitleBar(e){const t=document.createElement("div");t.classList.add("neuroglancer-side-panel-titlebar");const{title:n}=e;let s;n!==void 0&&(s=document.createElement("div"),s.classList.add("neuroglancer-side-panel-title"),s.textContent=n,t.appendChild(s));const r=No({title:"Close panel",onClick:()=>{this.close()}});return r.style.order="100",t.appendChild(r),this.element.appendChild(t),{titleBar:t,titleElement:s,closeButton:r}}addBody(e){e.draggable=!0,e.addEventListener("dragstart",t=>{t.preventDefault(),t.stopPropagation()}),this.element.appendChild(e)}}class ND extends T.O8{constructor(e,t,n=new vt(vt.VISIBLE)){super(),this.display=e,this.center=t,this.visibility=n,this.element=document.createElement("div"),this.centerColumn=document.createElement("div"),this.beforeRender=new j.HN,this.sides={left:this.makeSidePanelSideState("left"),right:this.makeSidePanelSideState("right"),top:this.makeSidePanelSideState("top"),bottom:this.makeSidePanelSideState("bottom")},this.registeredPanels=new Set,this.layoutNeedsUpdate=!1,this.invalidateLayout=()=>{this.layoutNeedsUpdate=!0,this.display.scheduleRedraw()};const{element:s,centerColumn:r}=this;s.style.display="flex",s.style.flex="1",s.style.flexDirection="row",r.style.display="flex",r.style.flex="1",r.style.flexDirection="column",r.style.flexBasis="0px",r.style.minWidth="0px",this.render(),this.registerDisposer(e.updateStarted.add(()=>{this.beforeRender.dispatch(),this.layoutNeedsUpdate&&(this.render(),++e.resizeGeneration)})),this.registerDisposer(this.visibility.changed.add(this.invalidateLayout))}get visible(){return this.visibility.visible}makeSidePanelSideState(e){return{flexGroups:[],outerDropZoneElement:this.makeDropZone(e,Ta[e]*(1/0),0,e,!1)}}hasDroppablePanel(){return this.dragSource!==void 0}startDrag(e,t){setTimeout(()=>{this.dragSource===e&&(this.element.dataset.neuroglancerSidePanelDrag="true")},0),this.dragSource=e,t.stopPropagation(),t.dataTransfer.setData("neuroglancer-side-panel","")}endDrag(){delete this.element.dataset.neuroglancerSidePanelDrag,this.dragSource=void 0}makeDropZone(e,t,n,s,r=!1){const o=document.createElement("div");o.className="neuroglancer-side-panel-drop-zone";const a=10,l=Ci[s],c=Ea[s];return o.style[Ji[c]]=`${a}px`,o.style[Ji[l]]="100%",r?(o.style.position="absolute",o.style[s]="50%",o.style[Mm[s]]="-${size/2}px"):(o.style.position="relative",o.style[Mm[AD[s]]]=`-${a}px`),o.addEventListener("dragenter",d=>{this.hasDroppablePanel()&&(o.classList.add(_s),d.preventDefault(),Cn(o,"drop",()=>document.createTextNode(`Drop side panel as new ${l}`)))}),o.addEventListener("dragleave",()=>{kt(o,"drop"),o.classList.remove(_s)}),o.addEventListener("dragover",d=>{this.hasDroppablePanel()&&d.preventDefault()}),o.addEventListener("drop",d=>{const{dragSource:u}=this;if(u===void 0)return;kt(o,"drop"),o.classList.remove(_s);const h=Ci[e];u.dropAsNewPanel({side:e,row:h==="column"?n:t,col:h==="row"?n:t}),this.dragSource=void 0,d.preventDefault(),d.stopPropagation()}),o}registerPanel(e){return this.registeredPanels.add(e),this.invalidateLayout(),e.location.locationChanged.add(this.invalidateLayout),()=>{this.unregisterPanel(e)}}unregisterPanel(e){this.registeredPanels.delete(e),e.location.locationChanged.remove(this.invalidateLayout),e.panel?.dispose(),this.invalidateLayout()}disposed(){for(const{panel:e}of this.registeredPanels)e?.dispose();super.disposed()}render(){this.layoutNeedsUpdate=!1;const e={left:[],right:[],top:[],bottom:[]};for(const o of this.registeredPanels)e[o.location.value.side].push(o);const t=o=>this.renderSide(o,this.sides[o].flexGroups,e[o]),n=this;function*s(){yield n.sides.left.outerDropZoneElement,yield*t("left"),yield n.centerColumn,yield*t("right"),yield n.sides.right.outerDropZoneElement}nn(this.element,s());function*r(){yield n.sides.top.outerDropZoneElement,yield*t("top"),yield n.center,yield*t("bottom"),yield n.sides.bottom.outerDropZoneElement}nn(this.centerColumn,r())}makeCrossGutter(e,t){const n=document.createElement("div");n.style.position="relative";const s=Ea[e];n.className=`neuroglancer-resize-gutter-${s==="row"?"horizontal":"vertical"}`,n.addEventListener("pointerdown",o=>{if("button"in o&&o.button!==0)return;o.preventDefault();const a=this.sides[e].flexGroups[t];if(a===void 0||!a.visible)return;let c=a.element.getBoundingClientRect()[Ji[s]];const d=a.minSize,u=()=>{Cn(n,"drag",`Drag to resize, current ${Ji[s]} is ${a.crossSize}px`)};u(),zt(o,(h,p,m)=>{const g=s==="row"?p:m;c-=Ta[e]*g,a.crossSize=Math.max(d,Math.round(c)),u(),this.invalidateLayout()},()=>{kt(n,"drag")})});const r=this.makeDropZone(e,t-Ta[e]*.5,0,e,!0);return n.appendChild(r),n}makeFlexGutter(e,t,n){const s=document.createElement("div");s.style.position="relative";const r=Ci[e];s.className=`neuroglancer-resize-gutter-${r==="row"?"horizontal":"vertical"}`,s.addEventListener("pointerdown",a=>{if("button"in a&&a.button!==0)return;a.preventDefault();const l=this.sides[e].flexGroups[t];if(l===void 0||!l.visible)return;const{cells:c}=l,d=c[n];if(d===void 0||!d.registeredPanel.location.visible)return;let u=n+1;for(;u{Cn(s,"drag",`Drag to resize, current ${Ji[r]} ratio is ${d.registeredPanel.location.value.flex} : ${h.registeredPanel.location.value.flex}`)};p(),zt(a,m=>{const g=d.registeredPanel.panel,v=h.registeredPanel.panel;if(g===void 0||v===void 0)return;const y=g.element.getBoundingClientRect(),S=v.element.getBoundingClientRect(),w=Math.max(.1,Math.min(.9,r==="column"?(m.clientY-y.top)/(S.bottom-y.top):(m.clientX-y.left)/(S.right-y.left))),b=d.registeredPanel.location.value,x=h.registeredPanel.location.value,E=b.flex+x.flex;d.registeredPanel.location.value={...b,flex:Math.round(w*E*100)/100},h.registeredPanel.location.value={...x,flex:Math.round((1-w)*E*100)/100},p(),d.registeredPanel.location.locationChanged.dispatch(),h.registeredPanel.location.locationChanged.dispatch(),this.invalidateLayout()},()=>{kt(s,"drag")})});const o=this.makeDropZone(e,t,n+.5,Am[Ci[e]],!0);return s.appendChild(o),s}renderSide(e,t,n){const s=Pm[Ea[e]],r=Pm[Ci[e]];n.sort((l,c)=>{const d=l.location.value,u=c.location.value,h=d[r]-u[r];return h!==0?h:d[s]-u[s]});const o=this;function*a(){let l=0;const c=n.length;let d=0;for(;l0;let v=t[d];if(v===void 0){const S=o.makeCrossGutter(e,d),w=document.createElement("div");w.className=`neuroglancer-side-panel-${Ci[e]}`,v=t[d]={element:w,gutterElement:S,cells:[],crossSize:-1,minSize:m,visible:g,beginDropZone:o.makeDropZone(e,d,-1/0,Am[Ci[e]]),endDropZone:o.makeDropZone(e,d,1/0,MD[Ci[e]])}}else v.visible=g,v.minSize=m,v.crossSize=Math.max(v.crossSize,m);function*y(){yield v.beginDropZone;let S=0;for(let w=l,b=0;w1?`${D.flex}`:"1",yield L.element,S===p?E.gutterElement=void 0:(E.gutterElement===void 0&&(E.gutterElement=o.makeFlexGutter(e,d,b)),yield E.gutterElement)}yield v.endDropZone}nn(v.element,y()),v.cells.length=h-l,g&&(v.element.style[Ji[Ea[e]]]=`${v.crossSize}px`,Ta[e]>0?(yield v.gutterElement,yield v.element):(yield v.element,yield v.gutterElement)),l=h,++d}t.length=d}return a()}}/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function Nm(i={}){return Ne({text:"\u2197",...i})}/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function Om(i){return i.closest(".neuroglancer-selection-details")}class OD extends ji{constructor(e,t,n,s){super(e,t.location),this.sidePanelManager=e,this.state=t,this.manager=n,this.selectedLayer=s,this.body=document.createElement("div");const{element:r,body:o}=this;r.classList.add("neuroglancer-selection-details"),this.registerDisposer(new tn(this.element,Br()));const{titleBar:a}=this.addTitleBar({title:"Selection"}),l=Ne({svg:uf,title:"Previous selection",onClick:()=>{this.state.goBack()}}),c=Ne({svg:hf,title:"Next selection",onClick:()=>{this.state.goForward()}});a.appendChild(l),a.appendChild(c),a.appendChild(this.registerDisposer(new rn(t.pin,{text:"\u{1F4CC}\uFE0E",enableTitle:"Pin selection",disableTitle:"Unpin selection"})).element),o.classList.add("neuroglancer-selection-details-body"),this.addBody(o),o.appendChild(this.registerDisposer(new Wt(t,(d,u,h)=>{if(!t.location.visible||(l.style.visibility=t.canGoBack()?"visible":"hidden",c.style.visibility=t.canGoForward()?"visible":"hidden",d===void 0))return;const{position:p}=d;if(p!==void 0){const m=document.createElement("div");m.classList.add("neuroglancer-selection-details-position");const g=Hn({title:"Copy position",onClick:()=>{mi(S.map(b=>Math.floor(b)).join(", "))}});m.appendChild(g);const{coordinateSpace:{rank:v,names:y},position:S}=d;for(let b=0;b{this.manager.globalPosition.value=S}});m.appendChild(w),u.appendChild(m)}for(const m of d.layers){const{layer:g}=m;u.appendChild(h.registerDisposer(new Wt({value:void 0,changed:g.managedLayer.layerChanged},(v,y,S)=>{if(g.wasDisposed||!g.isReady)return;const w=document.createElement("div");if(w.classList.add("neuroglancer-selection-details-layer-body"),!g.displaySelectionState(m.state,w,S))return;const b=document.createElement("div");y.appendChild(b),b.classList.add("neuroglancer-selection-details-layer");const x=document.createElement("div");x.classList.add("neuroglancer-selection-details-layer-title"),x.textContent=g.managedLayer.name,x.addEventListener("click",()=>{this.selectedLayer.layer=g.managedLayer,this.selectedLayer.visible=!0}),x.title="Click to show layer side panel",b.appendChild(x),b.appendChild(w)})).element)}})).element)}close(){super.close(),this.state.value=void 0,this.state.pin.value=!0}}var _m=G(9564);/** + * @license + * Copyright 2023 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function Vm(i={}){const e=Ne({svg:_m,...i});return e.classList.add("neuroglancer-eye-icon"),e}var _D=G(7237);/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function VD(i={}){return Ne({svg:_D,...i})}var BD=G(9187);/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function Bm(i={}){const e=Ne({svg:BD,...i});return e.classList.add("neuroglancer-star-icon"),e}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class wi{constructor(e,t,n){this.key=e,this.value=t,this.label=n}toString(){const{key:e,value:t,label:n}=this;let s;return t===void 0?s=`${e}`:s=`${e}\u2192${t}`,n===void 0?s:`${s} ${n}`}}class FD extends T.O8{constructor(){super(...arguments),this.selectedSegment=new P.R,this.baseSelectedSegment=new P.R,this.hasSelectedSegment=!1,this.changed=new j.IY}get value(){return this.hasSelectedSegment?this.selectedSegment:void 0}get baseValue(){return this.hasSelectedSegment?this.baseSelectedSegment:void 0}set(e,t=!1){const{selectedSegment:n,baseSelectedSegment:s}=this;let r=0,o=0,a=0,l=0,c;if(e==null)c=!1;else if(typeof e=="number")r=a=e>>>0,o=l=e<0?4294967295:0,c=!0;else if(e instanceof wi){const d=e.value||e.key;r=d.low,o=d.high,a=e.key.low,l=e.key.high,c=!0}else e instanceof P.R?(r=a=e.low,o=l=e.high,c=!0):c=!1;t&&r===0&&o===0&&(c=!1),c?c&&(!this.hasSelectedSegment||n.low!==r||n.high!==o||s.low!==a||s.high!==l)&&(n.low=r,n.high=o,s.low=a,s.high=l,this.hasSelectedSegment=!0,this.changed.dispatch()):this.hasSelectedSegment&&(this.hasSelectedSegment=!1,this.changed.dispatch())}isSelected(e){return this.hasSelectedSegment&&P.R.equal(e,this.selectedSegment)}bindTo(e,t){this.registerDisposer(e.changed.add(()=>{const n=e.get(t);let s;n!==void 0&&(s=n.value),this.set(s,t.displayState.segmentationGroupState.value.hideSegmentZero.value)}))}}function Ur(i){i.useTemporarySegmentEquivalences.value=!1,i.useTemporaryVisibleSegments.value=!1,i.temporaryVisibleSegments.clear(),i.temporarySegmentEquivalences.clear()}function Fm(i,e,t=!1){let n,s,r;if(typeof e=="number"?n=new P.R(e>>>0,e<0?4294967295:0):typeof e=="string"?n=P.R.parseString(e):n=t?e.clone():e,i==null)return n;const{segmentEquivalences:o,segmentPropertyMap:{value:a}}=i.segmentationGroupState.value;o.size!==0?(s=o.get(n),P.R.equal(s,n)?r=void 0:r=s):s=n;const l=a?.getSegmentLabel(s);return l===void 0&&r===void 0?n:new wi(n,r,l)}function Yi(i,e){if(e instanceof wi)return e;const t=Fm(i,e);return t instanceof P.R?new wi(t):t}function Um(i,e){const{length:t}=e;i.valuee.style.setProperty("--neuroglancer-segment-list-width",`${t}ch`),i.segmentationGroupState.value.maxIdLength)}const Dd=(()=>{const i=document.createElement("div");i.classList.add("neuroglancer-segment-list-entry");const e=document.createElement("div");e.classList.add("neuroglancer-segment-list-entry-sticky"),i.appendChild(e);const t=Hn({title:"Copy segment ID"});t.classList.add("neuroglancer-segment-list-entry-copy");const n=document.createElement("div");n.classList.add("neuroglancer-segment-list-entry-copy-container");const s=n.childElementCount;n.appendChild(t);const r=e.childElementCount;e.appendChild(n);const o=e.childElementCount,a=Vm({title:"Toggle segment visibility"});a.classList.add("neuroglancer-segment-list-entry-visible-checkbox"),e.appendChild(a);const l=document.createElement("div");l.classList.add("neuroglancer-segment-list-entry-id-container");const c=e.childElementCount;e.appendChild(l);const d=document.createElement("div");d.classList.add("neuroglancer-segment-list-entry-id");const u=l.childElementCount;l.appendChild(d);const h=Bm({title:"Star segment"});h.classList.add("neuroglancer-segment-list-entry-star");const p=e.childElementCount;e.appendChild(h);const m=document.createElement("span");m.classList.add("neuroglancer-segment-list-entry-name");const g=i.childElementCount;i.appendChild(m);const v=VD({title:"Filter by label"});v.classList.add("neuroglancer-segment-list-entry-filter");const y=i.childElementCount;i.appendChild(v);const S=i.childElementCount;return i.appendChild(hi.template()),{template:i,copyContainerIndex:r,copyIndex:s,visibleIndex:o,idContainerIndex:c,idIndex:u,labelIndex:g,filterIndex:y,starIndex:p,colorWidgetIndex:S,unmappedIdIndex:-1,unmappedCopyIndex:-1}})(),UD=(()=>{const i=Dd,e=i.template.cloneNode(!0),t=e.children[0],n=t.children[i.idContainerIndex],s=n.childElementCount,r=n.children[i.idIndex].cloneNode(!0);r.classList.add("neuroglancer-segment-list-entry-unmapped-id"),n.appendChild(r);const o=t.children[i.copyContainerIndex],a=o.childElementCount;return o.appendChild(o.children[i.copyIndex].cloneNode(!0)),{...i,template:e,unmappedIdIndex:s,unmappedCopyIndex:a}})();function $D(i){const e=Dd,t=e.template.cloneNode(!0),n=[];for(let s=0;s{const u=d.currentTarget,h=u.dataset.id,p=An;p.tryParseString(h),i.segmentSelectionState.set(p),Om(u)||i.selectSegment(p,!1)},t=d=>{const u=d.currentTarget,h=u.dataset.id,p=An;p.tryParseString(h),i.selectSegment(p,Om(u)?"toggle":!0)},n=()=>{i.segmentSelectionState.set(null)},s=d=>d.currentTarget.closest(".neuroglancer-segment-list-entry"),r=d=>{const u=s(d);mi(u.dataset.id),d.stopPropagation()},o=d=>{const u=s(d);mi(u.dataset.unmappedId),d.stopPropagation()},a=d=>{const h=s(d).dataset.id,p=An;p.tryParseString(h);const{selectedSegments:m,visibleSegments:g}=i.segmentationGroupState.value,v=!g.has(p);v&&m.add(p),g.set(p,v),d.stopPropagation(),d.preventDefault()},l=d=>{const h=s(d).dataset.id,p=An;p.tryParseString(h),i.filterBySegmentLabel(p),d.stopPropagation()},c=d=>{if(d.button!==2||d.ctrlKey||d.altKey||d.metaKey||d.shiftKey)return;const h=d.currentTarget.dataset.id,p=An;p.tryParseString(h),i.moveToSegment(p)};return(d,u)=>{const{children:h}=d,p=h[0].children;d.addEventListener("mousedown",c);const m=p[u.copyContainerIndex];u.unmappedCopyIndex!==-1&&m.children[u.unmappedCopyIndex].addEventListener("click",o),m.children[u.copyIndex].addEventListener("click",r),d.addEventListener("mouseenter",e),d.addEventListener("mouseleave",n),p[u.visibleIndex].addEventListener("click",a),h[u.filterIndex].addEventListener("click",l),d.addEventListener("action:select-position",t),p[u.starIndex].addEventListener("click",y=>{const w=s(y).dataset.id,b=An;b.tryParseString(w);const{selectedSegments:x}=i.segmentationGroupState.value;x.set(b,!x.has(b))});const v=new q(C.eR.fromValues(0,0,0));v.changed.add(()=>{const y=new P.R(Ie(v.value)),S=d.dataset.id,w=An;w.tryParseString(S),i.segmentStatedColors.value.delete(w),i.segmentStatedColors.value.set(w,y)}),new hi(v,void 0,h[u.colorWidgetIndex],()=>{const y=d.dataset.id,S=An;S.tryParseString(y),i.segmentStatedColors.value.delete(S)},!1)}}class Vs{constructor(e,t){if(this.displayState=e,this.template=t,e!==void 0){let n=$m.get(e);n===void 0&&(n=GD(e),$m.set(e,n)),this.registerEventHandlers=n}}static make(e,t){return new Vs(e,t?UD:Dd)}get(e){const{displayState:t}=this;return this.getWithNormalizedId(Yi(t,e))}getWithNormalizedId(e){const{displayState:t}=this,{template:n}=this,s=n.template.cloneNode(!0),r=e.key,o=e.value??r,a=o.toString();s.dataset.id=a;const{children:l}=s,c=l[0].children,d=c[n.idContainerIndex];d.children[n.idIndex].textContent=a;const{unmappedIdIndex:u}=n;if(t!==void 0?this.registerEventHandlers(s,n):c[n.visibleIndex].style.display="none",u!==-1){const h=d.children[u];if(P.R.equal(r,o)){h.style.display="none";const p=c[n.copyContainerIndex];p.children[n.unmappedCopyIndex].style.display="none"}else{const p=r.toString();s.dataset.unmappedId=p,h.textContent=p,t!==void 0&&Um(t.segmentationGroupState.value.maxIdLength,p)}}return l[n.labelIndex].textContent=e.label??"",t!==void 0&&(this.updateWithId(s,o),Um(t.segmentationGroupState.value.maxIdLength,a)),s}update(e){const t=An,n=e.dataset.id;n!==void 0&&(t.parseString(n),this.updateWithId(e,t))}updateWithId(e,t){const{children:n}=e,s=n[0].children,{template:r}=this,{displayState:o}=this,{segmentSelectionState:a}=o,{visibleSegments:l}=o.segmentationGroupState.value;s[r.visibleIndex].classList.toggle("neuroglancer-visible",l.has(t)),e.dataset.selected=(a.hasSelectedSegment&&P.R.equal(a.selectedSegment,t)).toString();const{selectedSegments:c}=o.segmentationGroupState.value;s[r.starIndex].classList.toggle("neuroglancer-starred",c.has(t));const d=s[r.idContainerIndex];let u=Rd(this.displayState,t);Gm(d.children[r.idIndex],u);const h=!!this.displayState?.segmentStatedColors.value.has(t);zm(n[r.colorWidgetIndex],u,h);const{unmappedIdIndex:p}=r;if(p!==-1){let m;if(o.baseSegmentColoring.value&&(m=e.dataset.unmappedId)!==void 0){const v=An;v.parseString(m),u=Rd(this.displayState,v)}else u=C.Oi;Gm(d.children[p],u);const g=!!this.displayState?.segmentStatedColors.value.has(t);zm(n[r.colorWidgetIndex],u,g)}}}function Gm(i,e){i.style.backgroundColor=Dm(e),i.style.color=Be(e)?"white":"black"}function zm(i,e,t){i.value=Ge(e.subarray(0,3)),i.classList.toggle("overridden",t)}class Wm extends Vs{constructor(e,t,n){const s=e.segmentationGroupState.value.segmentPropertyMap.value,r=(s?.numericalProperties??[]).filter(n),o=$D(r.length);super(e,o),this.parentElement=t,this.segmentPropertyMap=s,this.numericalProperties=r,(this.numericalPropertyWidths=new Array(this.numericalProperties.length)).fill(0)}getWithNormalizedId(e){const t=super.getWithNormalizedId(e),{numericalProperties:n}=this,{numericalPropertyIndices:s}=this.template;if(s.length>0){const r=this.segmentPropertyMap?.getSegmentInlineIndex(e.value??e.key)??-1;if(r!==-1){const{numericalPropertyWidths:o}=this;for(let a=0,l=s.length;ao[a]&&(o[a]=u,this.parentElement.style.setProperty(`--neuroglancer-column-${a}-width`,`${u}ch`)),t.children[s[a]].textContent=d}}}}return t}makeHeaderLabel(e,t,n){const s=document.createElement("span");s.textContent=e,s.classList.add("neuroglancer-segment-list-header-label"),s.classList.add("neuroglancer-segment-list-header-label"),e==="label"&&(n.style.textAlign="left");const r=document.createElement("span");r.classList.add("neuroglancer-segment-list-header-label-sort"),s.appendChild(r),r.textContent="\u25B2";const o=dx(s).width;return this.parentElement.style.setProperty(t,`${o}px`),n.appendChild(s),{id:e,label:s,sortIcon:r}}getHeader(){const{template:e}=this,t=e.template.cloneNode(!0),{children:n}=t,s=n[0].children,r=s[e.copyContainerIndex];r.style.visibility="hidden",s[e.visibleIndex].style.visibility="hidden",n[e.filterIndex].style.visibility="hidden";const o=s[e.idContainerIndex],a=[this.makeHeaderLabel("id","--neuroglancer-id-column-label-width",o.children[e.idIndex]),this.makeHeaderLabel("label","--neuroglancer-label-column-label-width",n[e.labelIndex])],{numericalProperties:l}=this,{numericalPropertyIndices:c}=this.template;for(let d=0,u=c.length;d{iT(n,s,t)},i.segmentationGroupState)),e.registerDisposer((0,_.aM)((n,s)=>{n.registerDisposer(s.segmentColorHash.changed.add(t)),n.registerDisposer(s.segmentDefaultColor.changed.add(t))},i.segmentationColorGroupState)),e.registerDisposer(i.saturation.changed.add(t)),e.registerDisposer(i.segmentSelectionState.changed.add(t)),e.registerDisposer(i.baseSegmentColoring.changed.add(t)),e.registerDisposer(i.hoverHighlight.changed.add(t)),e.registerDisposer(i.segmentStatedColors.changed.add(t))}function Hm(i,e){const t=e.redrawNeeded.dispatch;Bs(i,e,t),e.registerDisposer((0,_.aM)((n,s)=>{sT(n,s,t)},i.segmentationGroupState))}function zD(i,e){Hm(i,e),e.registerDisposer(i.objectAlpha.changed.add(e.redrawNeeded.dispatch))}function Ld(i,e){zD(i,e),e.registerDisposer(i.transform.changed.add(e.redrawNeeded.dispatch)),e.registerDisposer(i.renderScaleTarget.changed.add(e.redrawNeeded.dispatch)),e.registerDisposer(i.transparentPickEnabled.changed.add(e.redrawNeeded.dispatch))}const Jm=C.ln.create(),An=new P.R,Da=new P.R;function Rd(i,e,t=Jm){if(i==null)return t.fill(1),t;const n=i.segmentationColorGroupState.value,{segmentStatedColors:s}=n;if(s.size!==0&&n.segmentStatedColors.get(e,Da))return t[0]=(Da.low&255)/255,t[1]=((Da.low&65280)>>>8)/255,t[2]=((Da.low&16711680)>>>16)/255,t;const r=n.segmentDefaultColor.value;return r!==void 0?(t[0]=r[0],t[1]=r[1],t[2]=r[2],t):(n.segmentColorHash.compute(t,e),t)}function WD(i,e,t=1){const n=Jm;n[3]=t,Rd(i,e,n);let s=i.saturation.value;i.hoverHighlight.value&&i.segmentSelectionState.isSelected(e)&&(s>.5?s=s-=.5:s+=.5);for(let r=0;r<3;++r)n[r]=n[r]*s+(1-s);return n[0]*=t,n[1]*=t,n[2]*=t,n}function jm(i,e={}){for(const t of cg)e[t]=i[t].rpcId;return e}const HD=ar(Dr);class Ia extends HD{constructor(e,t,n){super(n),this.chunkManager=e,this.displayState=t;const s=t.segmentationGroupState.value;for(const r of cg)this.registerDisposer(s[r].addRef())}initializeCounterpartWithChunkManager(e){const{displayState:t}=this;e.chunkManager=this.chunkManager.rpcId,jm(t.segmentationGroupState.value,e),e.transform=this.registerDisposer(ft.makeFromExisting(this.chunkManager.rpc,this.displayState.transform)).rpcId,e.renderScaleTarget=this.registerDisposer(ft.makeFromExisting(this.chunkManager.rpc,this.displayState.renderScaleTarget)).rpcId,super.initializeCounterpart(this.chunkManager.rpc,e)}}function kd(i,e,t,n,s){const r=Math.min(1,i.objectAlpha.value),o=i.baseSegmentColoring.value;Rs(i.segmentationGroupState.value,(a,l)=>{const c=n?.registerUint64(e,a),d=t?WD(i,o?a:l,r):void 0;s(a,d,c,l)})}var JD=Object.defineProperty,jD=Object.getOwnPropertyDescriptor,Ym=(i,e,t,n)=>{for(var s=n>1?void 0:n?jD(e,t):e,r=i.length-1,o;r>=0;r--)(o=i[r])&&(s=(n?o(e,t,s):o(s))||s);return n&&s&&JD(e,t,s),s};/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const YD=C.pB.create(),an=C.w0.create(),Qm=!1;function Km(i,e){e.vertexBuffer=At.fromData(i,e.meshData.vertexPositions,i.ARRAY_BUFFER,i.STATIC_DRAW),e.indexBuffer=At.fromData(i,e.meshData.indices,i.ELEMENT_ARRAY_BUFFER,i.STATIC_DRAW),e.normalBuffer=At.fromData(i,e.meshData.vertexNormals,i.ARRAY_BUFFER,i.STATIC_DRAW)}function qm(i){i.vertexBuffer.dispose(),i.indexBuffer.dispose(),i.normalBuffer.dispose()}const QD=` +highp vec3 decodeNormalOctahedronSnorm8(highp vec2 e) { + vec3 v = vec3(e.xy, 1.0 - abs(e.x) - abs(e.y)); + if (v.z < 0.0) v.xy = (1.0 - abs(v.yx)) * vec2(v.x > 0.0 ? 1.0 : -1.0, v.y > 0.0 ? 1.0 : -1.0); + return normalize(v); +} +`;function Xm(i){return i>=128&&(i=i-256),Math.max(-1,i/127)}function qV(i){let e=i.length;e-=1;const t=new Float32Array(Math.floor(i.length/2)*3);let n=0;for(let s=0;s0?1:-1),l=(1-Math.abs(a))*(l>0?1:-1));const d=Math.sqrt(a**2+l**2+c**2);t[n]=a/d,t[n+1]=l/d,t[n+2]=c/d,n+=3}return t}function Zm(i){return{defineShader:e=>{e.addAttribute("highp vec3","aVertexPosition"),e.addVertexCode("highp vec3 getVertexPosition() { return aVertexPosition; }")},bind(e,t,n){n.vertexBuffer.bindToVertexAttrib(t.attribute("aVertexPosition"),3,i,!0)},endLayer:(e,t)=>{e.disableVertexAttribArray(t.attribute("aVertexPosition"))}}}const KD={[bn.Pc.float32]:Zm(WebGL2RenderingContext.FLOAT),[bn.Pc.uint16]:Zm(WebGL2RenderingContext.UNSIGNED_SHORT),[bn.Pc.uint10]:{defineShader:i=>{i.addAttribute("highp uint","aVertexPosition"),i.addVertexCode(` +highp vec3 getVertexPosition() { + return vec3(float(aVertexPosition & 1023u), + float((aVertexPosition >> 10) & 1023u), + float((aVertexPosition >> 20) & 1023u)) / 1023.0; +} +`)},bind(i,e,t){t.vertexBuffer.bindToVertexAttribI(e.attribute("aVertexPosition"),1,WebGL2RenderingContext.UNSIGNED_INT)},endLayer:(i,e)=>{i.disableVertexAttribArray(e.attribute("aVertexPosition"))}}};class ev{constructor(e,t){this.fragmentRelativeVertices=e,this.vertexPositionFormat=t,this.tempLightVec=new Float32Array(4),this.vertexPositionHandler=KD[this.vertexPositionFormat]}beginLayer(e,t,n,s){const{lightDirection:r,ambientLighting:o,directionalLighting:a}=n,l=this.tempLightVec;C.eR.scale(l,r,a),l[3]=o,e.uniform4fv(t.uniform("uLightDirection"),l);const c=s.silhouetteRendering.value;c>0&&e.uniform1f(t.uniform("uSilhouettePower"),c)}setColor(e,t,n){e.uniform4fv(t.uniform("uColor"),n)}setPickID(e,t,n){e.uniform1ui(t.uniform("uPickID"),n)}beginModel(e,t,n,s){const{projectionParameters:r}=n;e.uniformMatrix4fv(t.uniform("uModelViewProjection"),!1,C.pB.multiply(YD,r.viewProjectionMat,s)),(0,C._A)(an,s),(0,C.Jh)(an,an,r.displayDimensionRenderInfo.canonicalVoxelFactors),C.w0.invert(an,an),C.w0.transpose(an,an),e.uniformMatrix3fv(t.uniform("uNormalMatrix"),!1,an)}drawFragmentHelper(e,t,n,s,r){this.vertexPositionHandler.bind(e,t,n);const{meshData:o}=n;n.normalBuffer.bindToVertexAttrib(t.attribute("aVertexNormal"),2,WebGL2RenderingContext.BYTE,!0),n.indexBuffer.bind();const{indices:a}=o;e.drawElements(o.strips?WebGL2RenderingContext.TRIANGLE_STRIP:WebGL2RenderingContext.TRIANGLES,r-s,a.BYTES_PER_ELEMENT===2?WebGL2RenderingContext.UNSIGNED_SHORT:WebGL2RenderingContext.UNSIGNED_INT,s*a.BYTES_PER_ELEMENT)}drawFragment(e,t,n){const{meshData:s}=n,{indices:r}=s;this.drawFragmentHelper(e,t,n,0,r.length)}drawMultiscaleFragment(e,t,n,s,r){const o=n.meshData.subChunkOffsets[s],a=n.meshData.subChunkOffsets[r];this.drawFragmentHelper(e,t,n,o,a)}endLayer(e,t){this.vertexPositionHandler.endLayer(e,t),e.disableVertexAttribArray(t.attribute("aVertexNormal"))}makeGetter(e){const t=e.registerDisposer((0,_.Uq)(n=>n>0,[e.displayState.silhouetteRendering]));return Ai(e,e.gl,{memoizeKey:`mesh/MeshShaderManager/${this.fragmentRelativeVertices}/${this.vertexPositionFormat}`,parameters:t,defineShader:(n,s)=>{this.vertexPositionHandler.defineShader(n),n.addAttribute("highp vec2","aVertexNormal"),n.addVarying("highp vec4","vColor"),n.addUniform("highp vec4","uLightDirection"),n.addUniform("highp vec4","uColor"),n.addUniform("highp mat3","uNormalMatrix"),n.addUniform("highp mat4","uModelViewProjection"),n.addUniform("highp uint","uPickID"),s&&n.addUniform("highp float","uSilhouettePower"),this.fragmentRelativeVertices&&(n.addUniform("highp vec3","uFragmentOrigin"),n.addUniform("highp vec3","uFragmentShape")),n.addVertexCode(QD);let r="";this.fragmentRelativeVertices?r+=` +highp vec3 vertexPosition = uFragmentOrigin + uFragmentShape * getVertexPosition(); +highp vec3 normalMultiplier = 1.0 / uFragmentShape; +`:r+=` +highp vec3 vertexPosition = getVertexPosition(); +highp vec3 normalMultiplier = vec3(1.0, 1.0, 1.0); +`,r+=` +gl_Position = uModelViewProjection * vec4(vertexPosition, 1.0); +vec3 origNormal = decodeNormalOctahedronSnorm8(aVertexNormal); +vec3 normal = normalize(uNormalMatrix * (normalMultiplier * origNormal)); +float absCosAngle = abs(dot(normal, uLightDirection.xyz)); +float lightingFactor = absCosAngle + uLightDirection.w; +vColor = vec4(lightingFactor * uColor.rgb, uColor.a); +`,s&&(r+=` +vColor *= pow(1.0 - absCosAngle, uSilhouettePower); +`),n.setVertexMain(r),n.setFragmentMain("emit(vColor, uPickID);")}})}}class La extends Gi{constructor(e,t,n){super(),this.chunkManager=e,this.source=t,this.displayState=n,this.meshShaderManager=new ev(!1,bn.Pc.float32),this.getShader=this.meshShaderManager.makeGetter(this),Ld(n,this),this.registerDisposer(n.silhouetteRendering.changed.add(this.redrawNeeded.dispatch));const s=this.backend=this.registerDisposer(new Ia(e,n,this.layerChunkProgressInfo));s.RPC_TYPE_ID=bn.Of,s.initializeCounterpartWithChunkManager({source:t.addCounterpartRef()}),s.visibility.add(this.visibility),this.registerDisposer(n.renderScaleHistogram.visibility.add(this.visibility))}get isTransparent(){const{displayState:e}=this;return e.objectAlpha.value<1||e.silhouetteRendering.value>0}get transparentPickEnabled(){return this.displayState.transparentPickEnabled.value}get gl(){return this.chunkManager.chunkQueueManager.gl}draw(e,t){if(!e.emitColor&&e.alreadyEmittedPickID)return;const{gl:n,displayState:s,meshShaderManager:r}=this;if(s.objectAlpha.value<=0)return;const o=lr(s.transform.value,e.projectionParameters.displayDimensionRenderInfo,t);if(o===void 0)return;const{shader:a}=this.getShader(e.emitter);if(a===null)return;a.bind(),r.beginLayer(n,a,e,this.displayState),r.beginModel(n,a,e,o);const l=this.source.chunks;let c=0,d=0;const{renderScaleHistogram:u}=this.displayState,h=this.source.fragmentSource.chunks;kd(s,this,e.emitColor,e.emitPickID?e.pickIDs:void 0,(p,m,g)=>{const v=Sn(p),y=l.get(v);if(++c,y!==void 0){++d,e.emitColor&&r.setColor(n,a,m),e.emitPickID&&r.setPickID(n,a,g),c+=y.fragmentIds.length;for(const S of y.fragmentIds){const{key:w}=this.source.getFragmentKey(v,S),b=h.get(w);b!==void 0&&b.state===Ue.GPU_MEMORY&&(r.drawFragment(n,a,b),++d)}}}),e.emitColor&&(u.begin(this.chunkManager.chunkQueueManager.frameNumberCounter.frameNumber),u.add(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,d,c-d)),r.endLayer(n,a)}isReady(){const{displayState:e,source:t}=this;let n=!0;const s=t.fragmentSource.chunks;return Rs(e.segmentationGroupState.value,r=>{const o=Sn(r),a=t.chunks.get(o);if(a===void 0){n=!1;return}for(const l of a.fragmentIds){const{key:c}=this.source.getFragmentKey(o,l),d=s.get(c);if(d===void 0||d.state!==Ue.GPU_MEMORY){n=!1;return}}}),n}getObjectPosition(e,t){const n=this.displayState.transform.value;if(n.error!==void 0)return;const s=Sn(e),r=this.source.chunks.get(s);if(r===void 0)return;const{rank:o}=n,a=new Float32Array(n.modelToRenderLayerTransform.length);De.DI(a,o+1,n.modelToRenderLayerTransform,o+1,o+1);const l=new Float32Array(o);De.vo(l,a,o+1,t,o);const{fragmentIds:c}=r;let d=0;const u=[];for(const S of c){const{key:w}=this.source.getFragmentKey(s,S),b=this.source.fragmentSource.chunks.get(w);if(b===void 0)continue;const{state:x,meshData:E}=b;x!==Ue.SYSTEM_MEMORY&&x!==Ue.GPU_MEMORY||(d+=E.vertexPositions.length/o,u.push(b))}const p=100*1e3/d,m=Math.max(1,Math.floor(1/p)),g=new Float32Array(o);let v=Number.POSITIVE_INFINITY;for(const S of u){const{meshData:w}=S,{vertexPositions:b}=w;if(!(b.length0}get transparentPickEnabled(){return this.displayState.transparentPickEnabled.value}get gl(){return this.chunkManager.chunkQueueManager.gl}draw(e,t){if(!e.emitColor&&e.alreadyEmittedPickID)return;const{gl:n,displayState:s,meshShaderManager:r}=this;if(s.objectAlpha.value<=0)return;const o=lr(s.transform.value,e.projectionParameters.displayDimensionRenderInfo,t);if(o===void 0)return;const{shader:a}=this.getShader(e.emitter);if(a===null)return;a.bind(),r.beginLayer(n,a,e,this.displayState);const{renderScaleHistogram:l}=this.displayState;e.emitColor&&l.begin(this.chunkManager.chunkQueueManager.frameNumberCounter.frameNumber),(0,C._A)(an,o),(0,C.Jh)(an,an,e.projectionParameters.displayDimensionRenderInfo.voxelPhysicalScales);const c=Math.abs(C.w0.determinant(an))**(1/3),{chunks:d}=this.source,u=this.source.fragmentSource.chunks,{projectionParameters:h}=e,p=C.pB.multiply(C.pB.create(),h.viewProjectionMat,o),m=(0,C._S)(new Float32Array(24),p),g=this.displayState.renderScaleTarget.value,{fragmentRelativeVertices:v}=this.source.format;r.beginModel(n,a,e,o);let y=0,S=0;kd(s,this,e.emitColor,e.emitPickID?e.pickIDs:void 0,(w,b,x)=>{const E=Sn(w),D=d.get(E);if(++y,D===void 0)return;++S;const{manifest:I}=D,{octree:L,chunkShape:N,chunkGridSpatialOrigin:k,vertexOffsets:O}=I;if(Qm)try{dD(L)}catch(V){console.log(`invalid octree for object=${w}: ${V.message}`)}e.emitColor&&r.setColor(n,a,b),e.emitPickID&&r.setPickID(n,a,x),hm(I,p,m,g,h.width,h.height,(V,z,Y)=>{const Q=tv(u,E,V,z);return e.emitColor&&l.add(I.lodScales[V]*c,Y,Q?1:0,Q?0:1),Q},(V,z,Y,Q)=>{const X=pm(E,V,z),ce=u.get(X),oe=L[5*z],Se=L[5*z+1],Ke=L[5*z+2],$e=1<{if(!u)return;const p=Sn(h),m=r.get(p);if(m===void 0){u=!1;return}const{manifest:g}=m;hm(g,l,c,d,a.width,a.height,(v,y)=>(u=u&&tv(o,p,v,y),u),()=>{})}),u}getObjectPosition(e){const t=this.displayState.transform.value;if(t.error!==void 0)return;const n=this.source.chunks.get(Sn(e));if(n===void 0)return;const{manifest:s}=n,{clipLowerBound:r,clipUpperBound:o}=s,{rank:a}=t,l=new Float32Array(a);for(let d=0;d<3;++d)l[d]=(r[d]+o[d])/2;const c=new Float32Array(a);return De.vo(c,t.modelToRenderLayerTransform,a+1,l,a),c}}class ZD extends Jn{constructor(e,t){super(e),this.manifest=t.manifest}}class eI extends Jn{constructor(e,t){super(e),this.meshData=t}copyToGPU(e){super.copyToGPU(e),Km(e,this)}freeGPUMemory(e){super.freeGPUMemory(e),qm(this)}}class Ra extends on{constructor(e,t){super(e,t),this.fragmentSource=this.registerDisposer(new Md(this.chunkManager,this)),this.format=t.format}static encodeOptions(e){return{format:e.format,...on.encodeOptions(e)}}initializeCounterpart(e,t){this.fragmentSource.initializeCounterpart(this.chunkManager.rpc,{}),t.fragmentSource=this.fragmentSource.addCounterpartRef(),t.format=this.format,super.initializeCounterpart(e,t)}getChunk(e){return new ZD(this,e)}}let Md=class extends on{constructor(i,e){super(i),this.meshSource=e}get key(){return this.meshSource.key}getChunk(i){return new eI(this,i)}};Md=Ym([Zt(bn.pi)],Md);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function XV(i){let e=0;const t=i.length;for(let n=0;n>>0,e=(e<<15|e>>>17)>>>0,e=Math.imul(e,461845907)>>>0,i^=e,i=(i<<13|i>>>19)>>>0,i=Math.imul(i,5)+3864292196>>>0,i}function tI(i,e){return i^=e,i^=i>>>16,i=Math.imul(i,2246822507)>>>0,i^=i>>>13,i*=3266489909,i^=i>>>16,i>>>0}function iv(i,e,t){let n=i;return n=nv(n,e),n=nv(n,t),tI(n,8)}function ka(i){return i^=i>>>16,i=Math.imul(i,2246822507),i^=i>>>13,i=Math.imul(i,3266489909),i^=i>>>16,i}function sv(i,e){return i<>>32-e}function ZV(i,e,t,n){let s=e,r=e,o=e,a=e;const l=597399067,c=2869860233,d=951274213;let u=Math.imul(n,c);u=sv(u,16),u=Math.imul(u,d),r^=u;let h=Math.imul(t,l);h=sv(h,15),h=Math.imul(h,c),s^=h;const p=8;return s^=p,r^=p,o^=p,a^=p,s=s+r>>>0,s=s+o>>>0,s=s+a>>>0,r=r+s>>>0,o=o+s>>>0,a=a+s>>>0,s=ka(s),r=ka(r),o=ka(o),a=ka(a),s=s+r>>>0,s=s+o>>>0,s=s+a>>>0,r=r+s>>>0,i.low=s,i.high=r,i}/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class nI extends on{constructor(e,t){super(e,t),this.properties=t.properties}static encodeOptions(e){return{properties:e.properties}}}function iI(i,e,t){const n=i.length-1;for(;;){if(e=e&n,i[e]===0){i[e]=t;return}++e}}function Fs(i,e){return e<=255?new Uint8Array(i):e<=65535?new Uint16Array(i):new Uint32Array(i)}function sI(i){const e=i.length/2,n=2**(Math.ceil(Math.log2(e))+1),s=Fs(n,e+1);for(let r=0;rn.type==="tags"),this.labels=t?.properties.find(n=>n.type==="label"),this.numericalProperties=t?.properties.filter(n=>n.type==="number")??[]}getSegmentInlineIndex(e){const{inlineIdToIndex:t}=this;return t===void 0?-1:rI(t,this.segmentPropertyMap.inlineProperties.ids,e.low,e.high)}getSegmentLabel(e){const t=this.getSegmentInlineIndex(e);if(t===-1)return;const{labels:n,tags:s}=this;let r="";if(n!==void 0&&(r=n.values[t]),s!==void 0){const{tags:o,values:a}=s,l=a[t];for(let c=0,d=l.length;c0&&(r+=" "),r+="#",r+=u}}if(r.length!==0)return r}}function ov(i,e,t){for(let n=0,s=t.length;n{const l=e[o*2],c=e[o*2+1],d=e[a*2],u=e[a*2+1];return c-u||l-d});const s=new Uint32Array(t*2);for(let o=0;o{const{values:a}=o,l=new a.constructor(t);for(let c=0;c{const p=a[2*u+1],m=a[2*u],g=l[2*h+1],v=l[2*h];return p-g||m-v},u=>{r[u]=t,++t},u=>{o[u]=t,++t},(u,h)=>{r[u]=t,o[h]=t,++t});let c;if(t===n)c=a;else if(t===s)c=l;else{c=new Uint32Array(t*2);for(let u=0;uxt(t))},()=>{const t=pI(e);if(t!==void 0)return new oI(t)})}const gI=/^[,\s]*[0-9]+(?:[,\s]+[0-9]+)*[,\s]*$/;function mI(i,e){if(e.match(gI)!==null){const d=e.split(/[\s,]+/),u=[],h=new Set;for(let p=0,m=d.length;pd.toLowerCase()),a=i?.labels,l=[];let c;for(let d=0;d{const y=g.toLowerCase(),S=o.indexOf(y);if(S===-1){l.push({begin:v,end:u,message:`Invalid tag: ${g}`});return}if(g=r[S],t.includeTags.includes(g)||t.excludeTags.includes(g)){l.push({begin:v,end:u,message:`Duplicate tag: ${g}`});return}return g};if(h.startsWith("#")){const g=p(h.substring(1),d+1);g!==void 0&&t.includeTags.push(g);continue}if(h.startsWith("-#")){const g=p(h.substring(2),d+2);g!==void 0&&t.excludeTags.push(g);continue}if(h.startsWith("<")||h.startsWith(">")){let g=h.substring(1).toLowerCase();if(g!=="id"&&g!=="label"){const v=n?.find(y=>y.id.toLowerCase()===g&&(y.type==="number"||y.type==="label"||y.type==="string"));if(v===void 0){l.push({begin:d+1,end:u,message:`Invalid field: ${g}`});continue}g=v.id}if(t.sortBy.find(v=>v.fieldId===g)!==void 0){l.push({begin:d+1,end:u,message:`Duplicate sort field: ${g}`});continue}t.sortBy.push({order:h[0],fieldId:g});continue}if(h.startsWith("|")){let g=h.substring(1).toLowerCase();if(g==="id"||g==="label")continue;const v=n?.find(y=>y.id.toLowerCase()===g&&(y.type==="number"||y.type==="string"));if(v===void 0){l.push({begin:d+1,end:u,message:`Invalid field: ${g}`});continue}if(g=v.id,t.sortBy.find(y=>y.fieldId===g)||t.includeColumns.find(y=>y===g))continue;t.includeColumns.push(g);continue}if(h.startsWith("/")){if(t.regexp!==void 0){l.push({begin:d,end:u,message:"Only one regular expression allowed"});continue}if(t.prefix!==void 0){l.push({begin:d,end:u,message:"Prefix cannot be combined with regular expression"});continue}if(a===void 0&&r.length==0){l.push({begin:d,end:u,message:"No label property"});continue}try{t.regexp=new RegExp(h.substring(1))}catch{l.push({begin:d,end:u,message:"Invalid regular expression syntax"})}continue}const m=h.match(/^([a-zA-Z][a-zA-Z0-9_]*)(<|<=|=|>=|>)([0-9.].*)$/);if(m!==null){let g=m[1].toLowerCase();const v=m[2],y=i?.numericalProperties.find(I=>I.id.toLowerCase()===g);if(y===void 0){l.push({begin:d,end:d+g.length,message:`Invalid numerical field: ${g}`});continue}g=y.id;let S;try{S=qt(y.dataType,m[3])}catch(I){l.push({begin:d+m[1].length+m[2].length,end:u,message:I.message});continue}let w=t.numericalConstraints.find(I=>I.fieldId===g);w===void 0&&(w={fieldId:g,bounds:y.bounds},t.numericalConstraints.push(w));const b=Pe(y.bounds,w.bounds[0]),x=Pe(y.bounds,w.bounds[1]);let E=x,D=b;switch(v){case"<":E=H(y.dataType,S,-1);break;case"<=":E=S;break;case"=":E=D=S;break;case">=":D=S;break;case">":D=H(y.dataType,S,1);break}if(D=rt(b,D)>0?b:D,E=rt(x,E)<0?x:E,rt(D,E)>0){l.push({begin:d,end:u,message:"Constraint would not match any values"});continue}w.bounds=[D,E];continue}if(t.regexp!==void 0){l.push({begin:d,end:u,message:"Prefix cannot be combined with regular expression"});continue}if(a===void 0&&r.length==0){l.push({begin:d,end:u,message:"No label property"});continue}t.prefix!==void 0?t.prefix+=` ${h}`:t.prefix=h}return l.length>0?{errors:l}:(t.sortBy.length===0&&t.sortBy.push({fieldId:lv(i),order:"<"}),t)}function Nd(i){return"\\u"+i.toString(16).padStart(4,"0")}function vI(i,e){if(e.errors!==void 0)return{query:e,total:-1,count:0,errors:e.errors};if(e.ids!==void 0){const{ids:b}=e;return{query:e,total:-1,explicitIds:b,count:b.length}}const t=i?.segmentPropertyMap?.inlineProperties;if(t===void 0)return{query:e,count:0,total:-1};const n=t?.properties,s=t.ids.length/2,r=i?.tags?.tags?.length||0;let o=Fs(s,s);const a=Fs(r,r);a.fill(1);for(let b=0;b{const x=o.length;let E=0;for(let D=0;D{const x=i.tags.tagDescriptions,E=i.tags.tags;a.fill(0);for(let D=0;DE[D].match(b)!==null),x!==void 0&&l(D=>E[D].startsWith(x))}if(o.length==0&&b!==void 0||i.labels==null&&b!=null){o=Fs(s,s);for(let E=0;E0||u.length>0){const{values:b,tags:x}=h,E=[];for(const k of d)E.push([x.indexOf(k),1]);for(const k of u)E.push([x.indexOf(k),0]);E.sort((k,O)=>k[0]-O[0]);let D="^",I=0;const L=k=>{kb[k].match(N)!==null)}let p,m;const{numericalConstraints:g}=e;if(g.length>0){const b=i.numericalProperties,x=g.length,E=2**x-1;p=Fs(o.length,E);for(let L=0;LQ.id===N.fieldId),{values:O}=k,V=2**L,[z,Y]=N.bounds;for(let Q=0,X=o.length;Q=z&&ce<=Y)}}m=o,o=m.slice();const D=o.length;let I=0;for(let L=0;L0&&v.push(z)}b.push(...v),v=b}const y=(b,x)=>{if(b.type!=="number"){const{values:E}=b;o.sort((D,I)=>(0,kr.e)(E[D],E[I])*x)}else{const E=b.values;o.sort((D,I)=>(E[D]-E[I])*x)}},S=b=>{h!==void 0&&y(h,b);const x=i?.labels;x!==void 0&&y(x,b)},{sortBy:w}=e;for(let b=w.length-1;b>=0;--b){const{fieldId:x,order:E}=w[b],D=E==="<"?1:-1;if(x==="id"){if(b+1===w.length){if(E==="<")continue;o.reverse();continue}o.sort((I,L)=>D*(I-L))}else x==="label"?S(D):y(n.find(I=>I.id===x),D)}return{query:e,intermediateIndices:m,intermediateIndicesMask:p,indices:o,tags:v,count:o.length,total:s}}function yI(i,e,t){const{values:s}=e,[r,o]=t,a=o<=r?0:256/(o-r),l=new Uint32Array(258),{numericalConstraints:c}=i.query,d=c.findIndex(u=>u.fieldId===e.id);if(d===-1){const u=i.indices;for(let h=0,p=u.length;h>>0]}}else{const u=i.intermediateIndices,h=i.intermediateIndicesMask,p=2**c.length-1-2**d;for(let m=0,g=u.length;m>>0]}}return{queryResult:i,histogram:l,window:t}}function SI(i,e,t,n){if(i===void 0){t.length=0,n.length=0;return}const{numericalProperties:s}=i,r=s.length;if(e?.indices===void 0){t.length=0;return}for(let a=0;aa.toString()).join(", ");let n="";e=e;const{prefix:s,regexp:r}=e;s!==void 0?n=s:r!==void 0&&(n=`/${r}`);for(const a of e.includeTags)n.length>0&&(n+=" "),n+=`#${a}`;for(const a of e.excludeTags)n.length>0&&(n+=" "),n+=`-#${a}`;for(const a of e.numericalConstraints){const{fieldId:l,bounds:c}=a,[d,u]=c,h=i.numericalProperties.find(p=>p.id===l);if(!Bt(h.dataType,h.bounds,c)){if(rt(d,u)===0){n.length>0&&(n+=" "),n+=`${l}=${d}`;continue}if(rt(d,h.bounds[0])>0){n.length>0&&(n+=" ");const p=H(h.dataType,d,-1),m=d.toString(),g=p.toString();h.dataType!==R.FLOAT32||m.length<=g.length?n+=`${l}>=${m}`:n+=`${l}>${g}`}if(rt(u,h.bounds[1])<0){n.length>0&&(n+=" ");const p=H(h.dataType,u,1),m=u.toString(),g=p.toString();h.dataType!==R.FLOAT32||m.length<=g.length?n+=`${l}<=${m}`:n+=`${l}<${g}`}}}let{sortBy:o}=e;if(o.length===1){const a=o[0];a.order==="<"&&a.fieldId===lv(i)&&(o=[])}for(const a of o)n.length>0&&(n+=" "),n+=`${a.order}${a.fieldId}`;for(const a of e.includeColumns)n.length>0&&(n+=" "),n+=`|${a}`;return n}const Us=new P.R;function CI(i,e,t){if(e===void 0)return;const{explicitIds:n}=e;if(n!==void 0){n.forEach(t);return}const{indices:s}=e;if(s!==void 0){const{ids:r}=i.segmentPropertyMap.inlineProperties;for(let o=0,a=s.length;o{t.has(s)&&++n}),n}function dv(i,e,t,n){const s=i.includeTags.filter(o=>o!==e),r=i.excludeTags.filter(o=>o!==e);return n===!0&&(t?s:r).push(e),{...i,includeTags:s,excludeTags:r}}function xI(i){return i.ids!==void 0?!1:i.errors!==void 0?!0:!(i.numericalConstraints.length>0||i.includeTags.length>0||i.excludeTags.length>0||i.prefix||i.regexp)}function Pa(i,e){if(i===void 0||i.ids!==void 0||i.errors!==void 0)return!1;const{sortBy:t,includeColumns:n}=i;return t.find(s=>s.fieldId===e)!==void 0||n.includes(e)}/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class EI extends Gt{constructor(e){super(),this.layer=e;const{element:t}=this;t.appendChild(this.registerDisposer(new Wt(e.displayState.segmentationGroupState.value.graph,(n,s,r)=>{n?.tabContents&&s.appendChild(n.tabContents(e,r,this))})).element)}}class Od{}class _d extends T.O8{constructor(e,t){super(),this.graph=e,this.segmentsState=t}createRenderLayers(e,t,n){return[]}}function e2(i,e){let t,n;const s=()=>{const{value:a}=e;if(a===void 0){n!==void 0&&(n(),n=void 0,t=void 0);return}t!=null&&Uint64.equal(t,a)||(n!==void 0&&(n(),n=void 0,t=void 0),n=i.trackSegment(a,l=>{t=l,e.value=l??void 0}))};s();const r=e.changed.add(s);return()=>{r(),n!==void 0&&(n(),n=void 0)}}var Vd=G(9100),TI=Object.defineProperty,DI=Object.getOwnPropertyDescriptor,II=(i,e,t,n)=>{for(var s=n>1?void 0:n?DI(e,t):e,r=i.length-1,o;r>=0;r--)(o=i[r])&&(s=(n?o(e,t,s):o(s))||s);return n&&s&&TI(e,t,s),s};/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const LI="DisjointUint64Sets",uv="DisjointUint64Sets.add",hv="DisjointUint64Sets.clear",pv="DisjointUint64Sets.highBitRepresentativeChanged",fv="DisjointUint64Sets.deleteSet";let Ki=class extends vo{constructor(){super(...arguments),this.disjointSets=new Vd.I,this.changed=new j.IY}get value(){return this}static makeWithCounterpart(i,e){const t=new Ki;return t.disjointSets.visibleSegmentEquivalencePolicy=e,t.registerDisposer(e.changed.add(()=>{gv(t)})),t.initializeCounterpart(i),e.value&&gv(t),t}disposed(){this.disjointSets=void 0,this.changed=void 0,super.disposed()}link(i,e){if(this.disjointSets.link(i,e)){const{rpc:t}=this;return t&&t.invoke(uv,{id:this.rpcId,al:i.low,ah:i.high,bl:e.low,bh:e.high}),this.changed.dispatch(),!0}return!1}linkAll(i){for(let e=1,t=i.length;e{(0,f.$v)(t,(n,s)=>{e[s%2].parseString(String(n),10),s!==0&&this.link(e[0],e[1])})})}}assignFrom(i){this.clear(),i instanceof Ki&&(i=i.disjointSets);for(const[e,t]of i)this.link(e,t)}};Ki=II([yo(LI)],Ki);const $s=new P.R,Bd=new P.R;pt(uv,function(i){const e=this.get(i.id);$s.low=i.al,$s.high=i.ah,Bd.low=i.bl,Bd.high=i.bh,e.disjointSets.link($s,Bd)&&e.changed.dispatch()}),pt(hv,function(i){const e=this.get(i.id);e.disjointSets.clear()&&e.changed.dispatch()});function gv(i){i.rpc.invoke(pv,{id:i.rpcId,value:i.disjointSets.visibleSegmentEquivalencePolicy.value})}pt(pv,function(i){const e=this.get(i.id);e.disjointSets.visibleSegmentEquivalencePolicy.value=i.value}),pt(fv,function(i){const e=this.get(i.id);$s.low=i.l,$s.high=i.h,e.disjointSets.deleteSet($s)&&e.changed.dispatch()});/** + * @license + * Copyright 2021 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class RI extends Od{constructor(){super(...arguments),this.spanningTreeEdges=new Map,this.equivalences=new Ki,this.connections=new Set,this.changed=new j.HN}link(e,t){this.equivalences.link(e,t);for(const n of this.connections)n.segmentsState.segmentEquivalences.link(e,t)}linkAll(e){this.equivalences.linkAll(e);for(const t of this.connections)t.segmentsState.segmentEquivalences.linkAll(e)}deleteSet(e){this.equivalences.deleteSet(e);for(const t of this.connections)t.segmentsState.segmentEquivalences.deleteSet(e)}normalizeAll(){for(const e of this.connections)Fd(e.segmentsState.visibleSegments,e.segmentsState.segmentEquivalences.disjointSets)}addSpanningTreeEdge(e,t){const n=e.toString(),s=t.toString(),{spanningTreeEdges:r}=this;let o=r.get(n);o===void 0&&(o=new Set,r.set(n,o));let a=r.get(s);a===void 0&&(a=new Set,r.set(s,a)),o.add(s),a.add(n)}removeSpanningTreeEdge(e,t){const n=e.toString(),s=t.toString(),{spanningTreeEdges:r}=this,o=r.get(n),a=r.get(s);o.delete(s),o.size===0&&r.delete(n),a.delete(n),a.size===0&&r.delete(s)}*getSpanningTreeNeighbors(e){const t=new P.R,n=this.spanningTreeEdges.get(e.toString());if(n!==void 0)for(const s of n)t.parseString(s),yield t}restoreState(e){const{equivalences:t,spanningTreeEdges:n}=this;if(t.clear(),n.clear(),e===void 0)return;const s=[new P.R,new P.R];(0,f.$v)(e,r=>{(0,f.$v)(r,(o,a)=>{s[a%2].parseString(String(o),10),a!==0&&t.link(s[0],s[1])&&this.addSpanningTreeEdge(s[0],s[1])})})}toJSON(){const{spanningTreeEdges:e}=this;if(e.size===0)return;const t=new Array;for(const[n,s]of e){const r=P.R.parseString(n);for(const o of s){const a=P.R.parseString(o);P.R.compare(r,a)>0||t.push([r,a])}}return t.sort((n,s)=>P.R.compare(n[0],s[0])||P.R.compare(n[1],s[1])),t.map(n=>n.map(s=>s.toString()))}get visibleSegmentEquivalencePolicy(){return Rt.y6.MIN_REPRESENTATIVE}async merge(e,t){const{equivalences:n}=this;return P.R.equal(n.get(e),n.get(t))?e:(this.addSpanningTreeEdge(e,t),this.link(e,t),this.normalizeAll(),this.changed.dispatch(),n.get(e))}async split(e,t){const n=this.computeSplit(e,t);if(n===void 0)throw new Error("Segments are already split");const{includeBaseSegments:s,includeRepresentative:r,excludeBaseSegments:o,excludeRepresentative:a}=n,{equivalences:l}=this;this.deleteSet(e),this.linkAll(s),this.linkAll(o);const c=(h,p)=>{for(const m of h)for(const g of this.getSpanningTreeNeighbors(m))P.R.equal(l.get(g),p)||this.removeSpanningTreeEdge(m,g)},d=l.get(e),u=l.get(t);c(s,d),c(o,u);for(const h of this.connections){const{selectedSegments:p,visibleSegments:m}=h.segmentsState;p.has(a)&&(p.delete(a),p.add(r),m.add(r))}return this.normalizeAll(),this.changed.dispatch(),{include:d,exclude:u}}trackSegment(e,t){return()=>{}}computeSplit(e,t){const{equivalences:n}=this,s=n.get(e);if(!P.R.equal(s,n.get(t)))return;const r=new Vd.I;for(const u of n.setElements(s))if(!P.R.equal(u,t))for(const h of this.getSpanningTreeNeighbors(u))P.R.equal(h,t)||r.link(u,h);const o=[],a=[],l=r.get(e);let c=e,d=t;for(const u of n.setElements(s))P.R.equal(r.get(u),l)?(o.push(u),P.R.compare(u,c)<0&&(c=u)):(a.push(u),P.R.compare(u,d)<0&&(d=u));return o.sort(P.R.compare),a.sort(P.R.compare),{includeBaseSegments:o,includeRepresentative:c,excludeBaseSegments:a,excludeRepresentative:d}}connect(e){const t=e.displayState.segmentationGroupState.value,n=new kI(this,t);return t.segmentEquivalences.assignFrom(this.equivalences),Fd(t.visibleSegments,t.segmentEquivalences.disjointSets),n.registerDisposer(t.visibleSegments.changed.add(n.registerCancellable((0,Fe.A)(()=>Fd(t.visibleSegments,t.segmentEquivalences.disjointSets),0)))),this.connections.add(n),n.registerDisposer(()=>{this.connections.delete(n)}),n}}function Fd(i,e){const t=[];for(const n of i.unsafeKeys()){const s=e.get(n);P.R.equal(n,s)||(t.push(s),i.delete(n))}for(const n of t)i.add(n)}class kI extends _d{computeSplit(e,t){return this.graph.computeSplit(e,t)}}var PI=G(3786);/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const mv=yr;function Aa(i,e){i.addVertexCode(wc),i.addUniform("highp vec3","uCircleParams"),i.addVarying("highp vec4","vCircleCoord"),i.addVertexCode(` +void emitCircle(vec4 position, float diameter, float borderWidth) { + gl_Position = position; + float totalDiameter = diameter + 2.0 * (borderWidth + uCircleParams.z); + if (diameter == 0.0) totalDiameter = 0.0; + vec2 circleCornerOffset = getQuadVertexPosition(vec2(-1.0, -1.0), vec2(1.0, 1.0)); + gl_Position.xy += circleCornerOffset * uCircleParams.xy * gl_Position.w * totalDiameter; + vCircleCoord.xy = circleCornerOffset; + if (borderWidth == 0.0) { + vCircleCoord.z = totalDiameter; + vCircleCoord.w = 1e-6; + } else { + vCircleCoord.z = diameter / totalDiameter; + vCircleCoord.w = uCircleParams.z / totalDiameter; + } +} +`),e?i.addFragmentCode(` +float getCircleAlphaMultiplier() { + return 1.0 - 2.0 * abs(0.5 - gl_FragCoord.z); +} +`):i.addFragmentCode(` +float getCircleAlphaMultiplier() { + return 1.0; +} +`),i.addFragmentCode(` +vec4 getCircleColor(vec4 interiorColor, vec4 borderColor) { + float radius = length(vCircleCoord.xy); + if (radius > 1.0) { + discard; + } + + float borderColorFraction = clamp((radius - vCircleCoord.z) / vCircleCoord.w, 0.0, 1.0); + float feather = clamp((1.0 - radius) / vCircleCoord.w, 0.0, 1.0); + vec4 color = mix(interiorColor, borderColor, borderColorFraction); + + return vec4(color.rgb, color.a * feather * getCircleAlphaMultiplier()); +} +`)}function Ma(i,e,t){const{gl:n}=i;n.uniform3f(i.uniform("uCircleParams"),1/e.width,1/e.height,Math.max(1e-6,t.featherWidthInPixels))}function Na(i,e,t){Ao(i,e,t)}/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function xi(i){i.addAttribute("int","aDummyVertexId",0),i.addVertexCode(` +int getVertexId () { + return aDummyVertexId + gl_VertexID; +} +#define gl_VertexID (getVertexId()) +`)}class Qn extends T.O8{constructor(e){super(),this.buffer=new At(e),this.size=0}disposed(){this.buffer.dispose()}enable(e=256){const{buffer:t}=this,{gl:n}=t;t.bind(),e>this.size&&(this.size=e,n.bufferData(WebGL2RenderingContext.ARRAY_BUFFER,new Int32Array(e),WebGL2RenderingContext.STATIC_DRAW)),n.vertexAttribIPointer(0,1,WebGL2RenderingContext.INT,0,0),n.vertexAttribDivisor(0,0),n.enableVertexAttribArray(0)}disable(){const{gl:e}=this.buffer;e.disableVertexAttribArray(0)}static get(e){return e.memoize.get("VertexIdHelper",()=>new Qn(e))}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const AI=C.pB.create(),vv=`void main() { + emitDefault(); +} +`,Gr=[],MI=Wi(new Ns,R.FLOAT32,3);class yv extends T.O8{constructor(e,t){super(),this.base=e,this.targetIsSliceView=t,this.textureAccessHelper=new xa("vertexData"),this.vertexIdHelper=this.registerDisposer(Qn.get(this.gl)),this.edgeShaderGetter=Ai(this,this.gl,{memoizeKey:{type:"skeleton/SkeletonShaderManager/edge",vertexAttributes:this.vertexAttributes},fallbackParameters:this.base.fallbackShaderParameters,parameters:this.base.displayState.skeletonRenderingOptions.shaderControlState.builderState,shaderError:this.base.displayState.shaderError,defineShader:(n,s)=>{if(s.parseResult.errors.length!==0)throw new Error("Invalid UI control specification");this.defineCommonShader(n),this.defineAttributeAccess(n),In(n),n.addAttribute("highp uvec2","aVertexIndex"),n.addUniform("highp float","uLineWidth");let r=` +highp vec3 vertexA = readAttribute0(aVertexIndex.x); +highp vec3 vertexB = readAttribute0(aVertexIndex.y); +emitLine(uProjection, vertexA, vertexB, uLineWidth); +highp uint lineEndpointIndex = getLineEndpointIndex(); +highp uint vertexIndex = aVertexIndex.x * lineEndpointIndex + aVertexIndex.y * (1u - lineEndpointIndex); +`;n.addFragmentCode(` +vec4 segmentColor() { + return uColor; +} +void emitRGB(vec3 color) { + emit(vec4(color * uColor.a, uColor.a * getLineAlpha() * ${this.getCrossSectionFadeFactor()}), uPickID); +} +void emitDefault() { + emit(vec4(uColor.rgb, uColor.a * getLineAlpha() * ${this.getCrossSectionFadeFactor()}), uPickID); +} +`),n.addFragmentCode(Is);const{vertexAttributes:o}=this,a=o.length;for(let l=1;l{if(s.parseResult.errors.length!==0)throw new Error("Invalid UI control specification");this.defineCommonShader(n),this.defineAttributeAccess(n),Aa(n,this.targetIsSliceView),n.addUniform("highp float","uNodeDiameter");let r=` +highp uint vertexIndex = uint(gl_InstanceID); +highp vec3 vertexPosition = readAttribute0(vertexIndex); +emitCircle(uProjection * vec4(vertexPosition, 1.0), uNodeDiameter, 0.0); +`;n.addFragmentCode(` +vec4 segmentColor() { + return uColor; +} +void emitRGBA(vec4 color) { + vec4 borderColor = color; + emit(getCircleColor(color, borderColor), uPickID); +} +void emitRGB(vec3 color) { + emitRGBA(vec4(color, 1.0)); +} +void emitDefault() { + emitRGBA(uColor); +} +`),n.addFragmentCode(Is);const{vertexAttributes:o}=this,a=o.length;for(let l=1;l{e.addTextureSampler(`${Ca(s.dataType)}sampler2D`,`uVertexAttributeSampler${r}`,Gr[r]),e.addVertexCode(t.getAccessor(`readAttribute${r}`,`uVertexAttributeSampler${r}`,s.dataType,s.numComponents))})}getCrossSectionFadeFactor(){return this.targetIsSliceView?"(clamp(1.0 - 2.0 * abs(0.5 - gl_FragCoord.z), 0.0, 1.0))":"(1.0)"}beginLayer(e,t,n,s){const{viewProjectionMat:r}=n.projectionParameters,o=C.pB.multiply(AI,r,s);e.uniformMatrix4fv(t.uniform("uProjection"),!1,o),this.vertexIdHelper.enable()}setColor(e,t,n){e.uniform4fv(t.uniform("uColor"),n)}setPickID(e,t,n){e.uniform1ui(t.uniform("uPickID"),n)}drawSkeleton(e,t,n,s,r){const{vertexAttributes:o}=this,a=o.length,{vertexAttributeTextures:l}=s;for(let c=0;c(i[i.LINES=0]="LINES",i[i.LINES_AND_POINTS=1]="LINES_AND_POINTS",i))(Sv||{});class bv extends Oi.F{constructor(e,t=e){super(Sv,e,t)}}class Cv extends _.DN{constructor(e,t=e){super(e,f.Mo,t)}}class NI{constructor(){this.compound=new fr,this.shader=Co(vv),this.shaderControlState=new Jo(this.shader),this.params2d={mode:new bv(1),lineWidth:new Cv(2)},this.params3d={mode:new bv(0),lineWidth:new Cv(1)};const{compound:e}=this;e.add("shader",this.shader),e.add("shaderControls",this.shaderControlState),e.add("mode2d",this.params2d.mode),e.add("lineWidth2d",this.params2d.lineWidth),e.add("mode3d",this.params3d.mode),e.add("lineWidth3d",this.params3d.lineWidth)}get changed(){return this.compound.changed}reset(){this.compound.reset()}restoreState(e){e!==void 0&&this.compound.restoreState(e)}toJSON(){const e=this.compound.toJSON();for(const t of Object.values(e))if(t!==void 0)return e}}class OI extends T.O8{constructor(e,t,n){super(),this.chunkManager=e,this.source=t,this.displayState=n,this.layerChunkProgressInfo=new fo,this.redrawNeeded=new j.IY,this.fallbackShaderParameters=new _.B0(Ho(Er(vv))),Ld(n,this),this.displayState.shaderError.value=void 0;const{skeletonRenderingOptions:s}=n;this.registerDisposer(s.shader.changed.add(()=>{this.displayState.shaderError.value=void 0,this.redrawNeeded.dispatch()}));const r=this.sharedObject=this.registerDisposer(new Ia(e,n,this.layerChunkProgressInfo));r.RPC_TYPE_ID=PI.k,r.initializeCounterpartWithChunkManager({source:t.addCounterpartRef()});const o=this.vertexAttributes=[VI];for(const[a,l]of t.vertexAttributes)o.push({name:a,dataType:l.dataType,numComponents:l.numComponents,webglDataType:_I(l.dataType),glslDataType:l.numComponents>1?`vec${l.numComponents}`:"float"})}get visibility(){return this.sharedObject.visibility}get gl(){return this.chunkManager.chunkQueueManager.gl}draw(e,t,n,s,r){const o=s.lineWidth.value,{gl:a,source:l,displayState:c}=this;if(c.objectAlpha.value<=0)return;const d=lr(c.transform.value,e.projectionParameters.displayDimensionRenderInfo,r);if(d===void 0)return;let u;s.mode.value===1?u=Math.max(5,o*2):u=o;const h=n.edgeShaderGetter(e.emitter),p=n.nodeShaderGetter(e.emitter),{shader:m,parameters:g}=h,{shader:v,parameters:y}=p;if(m===null||v===null)return;const{shaderControlState:S}=this.displayState.skeletonRenderingOptions;m.bind(),n.beginLayer(a,m,e,d),vi(a,m,S,g.parseResult.controls),a.uniform1f(m.uniform("uLineWidth"),o),v.bind(),n.beginLayer(a,v,e,d),a.uniform1f(v.uniform("uNodeDiameter"),u),vi(a,v,S,y.parseResult.controls);const w=l.chunks;kd(c,t,e.emitColor,e.emitPickID?e.pickIDs:void 0,(b,x,E)=>{const D=Sn(b),I=w.get(D);I===void 0||I.state!==Ue.GPU_MEMORY||(x!==void 0&&(m.bind(),n.setColor(a,m,x),v.bind(),n.setColor(a,v,x)),E!==void 0&&(m.bind(),n.setPickID(a,m,E),v.bind(),n.setPickID(a,v,E)),n.drawSkeleton(a,m,v,I,e.projectionParameters))}),n.endLayer(a,m)}isReady(){const{source:e,displayState:t}=this;if(t.objectAlpha.value<=0)return!0;const n=e.chunks;let s=!0;return Rs(t.segmentationGroupState.value,r=>{const o=Sn(r),a=n.get(o);if(a===void 0||a.state!==Ue.GPU_MEMORY){s=!1;return}}),s}}class Ud extends Gi{constructor(e){super(),this.base=e,this.renderHelper=this.registerDisposer(new yv(this.base,!1)),this.renderOptions=this.base.displayState.skeletonRenderingOptions.params3d,this.layerChunkProgressInfo=e.layerChunkProgressInfo,this.registerDisposer(e),this.registerDisposer(e.redrawNeeded.add(this.redrawNeeded.dispatch));const{renderOptions:t}=this;this.registerDisposer(t.mode.changed.add(this.redrawNeeded.dispatch)),this.registerDisposer(t.lineWidth.changed.add(this.redrawNeeded.dispatch)),this.registerDisposer(e.visibility.add(this.visibility))}get gl(){return this.base.gl}get isTransparent(){return this.base.displayState.objectAlpha.value<1}draw(e,t){!e.emitColor&&e.alreadyEmittedPickID||this.base.draw(e,this,this.renderHelper,this.renderOptions,t)}isReady(){return this.base.isReady()}}class wv extends Fi{constructor(e){super(),this.base=e,this.renderHelper=this.registerDisposer(new yv(this.base,!0)),this.renderOptions=this.base.displayState.skeletonRenderingOptions.params2d,this.layerChunkProgressInfo=e.layerChunkProgressInfo,this.registerDisposer(e);const{renderOptions:t}=this;this.registerDisposer(t.mode.changed.add(this.redrawNeeded.dispatch)),this.registerDisposer(t.lineWidth.changed.add(this.redrawNeeded.dispatch)),this.registerDisposer(e.redrawNeeded.add(this.redrawNeeded.dispatch)),this.registerDisposer(e.visibility.add(this.visibility))}get gl(){return this.base.gl}draw(e,t){this.base.draw(e,this,this.renderHelper,this.renderOptions,t)}isReady(){return this.base.isReady()}}function _I(i){switch(i){case R.FLOAT32:return WebGL2RenderingContext.FLOAT;default:throw new Error(`Data type not supported by WebGL: ${R[i]}`)}}const VI={dataType:R.FLOAT32,numComponents:3,name:"",webglDataType:WebGL2RenderingContext.FLOAT,glslDataType:"vec3"};class BI extends Jn{constructor(e,t){super(e),this.vertexAttributes=t.vertexAttributes;const n=this.indices=t.indices;this.numVertices=t.numVertices,this.vertexAttributeOffsets=t.vertexAttributeOffsets,this.numIndices=n.length}copyToGPU(e){super.copyToGPU(e);const{attributeTextureFormats:t}=this.source,{vertexAttributes:n,vertexAttributeOffsets:s}=this,r=this.vertexAttributeTextures=[];for(let o=0,a=s.length;o(i[i.UNKNOWN=0]="UNKNOWN",i[i.IMAGE=1]="IMAGE",i[i.SEGMENTATION=2]="SEGMENTATION",i))(St||{});const t2=18;function $d(i){const{rank:e,dataType:t,fillValue:n=t===R.UINT64?P.R.ZERO:0,compressedSegmentationBlockSize:s}=i,{baseVoxelOffset:r=new Float32Array(e)}=i;return{...Ko(i),compressedSegmentationBlockSize:s,baseVoxelOffset:r,dataType:t,fillValue:n}}function $I(i){if(i.compressedSegmentationBlockSize!==void 0||i.volumeType!==2&&!i.volumeSourceOptions.discreteValues)return!1;switch(i.dataType){case R.UINT32:case R.UINT64:break;default:return!1}switch(i.rank){case 3:return!0;case 4:{const{chunkDataSize:e}=i;return e[3]===1}default:return!1}}function xv(i){const{rank:e,lowerVoxelBound:t,upperVoxelBound:n}=i;if(!$I(i))return $d(i);let{volumeSourceOptions:{displayRank:s,multiscaleToViewTransform:r},chunkToMultiscaleTransform:o,chunkToViewTransform:a}=i;a===void 0&&(a=De.lw(new Float32Array(e*s),s,r,s,o,e+1,s,e,e));const{maxCompressedSegmentationBlockSize:l,chunkDataSize:c}=i;return $d({...i,compressedSegmentationBlockSize:Float32Array.from(Qo({rank:e,chunkToViewTransform:a,displayRank:s,lowerVoxelBound:t,upperVoxelBound:n,maxVoxelsPerChunkLog2:9,maxBlockSize:l===void 0?c:uC(new Uint32Array(e),c,l)}))})}function qi(i){const{rank:e}=i,{volumeSourceOptions:{displayRank:t,multiscaleToViewTransform:n,modelChannelDimensionIndices:s},chunkToMultiscaleTransform:r}=i,o=De.lw(new Float32Array(t*e),t,n,t,r,e+1,t,e,e);let{minBlockSize:a}=i;a===void 0?(a=new Uint32Array(e),a.fill(1)):a=new Uint32Array(a);const{lowerVoxelBound:l,upperVoxelBound:c}=i;if(s.length!==0)for(const u of(0,C.PC)(r,e,s)){let h=c[u];l!==void 0&&(h-=l[u]),a[u]=h}const{chunkDataSizes:d=ME({...i,minBlockSize:a,chunkToViewTransform:o,displayRank:t})}=i;return d.map(u=>xv({...i,chunkDataSize:u,chunkToViewTransform:o}))}const n2="volume";/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function Ev(i,e,t,n){const{dataType:s}=e;e.defineShader(i,t);let r="",o="";if(t===0)r+="highp int ignoredChannelIndex";else for(let l=0;l=l[g])return;if(t.channelSpaceShape.length===0)return a.getValueAt(r);const{numChannels:c,chunkChannelCoordinates:d,chunkChannelDimensionIndices:u}=t,h=u.length;let p=0;const m=new Array(c);for(let g=0;g{const i=[0,1,2,4,5,3,6,7],e=[0,1,2,5,3,4,6,7],t=[0,1,1,4,4,7,4,7,1,5,0,1,1,4,4,7,0,2,2,5,5,7,5,7,2,6,0,2,2,5,5,7,0,3,3,6,6,7,6,7,3,4,0,3,3,6,6,7],n=[0,1,2,3,4,5,6,7,1,4,5,0,3,7,2,6,2,6,0,5,7,3,1,4,3,0,6,4,1,2,7,5,4,3,7,1,0,6,5,2,5,2,1,7,6,0,4,3,6,7,3,2,5,4,0,1,7,5,4,6,2,1,3,0],s=new Int32Array(8*8*6);for(let r=0;r<8;++r)for(let o=0;o{e.gl.uniform3fv(e.uniform("uVertexBasePosition"),Gd)}),i.addVertexCode(` +vec3 getBoundingBoxPlaneIntersectionVertexPosition(vec3 chunkSize, vec3 boxLower, vec3 lowerClipBound, vec3 upperClipBound, int vertexIndex, float planeDistance) { + for (int e = 0; e < 4; ++e) { + highp ivec2 vidx = uVertexIndex[vertexIndex*4 + e]; + highp vec3 v1 = max(lowerClipBound, min(upperClipBound, chunkSize * uVertexBasePosition[vidx.x] + boxLower)); + highp vec3 v2 = max(lowerClipBound, min(upperClipBound, chunkSize * uVertexBasePosition[vidx.y] + boxLower)); + highp vec3 vDir = v2 - v1; + highp float denom = dot(vDir, uPlaneNormal); + if (abs(denom) > ${Iv}) { + highp float lambda = (planeDistance - dot(v1, uPlaneNormal)) / denom; + if ((lambda >= -${_a}) && (lambda <= (1.0 + ${_a}))) { + lambda = clamp(lambda, 0.0, 1.0); + highp vec3 position = v1 + lambda * vDir; + return position; + } + } + } + return vec3(0, 0, 0); +} +vec3 getBoundingBoxPlaneIntersectionVertexPosition(vec3 chunkSize, vec3 boxLower, vec3 lowerClipBound, vec3 upperClipBound, int vertexIndex) { + return getBoundingBoxPlaneIntersectionVertexPosition(chunkSize, boxLower, lowerClipBound, upperClipBound, vertexIndex, uPlaneDistance); +} +`)}function kv(i,e,t,n,s,r,o,a=!0){const l=Lv(s),c=Rv.subarray(l*48,(l+1)*48),d=[0,0],u=[C.eR.create(),C.eR.create()],h=C.eR.create(),p=C.eR.create(),m=g=>Gd.subarray(g*3,g*3+3);for(let g=0;g<4;++g){for(let y=0;y<2;++y)d[y]=c[2*(o*4+g)+y],C.eR.multiply(u[y],i,m(d[y])),C.eR.add(u[y],u[y],r),C.eR.min(u[y],u[y],t),C.eR.max(u[y],u[y],e);C.eR.subtract(h,u[1],u[0]);const v=C.eR.dot(h,s);if(Math.abs(v)>Iv){let y=(n-C.eR.dot(u[0],s))/v;if(y>=-_a&&y<=1+_a)return a&&console.log(`vertex ${o}, e = ${g}, good, lambda=${y}, denom=${v}, v0=${u[0].join()}, vDir=${h.join()}`),y=Math.max(0,Math.min(1,y)),C.eR.scaleAndAdd(p,u[0],h,y),p;a&&console.log(`vertex ${o}, e = ${g}, skipped, denom = ${v}, vDir = ${h.join()}, v0=${u[0].join()}, v1=${u[1].join()}uPlaneNormal = ${(0,C.nL)(s)}, lambda=${y}`)}else a&&console.log(`vertex ${o}, e = ${g}, skipped, deom = ${v}, vDir = ${(0,C.nL)(h)}, uPlaneNormal = ${(0,C.nL)(s)}, uLowerClipBound=${e.join()}, uUpperClipBound=${t.join()}, chunkSize=${i}, uVertexBasePosition(v0)=${m(d[0]).join()}, uVertexBasePosition(v1)=${m(d[1]).join()}, uTranslation=${r.join()}`)}}function i2(i,e,t,n,s,r){const o=[];for(let a=0;a<6;++a){const l=kv(i,e,t,n,s,r,a,!1);l!==void 0&&o.push(l)}return o}function JI(i,e,t){const{gl:n}=i;n.uniform3fv(i.uniform("uPlaneNormal"),e),n.uniform1f(i.uniform("uPlaneDistance"),t);const s=Lv(e);n.uniform2iv(i.uniform("uVertexIndex"),Rv.subarray(s*48,(s+1)*48))}function zd(i,e,t,n,s){const r=(0,C.uD)(WI,e,n);C.eR.normalize(r,r);const o=C.eR.dot(C.eR.transformMat4(HI,t,s),r);JI(i,r,o)}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const Wd=!1,Pv=.001,Av=C.pB.create();function jI(i,e){if(xi(i),Va(i),i.addUniform("highp vec3","uTranslation"),i.addUniform("highp mat4","uProjectionMatrix"),i.addUniform("highp vec3","uChunkDataSize"),i.addUniform("highp vec3","uLowerClipBound"),i.addUniform("highp vec3","uUpperClipBound"),e){In(i),i.setVertexMain(` +int vertexIndex1 = gl_VertexID / ${Ut}; +int vertexIndex2 = vertexIndex1 == 5 ? 0 : vertexIndex1 + 1; +vec3 vertexPosition1 = getBoundingBoxPlaneIntersectionVertexPosition(uChunkDataSize, uTranslation, uLowerClipBound, uUpperClipBound, vertexIndex1); +vec3 vertexPosition2 = getBoundingBoxPlaneIntersectionVertexPosition(uChunkDataSize, uTranslation, uLowerClipBound, uUpperClipBound, vertexIndex2); +emitLine(uProjectionMatrix * vec4(vertexPosition1, 1.0), + uProjectionMatrix * vec4(vertexPosition2, 1.0), + 2.0); +`),i.setFragmentMain(` +emit(vec4(1.0, 1.0, 1.0, getLineAlpha())); +`);return}i.addVarying("highp vec3","vChunkPosition"),i.setVertexMain(` +vec3 position = getBoundingBoxPlaneIntersectionVertexPosition(uChunkDataSize, uTranslation, uLowerClipBound, uUpperClipBound, gl_VertexID); +gl_Position = uProjectionMatrix * vec4(position, 1.0); +gl_Position.z = 0.0; +vChunkPosition = (position - uTranslation) + + ${Pv} * abs(uPlaneNormal); +`)}function YI(i,e,t,n,s,r,o){const a=C.eR.create(),l=C.eR.create(),c=C.eR.fromValues(Math.abs(s[0]),Math.abs(s[1]),Math.abs(s[2])),d=C.eR.create();for(let u=0;u<6;++u){const h=kv(i,e,t,n,s,r,u);if(h===void 0){console.log("no intersection found");return}C.eR.transformMat4(a,h,o);const p=u!==0&&C.eR.equals(a,d);C.eR.copy(d,a),C.eR.sub(l,h,r),C.eR.scaleAndAdd(l,l,c,Pv),console.log(`${p?"SKIPPED":"OUTPUT"} vertex ${u}, at ${a}, vChunkPosition = ${l}, uTranslation=${r.join()}, position=${h.join()}`)}}function QI(i,e,t){t&&vn(i,e,1)}function KI(i,e,t,n,s,r){const o=t.projectionParameters.value,{centerDataPosition:a}=o;zd(e,o.viewportNormalInGlobalCoordinates,a,r.transform,r.invTransform),i.uniformMatrix4fv(e.uniform("uProjectionMatrix"),!1,C.pB.multiply(Av,n,r.transform)),i.uniform3fv(e.uniform("uLowerClipBound"),s.lowerClipDisplayBound),i.uniform3fv(e.uniform("uUpperClipBound"),s.upperClipDisplayBound),Wd&&(window.debug_sliceView_uLowerClipBound=s.lowerClipDisplayBound,window.debug_sliceView_uUpperClipBound=s.upperClipDisplayBound,window.debug_sliceView=t,window.debug_sliceView_dataToDevice=C.pB.clone(Av),window.debug_sliceView_chunkLayout=r)}function qI(i,e,t){i.uniform3fv(e.uniform("uChunkDataSize"),t),Wd&&(window.debug_sliceView_chunkDataSize=t)}function XI(i,e,t,n){if(i.uniform3fv(e.uniform("uTranslation"),t),n?mn(e.gl,6,1):i.drawArrays(i.TRIANGLE_FAN,0,6),Wd){const r=window.debug_sliceView.projectionParameters.value,o=window.debug_sliceView_chunkDataSize,a=window.debug_sliceView_uLowerClipBound,l=window.debug_sliceView_uUpperClipBound,c=window.debug_sliceView_dataToDevice,d=window.debug_sliceView_chunkLayout;console.log(`Drawing chunk: ${t.join()} of data size ${o.join()}, projection`,c);const u=d.globalToLocalNormal(C.eR.create(),r.viewportNormalInGlobalCoordinates),h=C.eR.dot(C.eR.transformMat4(C.eR.create(),r.centerDataPosition,d.invTransform),u);YI(o,a,l,h,u,t,c)}}function ZI(i,e,t){return i>e?t>i?i:e>t?e:t:t>e?e:i>t?i:t}class Mv extends Fc{constructor(e,t){const{shaderError:n=dr(),shaderParameters:s}=t;super(e.chunkManager,e,t);const{gl:r}=this;this.vertexIdHelper=this.registerDisposer(Qn.get(r)),this.shaderParameters=s;const{channelCoordinateSpace:o}=t;this.channelCoordinateSpace=o===void 0?(0,_.XZ)(Fn):o,this.registerDisposer(s.changed.add(this.redrawNeeded.dispatch));const a=this.registerDisposer((0,_.Uq)((l,c)=>({numChannelDimensions:l.rank,dataHistogramChannelSpecifications:c}),[this.channelCoordinateSpace,this.dataHistogramSpecifications.channels]));this.shaderGetter=wo(this,r,{memoizeKey:`volume/RenderLayer:${xt(this.constructor)}`,fallbackParameters:t.fallbackShaderParameters,parameters:s,encodeParameters:t.encodeShaderParameters,shaderError:n,extraParameters:a,defineShader:(l,c,d,u)=>{const{chunkFormat:h,dataHistogramsEnabled:p}=c,{dataHistogramChannelSpecifications:m,numChannelDimensions:g}=u;if(jI(l,h===null),l.addOutputBuffer("vec4","v4f_fragData0",0),l.addFragmentCode(` +void emit(vec4 color) { + v4f_fragData0 = color; +} +`),h===null)return;Ev(l,h,g,"vChunkPosition");const v=m.length;if(p&&v>0){let y="";const{dataType:S}=h;for(let w=0;w 1.0) x = 1.0; +else x = (1.0 + x * 253.0) / 255.0; +${x} = vec4(x, x, x, 1.0); +}`}l.addFragmentCode(`void userMain(); +void main() { + ${y} + userMain(); +} +#define main userMain +`)}this.defineShader(l,d)},getContextKey:l=>`${l.chunkFormat?.shaderKey}/${l.dataHistogramsEnabled}`}),this.tempChunkPosition=new Float32Array(e.rank),this.initializeCounterpart()}get dataType(){return this.multiscaleSource.dataType}getValueAt(e){const{tempChunkPosition:t}=this;for(const{source:n,chunkTransform:s}of this.visibleSourcesList){if(!gs(t,e,this.localPosition.value,s.layerRank,s.combinedGlobalLocalToChunkTransform))continue;const r=n.getValueAt(t,s);if(r!=null)return r}return null}beginChunkFormat(e,t,n){const{gl:s}=this,r=this.dataHistogramSpecifications.visibility.visible,o=this.shaderGetter({chunkFormat:t,dataHistogramsEnabled:r}),{shader:a,parameters:l,fallback:c}=o;if(a!==null&&(a.bind(),QI(a,n,t===null),t!==null)){if(r){const{dataHistogramChannelSpecifications:d}=o.extraParameters,u=d.length,h=this.dataHistogramSpecifications.bounds.value;for(let p=0;p{u!==null&&(u.unbindTransferFunctionTextures(),h!==null&&h.endDrawing(a,u),this.endSlice(t,u,d.parameters))};let g=!0;for(const v of s){const y=Mc(r,v.chunkLayout),{chunkTransform:{channelToChunkDimensionIndices:S}}=v,w=v.source,{fixedPositionWithinChunk:b,chunkDisplayDimensionIndices:x}=v;for(const V of x)b[V]=0;const E=o?null:w.chunkFormat;if(E!==h&&(h=E,m(),d=this.beginChunkFormat(t,E,r),u=d.shader),u===null)continue;const D=w.chunks;p.fill(1);const I=y.size;let L;const N=w.spec.rank;KI(a,u,t,r.viewProjectionMat,v,y),E!==null&&E.beginSource(a,u),g=!0;let k=0,O=0;if(t.forEachVisibleChunk(v,y,V=>{const z=D.get(V);if(z&&z.state===Ue.GPU_MEMORY){const Y=z.chunkDataSize;if(Y!==L){L=Y;for(let X=0;X<3;++X){const ce=x[X];p[X]=ce===-1||ce>=N?1:L[ce]}qI(a,u,p)}const{chunkGridPosition:Q}=z;for(let X=0;X<3;++X){const ce=x[X];l[X]=ce===-1||ce>=N?0:I[X]*Q[ce]}E!==null&&E.bindChunk(a,u,z,b,x,S,g),g=!1,XI(a,u,l,o),++k}else++O}),(k!==0||O!==0)&&c!==void 0){const{effectiveVoxelSize:V}=v,z=ZI(V[0],V[1],V[2]);c.add(z,z/r.pixelSize,k,O)}}if(m(),this.vertexIdHelper.disable(),!e.wireFrame){const v=this.getDataHistogramCount();v>0&&t.computeHistograms(v,this.dataHistogramSpecifications)}}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class Nv{constructor(e){this.disjointSets=e,this.generation=Number.NaN,this.hashMap=new yd}update(){const{disjointSets:e}=this,{generation:t}=e;if(this.generation!==t){this.generation=t;const{hashMap:n}=this;n.clear();for(const[s,r]of e.mappings())n.set(s,r)}}}const Ov=1,_v=2;class Vv extends Mv{constructor(e,t){super(e,{shaderParameters:new _.wP(n=>({hasEquivalences:n.registerDisposer((0,_.Uq)(s=>s.size!==0,[t.segmentationGroupState.value.segmentEquivalences])),hasSegmentStatedColors:n.registerDisposer((0,_.Uq)((s,r,o)=>(o?r:s).size!==0,[t.segmentStatedColors,t.tempSegmentStatedColors2d,t.useTempSegmentStatedColors2d])),hasSegmentDefaultColor:n.registerDisposer((0,_.Uq)((s,r)=>s!==void 0||r!==void 0,[t.segmentDefaultColor,t.tempSegmentDefaultColor2d])),hasHighlightColor:n.registerDisposer((0,_.Uq)(s=>s!==void 0,[t.highlightColor])),hideSegmentZero:t.hideSegmentZero,baseSegmentColoring:t.baseSegmentColoring,baseSegmentHighlighting:t.baseSegmentHighlighting})),transform:t.transform,renderScaleHistogram:t.renderScaleHistogram,renderScaleTarget:t.renderScaleTarget,localPosition:t.localPosition}),this.displayState=t,this.segmentationGroupState=this.displayState.segmentationGroupState.value,this.segmentColorShaderManager=new ED("segmentColorHash"),this.segmentStatedColorShaderManager=new TD("segmentStatedColor"),this.hashTableManager=new wm("visibleSegments"),this.gpuHashTable=this.registerDisposer(Hi.get(this.gl,this.segmentationGroupState.visibleSegments.hashTable)),this.gpuTemporaryHashTable=Hi.get(this.gl,this.segmentationGroupState.temporaryVisibleSegments.hashTable),this.equivalencesShaderManager=new xm("equivalences"),this.equivalencesHashMap=new Nv(this.segmentationGroupState.segmentEquivalences.disjointSets),this.temporaryEquivalencesHashMap=new Nv(this.segmentationGroupState.temporarySegmentEquivalences.disjointSets),this.gpuEquivalencesHashTable=this.registerDisposer(Hi.get(this.gl,this.equivalencesHashMap.hashMap)),this.gpuTemporaryEquivalencesHashTable=this.registerDisposer(Hi.get(this.gl,this.temporaryEquivalencesHashMap.hashMap)),this.registerDisposer(this.shaderParameters),Hm(t,this),this.registerDisposer(t.selectedAlpha.changed.add(this.redrawNeeded.dispatch)),this.registerDisposer(t.notSelectedAlpha.changed.add(this.redrawNeeded.dispatch)),this.registerDisposer(t.ignoreNullVisibleSet.changed.add(this.redrawNeeded.dispatch))}disposed(){this.gpuSegmentStatedColorHashTable?.dispose()}getSources(e){return this.multiscaleSource.getSources({...e,discreteValues:!0})}defineShader(e,t){this.hashTableManager.defineShader(e);let n=` +uint64_t getUint64DataValue() { + uint64_t x = toUint64(getDataValue()); +`;n+=`return x; +} +`,e.addFragmentCode(n),t.hasEquivalences?(this.equivalencesShaderManager.defineShader(e),e.addFragmentCode(` +uint64_t getMappedObjectId(uint64_t value) { + uint64_t mappedValue; + if (${this.equivalencesShaderManager.getFunctionName}(value, mappedValue)) { + return mappedValue; + } + return value; +} +`)):e.addFragmentCode(` +uint64_t getMappedObjectId(uint64_t value) { + return value; +} +`),e.addUniform("highp uvec2","uSelectedSegment"),e.addUniform("highp uint","uFlags"),e.addUniform("highp float","uSelectedAlpha"),e.addUniform("highp float","uNotSelectedAlpha"),e.addUniform("highp float","uSaturation");let s=` + uint64_t baseValue = getUint64DataValue(); + uint64_t value = getMappedObjectId(baseValue); + uint64_t valueForColor = ${t.baseSegmentColoring?"baseValue":"value"}; + uint64_t valueForHighlight = ${t.baseSegmentHighlighting?"baseValue":"value"}; + + float alpha = uSelectedAlpha; + float saturation = uSaturation; +`;t.hideSegmentZero&&(s+=` + if (value.value[0] == 0u && value.value[1] == 0u) { + emit(vec4(vec4(0, 0, 0, 0))); + return; + } +`),s+=` + bool has = (uFlags & ${_v}u) != 0u ? true : ${this.hashTableManager.hasFunctionName}(value); + if ((uFlags & ${Ov}u) != 0u && uSelectedSegment == valueForHighlight.value) { + float adjustment = has ? 0.5 : 0.75; + if (saturation > adjustment) { + saturation -= adjustment; + } else { + saturation += adjustment; + } +`,t.hasHighlightColor&&(e.addUniform("highp vec4","uHighlightColor"),s+=` + emit(uHighlightColor); + return; +`),s+=` + } else if (!has) { + alpha = uNotSelectedAlpha; + } +`;let r=`vec4 getMappedIdColor(uint64_t value) { +`;t.hasSegmentStatedColors&&(this.segmentStatedColorShaderManager.defineShader(e),r+=` + vec4 rgba; + if (${this.segmentStatedColorShaderManager.getFunctionName}(value, rgba)) { + return rgba; + } +`),t.hasSegmentDefaultColor?(e.addUniform("highp vec4","uSegmentDefaultColor"),r+=` return uSegmentDefaultColor; +`):(this.segmentColorShaderManager.defineShader(e),r+=` return vec4(segmentColorHash(value), 0.0); +`),r+=` +} +`,e.addFragmentCode(r),s+=` + vec4 rgba = getMappedIdColor(valueForColor); + if (rgba.a > 0.0) { + alpha = rgba.a; + } + emit(vec4(mix(vec3(1.0,1.0,1.0), vec3(rgba), saturation), alpha)); +`,e.setFragmentMain(s)}initializeShader(e,t,n){const{gl:s}=this,{displayState:r,segmentationGroupState:o}=this,{segmentSelectionState:a}=this.displayState,{segmentDefaultColor:{value:l},segmentColorHash:{value:c},highlightColor:{value:d},tempSegmentDefaultColor2d:{value:u}}=this.displayState,h=dg(o),p=this.displayState.ignoreNullVisibleSet.value;let m=0,g=0,v=0;if(a.hasSelectedSegment&&r.hoverHighlight.value){const S=r.baseSegmentHighlighting.value?a.baseSelectedSegment:a.selectedSegment;m=S.low,g=S.high,v|=Ov}if(s.uniform1f(t.uniform("uSelectedAlpha"),r.selectedAlpha.value),s.uniform1f(t.uniform("uSaturation"),r.saturation.value),s.uniform1f(t.uniform("uNotSelectedAlpha"),r.notSelectedAlpha.value),s.uniform2ui(t.uniform("uSelectedSegment"),m,g),h.hashTable.size===0&&p&&(v|=_v),s.uniform1ui(t.uniform("uFlags"),v),this.hashTableManager.enable(s,t,o.useTemporaryVisibleSegments.value?this.gpuTemporaryHashTable:this.gpuHashTable),n.hasEquivalences){const S=o.useTemporarySegmentEquivalences.value;(S?this.temporaryEquivalencesHashMap:this.equivalencesHashMap).update(),this.equivalencesShaderManager.enable(s,t,S?this.gpuTemporaryEquivalencesHashTable:this.gpuEquivalencesHashTable)}const y=u||l;if(y){const[S,w,b,x]=y;s.uniform4f(t.uniform("uSegmentDefaultColor"),S,w,b,x===void 0?0:x)}else this.segmentColorShaderManager.enable(s,t,c);if(n.hasSegmentStatedColors){const S=r.useTempSegmentStatedColors2d.value?r.tempSegmentStatedColors2d.value:r.segmentStatedColors.value;let{gpuSegmentStatedColorHashTable:w}=this;(w===void 0||w.hashTable!==S.hashTable)&&(w?.dispose(),this.gpuSegmentStatedColorHashTable=w=Hi.get(s,S.hashTable)),this.segmentStatedColorShaderManager.enable(s,t,w)}d!==void 0&&s.uniform4fv(t.uniform("uHighlightColor"),d)}endSlice(e,t,n){const{gl:s}=this;this.hashTableManager.disable(s,t),n.hasEquivalences&&this.equivalencesShaderManager.disable(s,t),n.hasSegmentStatedColors&&this.segmentStatedColorShaderManager.disable(s,t),super.endSlice(e,t,n)}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function zr(i=.5){return new _.DN(i,f.xU)}/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const Hd=12,Bv=8,eL=6,tL=` +vec3 getBoxFaceVertexPosition(int vertexIndex) { + const vec3 vertexPositions[] = vec3[]( + // Front face + vec3(0.0, 0.0, 1.0), // 0 + vec3(1.0, 0.0, 1.0), // 1 + vec3(1.0, 1.0, 1.0), // 2 + vec3(0.0, 1.0, 1.0), // 3 + + // Back face + vec3(0.0, 0.0, 0.0), // 4 + vec3(0.0, 1.0, 0.0), // 5 + vec3(1.0, 1.0, 0.0), // 6 + vec3(1.0, 0.0, 0.0), // 7 + + // Top face + vec3(0.0, 1.0, 0.0), // 8 + vec3(0.0, 1.0, 1.0), // 9 + vec3(1.0, 1.0, 1.0), // 10 + vec3(1.0, 1.0, 0.0), // 11 + + // Bottom face + vec3(0.0, 0.0, 0.0), // 12 + vec3( 1.0, 0.0, 0.0), // 13 + vec3( 1.0, 0.0, 1.0), // 14 + vec3(0.0, 0.0, 1.0), // 15 + + // Right face + vec3( 1.0, 0.0, 0.0), // 16 + vec3( 1.0, 1.0, 0.0), // 17 + vec3( 1.0, 1.0, 1.0), // 18 + vec3( 1.0, 0.0, 1.0), // 19 + + // Left face + vec3(0.0, 0.0, 0.0), // 20 + vec3(0.0, 0.0, 1.0), // 21 + vec3(0.0, 1.0, 1.0), // 22 + vec3(0.0, 1.0, 0.0) // 23 + ); + const int indices[] = int[]( + 0, 1, 2, 0, 2, 3, // front + 4, 5, 6, 4, 6, 7, // back + 8, 9, 10, 8, 10, 11, // top + 12, 13, 14, 12, 14, 15, // bottom + 16, 17, 18, 16, 18, 19, // right + 20, 21, 22, 20, 22, 23 // left + ); + return vertexPositions[indices[vertexIndex]]; +} +`;function Fv(i,e,t){i.drawArraysInstanced(WebGL2RenderingContext.TRIANGLES,0,6*eL*e,t)}/** + * @license + * Copyright 2018 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const Uv=0,Ba=Uv+1,Pt=Ba+Bv,Jd=Pt+Hd,nL=Jd+6,iL=Float32Array.from([0,0,0,0,0,1,Pt+0,1,0,0,1,0,1,Pt+1,0,1,0,0,1,1,Pt+2,1,1,0,1,1,1,Pt+3,0,0,0,0,1,0,Pt+4,0,0,1,0,1,1,Pt+5,1,0,0,1,1,0,Pt+6,1,0,1,1,1,1,Pt+7,0,0,0,1,0,0,Pt+8,0,0,1,1,0,1,Pt+9,0,1,0,1,1,0,Pt+10,0,1,1,1,1,1,Pt+11]),$v=C.pB.create(),Ei=new Float32Array(6);class Gv extends qo{constructor(){super(...arguments),this.vertexIdHelper=this.registerDisposer(Qn.get(this.gl))}defineShader(e){xi(e);const{rank:t}=this;Do(e,"float",WebGL2RenderingContext.FLOAT,!1,"Bounds",t,2),e.addUniform("vec3","uModelSpaceBoundOffsets",2)}enable(e,t,n){C.pB.invert($v,t.modelViewProjectionMatrix),(0,C.bS)($v,Ei);const{numChunkDisplayDims:s}=t.chunkDisplayTransform;for(let r=0;r{const o=r.vertexShaderInputBinders.Bounds;o.enable(1);const{gl:a}=this;a.uniform3fv(r.uniform("uModelSpaceBoundOffsets"),Ei),a.bindBuffer(WebGL2RenderingContext.ARRAY_BUFFER,t.buffer.buffer),o.bind(this.geometryDataStride,t.bufferOffset);const{vertexIdHelper:l}=this;l.enable(),n(r),l.disable(),o.disable()})}}function zv(i){i.addVertexCode(` +void setBoundingBoxBorderWidth(float width) {} +void setBoundingBoxBorderColor(vec4 color) {} +`)}function Wv(i){i.addVertexCode(` +void setBoundingBoxFillColor(vec4 color) {} +`)}function jd(i){Wv(i),i.addVertexCode(` +float ng_lineWidth; +void setBoundingBoxBorderWidth(float size) { + ng_lineWidth = size; +} +void setBoundingBoxBorderColor(vec4 color) { + vColor = color; +} +`)}function sL(i){zv(i),i.addVertexCode(` +void setBoundingBoxFillColor(vec4 color) { + vColor = color; +} +`)}class rL extends Gv{constructor(){super(...arguments),this.edgeBoxCornerOffsetsBuffer=this.registerDisposer(At.fromData(this.gl,(0,F.CS)(iL,7,1,Ut))),this.edgeShaderGetter=this.getDependentShader("annotation/boundingBox/projection/border",e=>{const{rank:t}=this;this.defineShader(e),In(e),e.addAttribute("highp vec3","aBoxCornerOffset1"),e.addAttribute("highp vec4","aBoxCornerOffset2"),e.addVarying("highp float","vClipCoefficient"),jd(e),e.setVertexMain(` +float modelPositionA[${t}] = getBounds0(); +float modelPositionB[${t}] = getBounds1(); +vec3 subspacePositionA = projectModelVectorToSubspace(modelPositionA) + uModelSpaceBoundOffsets[0]; +vec3 subspacePositionB = projectModelVectorToSubspace(modelPositionB) + uModelSpaceBoundOffsets[1]; +vec3 endpointA = mix(subspacePositionA, subspacePositionB, aBoxCornerOffset1); +vec3 endpointB = mix(subspacePositionA, subspacePositionB, aBoxCornerOffset2.xyz); +vClipCoefficient = getMaxSubspaceClipCoefficient(modelPositionA, modelPositionB); +if (vClipCoefficient == 0.0) { + gl_Position = vec4(2.0, 0.0, 0.0, 1.0); + return; +} +ng_lineWidth = 1.0; +${this.invokeUserMain} +emitLine(uModelViewProjection * vec4(endpointA, 1.0), + uModelViewProjection * vec4(endpointB, 1.0), + ng_lineWidth); +${this.setPartIndex(e,"uint(aBoxCornerOffset2.w)")}; +`),e.setFragmentMain(` +emitAnnotation(vec4(vColor.rgb, getLineAlpha() * vClipCoefficient)); +`)}),this.boxCornerOffsetsBuffer=this.registerDisposer(At.fromData(this.gl,(0,F.CS)(Gd,3,1,mv))),this.cornerShaderGetter=this.getDependentShader("annotation/boundingBox/projection/corner",e=>{const{rank:t}=this;this.defineShader(e),Aa(e,this.targetIsSliceView),e.addAttribute("highp vec3","aBoxCornerOffset"),e.addVarying("highp float","vClipCoefficient"),jd(e),e.setVertexMain(` +float modelPositionA[${t}] = getBounds0(); +float modelPositionB[${t}] = getBounds1(); +vClipCoefficient = getMaxEndpointSubspaceClipCoefficient(modelPositionA, modelPositionB); +if (vClipCoefficient == 0.0) { + gl_Position = vec4(2.0, 0.0, 0.0, 1.0); + return; +} +vec3 subspacePositionA = projectModelVectorToSubspace(modelPositionA) + uModelSpaceBoundOffsets[0]; +vec3 subspacePositionB = projectModelVectorToSubspace(modelPositionB) + uModelSpaceBoundOffsets[1]; +vec3 vertexPosition = mix(subspacePositionA, subspacePositionB, aBoxCornerOffset); +emitCircle(uModelViewProjection * vec4(vertexPosition, 1.0), ng_lineWidth, 0.0); +uint cornerIndex = uint(aBoxCornerOffset.x + aBoxCornerOffset.y * 2.0 + aBoxCornerOffset.z * 4.0); +uint cornerPickOffset = ${Ba}u + cornerIndex; +${this.setPartIndex(e,"cornerPickOffset")}; +`),e.setFragmentMain(` +vec4 borderColor = vec4(0.0, 0.0, 0.0, 1.0); +vec4 color = getCircleColor(vColor, borderColor); +color.a *= vClipCoefficient; +emitAnnotation(color); +`)})}drawEdges(e){const{gl:t}=this;this.enable(this.edgeShaderGetter,e,n=>{const s=n.attribute("aBoxCornerOffset1"),r=n.attribute("aBoxCornerOffset2");this.edgeBoxCornerOffsetsBuffer.bindToVertexAttrib(s,3,WebGL2RenderingContext.FLOAT,!1,28,0),this.edgeBoxCornerOffsetsBuffer.bindToVertexAttrib(r,4,WebGL2RenderingContext.FLOAT,!1,28,12),vn(n,e.renderContext.projectionParameters,1),mn(t,Hd,e.count),t.disableVertexAttribArray(s),t.disableVertexAttribArray(r)})}drawCorners(e){const{gl:t}=this;this.enable(this.cornerShaderGetter,e,n=>{const s=n.attribute("aBoxCornerOffset");this.boxCornerOffsetsBuffer.bindToVertexAttrib(s,3,WebGL2RenderingContext.FLOAT,!1),Ma(n,e.renderContext.projectionParameters,{featherWidthInPixels:0}),Na(n.gl,Bv,e.count),t.disableVertexAttribArray(s)})}draw(e){this.drawEdges(e),this.drawCorners(e)}}class oL extends Gv{constructor(){super(...arguments),this.faceShaderGetter=this.getDependentShader("annotation/boundingBox/crossSection/face",e=>{const{rank:t}=this;super.defineShader(e),Va(e),In(e),e.addVarying("highp float","vClipCoefficient"),jd(e),e.setVertexMain(` +float modelPositionA[${t}] = getBounds0(); +float modelPositionB[${t}] = getBounds1(); +for (int i = 0; i < ${t}; ++i) { + float a = modelPositionA[i]; + float b = modelPositionB[i]; + modelPositionA[i] = min(a, b); + modelPositionB[i] = max(a, b); +} +vClipCoefficient = getMaxSubspaceClipCoefficient(modelPositionA, modelPositionB); +if (vClipCoefficient == 0.0) { + gl_Position = vec4(2.0, 0.0, 0.0, 1.0); + return; +} +vec3 subspacePositionA = projectModelVectorToSubspace(modelPositionA) + uModelSpaceBoundOffsets[0]; +vec3 subspacePositionB = projectModelVectorToSubspace(modelPositionB) + uModelSpaceBoundOffsets[1]; +int vertexIndex1 = gl_VertexID / ${Ut}; +int vertexIndex2 = vertexIndex1 == 5 ? 0 : vertexIndex1 + 1; +vec3 vertexPosition1 = getBoundingBoxPlaneIntersectionVertexPosition(subspacePositionB - subspacePositionA, subspacePositionA, subspacePositionA, subspacePositionB, vertexIndex1); +vec3 vertexPosition2 = getBoundingBoxPlaneIntersectionVertexPosition(subspacePositionB - subspacePositionA, subspacePositionA, subspacePositionA, subspacePositionB, vertexIndex2); +ng_lineWidth = 1.0; +${this.invokeUserMain} +emitLine(uModelViewProjection * vec4(vertexPosition1, 1.0), + uModelViewProjection * vec4(vertexPosition2, 1.0), + ng_lineWidth); +${this.setPartIndex(e)}; +`),e.setFragmentMain(` +emitAnnotation(vec4(vColor.rgb, vColor.a * getLineAlpha() * vClipCoefficient)); +`)}),this.fillShaderGetter=this.getDependentShader("annotation/boundingBox/crossSection/fill",e=>{const{rank:t}=this;super.defineShader(e),Va(e),e.addVarying("highp float","vClipCoefficient"),sL(e),e.setVertexMain(` +float modelPositionA[${t}] = getBounds0(); +float modelPositionB[${t}] = getBounds1(); +for (int i = 0; i < ${t}; ++i) { + float a = modelPositionA[i]; + float b = modelPositionB[i]; + modelPositionA[i] = min(a, b); + modelPositionB[i] = max(a, b); +} +vClipCoefficient = getMaxSubspaceClipCoefficient(modelPositionA, modelPositionB); +if (vClipCoefficient == 0.0) { + gl_Position = vec4(2.0, 0.0, 0.0, 1.0); + return; +} +vec3 subspacePositionA = projectModelVectorToSubspace(modelPositionA) + uModelSpaceBoundOffsets[0]; +vec3 subspacePositionB = projectModelVectorToSubspace(modelPositionB) + uModelSpaceBoundOffsets[1]; +int vertexIndex = gl_VertexID; +vec3 vertexPosition = getBoundingBoxPlaneIntersectionVertexPosition(subspacePositionB - subspacePositionA, subspacePositionA, subspacePositionA, subspacePositionB, vertexIndex); +gl_Position = uModelViewProjection * vec4(vertexPosition, 1); +${this.invokeUserMain} +${this.setPartIndex(e)}; +`),e.setFragmentMain(` +emitAnnotation(vec4(vColor.rgb, vColor.a * vClipCoefficient)); +`)})}enableForBoundingBox(e,t,n){super.enable(e,t,s=>{const r=t.renderContext.sliceView.projectionParameters.value;zd(s,r.viewportNormalInGlobalCoordinates,r.centerDataPosition,t.renderSubspaceModelMatrix,t.renderSubspaceInvModelMatrix),n(s)})}draw(e){this.shaderControlState.parseResult.value.code.match(/\bsetBoundingBoxFillColor\b/)&&this.enableForBoundingBox(this.fillShaderGetter,e,()=>{pw(this.gl,WebGL2RenderingContext.TRIANGLE_FAN,0,6,e.count)}),this.enableForBoundingBox(this.faceShaderGetter,e,t=>{vn(t,e.renderContext.projectionParameters,1),mn(t.gl,6,e.count)})}}function aL(i,e){const t=i.length;for(let n=0;n=Ba&&n=Pt&&n=Ba&&t=Pt&&t{const{rank:t}=this;this.defineShader(e),In(e),e.addVarying(`highp float[${t}]`,"vModelPosition"),e.addVertexCode(` +float ng_LineWidth; +`),Hv(e),e.addVertexCode(` +void setLineWidth(float width) { + ng_LineWidth = width; +} +void setLineColor(vec4 startColor, vec4 endColor) { + vColor = mix(startColor, endColor, getLineEndpointCoefficient()); +} +`),e.setVertexMain(` +float modelPositionA[${t}] = getVertexPosition0(); +float modelPositionB[${t}] = getVertexPosition1(); +for (int i = 0; i < ${t}; ++i) { + vModelPosition[i] = mix(modelPositionA[i], modelPositionB[i], getLineEndpointCoefficient()); +} +ng_LineWidth = 1.0; +vColor = vec4(0.0, 0.0, 0.0, 0.0); +${this.invokeUserMain} +emitLine(uModelViewProjection * vec4(projectModelVectorToSubspace(modelPositionA), 1.0), + uModelViewProjection * vec4(projectModelVectorToSubspace(modelPositionB), 1.0), + ng_LineWidth); +${this.setPartIndex(e)}; +`),e.setFragmentMain(` +float clipCoefficient = getSubspaceClipCoefficient(vModelPosition); +emitAnnotation(vec4(vColor.rgb, vColor.a * getLineAlpha() * + ${this.getCrossSectionFadeFactor()} * + clipCoefficient)); +`)}),this.endpointShaderGetter=this.getDependentShader("annotation/line/endpoint",e=>{const{rank:t}=this;this.defineShader(e),Aa(e,this.targetIsSliceView),e.addVarying("highp float","vClipCoefficient"),e.addVarying("highp vec4","vBorderColor"),Jv(e),e.addVertexCode(` +float ng_markerDiameter; +float ng_markerBorderWidth; +int getEndpointIndex() { + return gl_VertexID / ${mv}; +} +void setEndpointMarkerSize(float startSize, float endSize) { + ng_markerDiameter = mix(startSize, endSize, float(getEndpointIndex())); +} +void setEndpointMarkerBorderWidth(float startSize, float endSize) { + ng_markerBorderWidth = mix(startSize, endSize, float(getEndpointIndex())); +} +void setEndpointMarkerColor(vec4 startColor, vec4 endColor) { + vColor = mix(startColor, endColor, float(getEndpointIndex())); +} +void setEndpointMarkerBorderColor(vec4 startColor, vec4 endColor) { + vBorderColor = mix(startColor, endColor, float(getEndpointIndex())); +} +`),e.setVertexMain(` +float modelPosition[${t}] = getVertexPosition0(); +float modelPositionB[${t}] = getVertexPosition1(); +for (int i = 0; i < ${t}; ++i) { + modelPosition[i] = mix(modelPosition[i], modelPositionB[i], float(getEndpointIndex())); +} +vClipCoefficient = getSubspaceClipCoefficient(modelPosition); +vColor = vec4(0.0, 0.0, 0.0, 0.0); +vBorderColor = vec4(0.0, 0.0, 0.0, 1.0); +ng_markerDiameter = 5.0; +ng_markerBorderWidth = 1.0; +${this.invokeUserMain} +emitCircle(uModelViewProjection * vec4(projectModelVectorToSubspace(modelPosition), 1.0), ng_markerDiameter, ng_markerBorderWidth); +${this.setPartIndex(e,"uint(getEndpointIndex()) + 1u")}; +`),e.setFragmentMain(` +vec4 color = getCircleColor(vColor, vBorderColor); +color.a *= vClipCoefficient; +emitAnnotation(color); +`)})}defineShader(e){xi(e);const{rank:t}=this;Do(e,"float",WebGL2RenderingContext.FLOAT,!1,"VertexPosition",t,2)}enable(e,t,n){super.enable(e,t,s=>{const r=s.vertexShaderInputBinders.VertexPosition;r.enable(1),this.gl.bindBuffer(WebGL2RenderingContext.ARRAY_BUFFER,t.buffer.buffer),r.bind(this.geometryDataStride,t.bufferOffset);const{vertexIdHelper:o}=this;o.enable(),n(s),o.disable(),r.disable()})}drawEdges(e){this.enable(this.edgeShaderGetter,e,t=>{vn(t,e.renderContext.projectionParameters,1),mn(t.gl,1,e.count)})}drawEndpoints(e){this.enable(this.endpointShaderGetter,e,t=>{Ma(t,e.renderContext.projectionParameters,{featherWidthInPixels:.5}),Na(t.gl,2,e.count)})}draw(e){this.drawEdges(e),this.drawEndpoints(e)}}function cL(i,e){const t=i.length;(0,C._q)(i,e.subarray(0,t),e.subarray(t),i)}function dL(i,e,t){const n=i.length,s=n*t;for(let r=0;r{xi(e),Aa(e,this.targetIsSliceView),this.defineShaderCommon(e),e.addVertexMain(` +emitCircle(uModelViewProjection * + vec4(projectModelVectorToSubspace(modelPosition), 1.0), ng_markerDiameter, ng_markerBorderWidth); +`),e.setFragmentMain(` +vec4 color = getCircleColor(vColor, vBorderColor); +emitAnnotation(color); +`)}),this.makeShaderGetter2d=e=>this.getDependentShader(`annotation/point:2d:${e}`,t=>{xi(t),In(t,!0),this.defineShaderCommon(t),t.addVertexMain(` +vec3 subspacePositionA = projectModelVectorToSubspace(modelPosition); +vec3 subspacePositionB = subspacePositionA; +vec4 baseProjection = uModelViewProjection * vec4(subspacePositionA, 1.0); +vec4 zCoeffs = uModelViewProjection[${e}]; +float minZ = 1e30; +float maxZ = -1e30; +for (int i = 0; i < 3; ++i) { + // Want: baseProjection[i] + z * zCoeffs[i] = -2.0 * (baseProjection.w - z * zCoeffs.w) + // i.e. baseProjection[i] + 2.0 * baseProjection.w < -z * (2.0 * zCoeffs.w + zCoeffs[i]) + // i.e. baseProjection[i] + 2.0 * baseProjection.w < -z * k1 + float k1 = 2.0 * zCoeffs.w + zCoeffs[i]; + float q1 = -(baseProjection[i] + 2.0 * baseProjection.w) / k1; + if (k1 != 0.0) { + minZ = min(minZ, q1); + maxZ = max(maxZ, q1); + } + // Want: baseProjection[i] + z * zCoeffs[i] = 2.0 * (baseProjection.w + z * zCoeffs.w) + // i.e. baseProjection[i] - 2.0 * baseProjection.w > z * (2.0 * zCoeffs.w - zCoeffs[i]) + // i.e. baseProjection[i] - 2.0 * baseProjection.w > z * k2 + float k2 = 2.0 * zCoeffs.w - zCoeffs[i]; + float q2 = (baseProjection[i] - 2.0 * baseProjection.w) / k2; + if (k2 != 0.0) { + minZ = min(minZ, q2); + maxZ = max(maxZ, q2); + } +} +if (minZ > maxZ) minZ = maxZ = 0.0; +subspacePositionA[${e}] = minZ; +subspacePositionB[${e}] = maxZ; +emitLine(uModelViewProjection, subspacePositionA, subspacePositionB, ng_markerDiameter, ng_markerBorderWidth); +`),t.setFragmentMain(` +vec4 color = getRoundedLineColor(vColor, vBorderColor); +emitAnnotation(vec4(color.rgb, color.a * ${this.getCrossSectionFadeFactor()})); +`)}),this.shaderGetter2d=this.makeShaderGetter2d(2),this.shaderGetter1d=this.makeShaderGetter2d(1),this.vertexIdHelper=this.registerDisposer(Qn.get(this.gl))}defineShaderCommon(e){const{rank:t}=this;Do(e,"float",WebGL2RenderingContext.FLOAT,!1,"VertexPosition",t),e.addVarying("highp vec4","vBorderColor"),e.addVertexCode(` +float ng_markerDiameter; +float ng_markerBorderWidth; +void setPointMarkerSize(float size) { + ng_markerDiameter = size; +} +void setPointMarkerBorderWidth(float size) { + ng_markerBorderWidth = size; +} +void setPointMarkerColor(vec4 color) { + vColor = color; +} +void setPointMarkerBorderColor(vec4 color) { + vBorderColor = color; +} +`),e.addVertexMain(` +ng_markerDiameter = 5.0; +ng_markerBorderWidth = 1.0; +vBorderColor = vec4(0.0, 0.0, 0.0, 1.0); +float modelPosition[${t}] = getVertexPosition0(); +float clipCoefficient = getSubspaceClipCoefficient(modelPosition); +if (clipCoefficient == 0.0) { + gl_Position = vec4(2.0, 0.0, 0.0, 1.0); + return; +} +${this.invokeUserMain} +vColor.a *= clipCoefficient; +vBorderColor.a *= clipCoefficient; +${this.setPartIndex(e)}; +`)}enable(e,t,n){super.enable(e,t,s=>{const r=s.vertexShaderInputBinders.VertexPosition;r.enable(1),this.gl.bindBuffer(WebGL2RenderingContext.ARRAY_BUFFER,t.buffer.buffer),r.bind(this.geometryDataStride,t.bufferOffset);const{vertexIdHelper:o}=this;o.enable(),n(s),o.disable(),r.disable()})}draw(e){const{numChunkDisplayDims:t}=e.chunkDisplayTransform;switch(t){case 3:this.enable(this.shaderGetter3d,e,n=>{Ma(n,e.renderContext.projectionParameters,{featherWidthInPixels:1}),Na(n.gl,1,e.count)});break;case 2:case 1:this.enable(t===2?this.shaderGetter2d:this.shaderGetter1d,e,n=>{vn(n,e.renderContext.projectionParameters,1),mn(n.gl,1,e.count)});break}}}Xo(Re.POINT,{sliceViewRenderHelper:Yv,perspectiveViewRenderHelper:Yv,defineShaderNoOpSetters(i){i.addVertexCode(` +void setPointMarkerSize(float size) {} +void setPointMarkerBorderWidth(float size) {} +void setPointMarkerColor(vec4 color) {} +void setPointMarkerBorderColor(vec4 color) {} +`)},pickIdsPerInstance:1,snapPosition(i,e,t){i.set(new Float32Array(e,t,i.length))},getRepresentativePoint(i,e){i.set(e.point)},updateViaRepresentativePoint(i,e){return{...i,point:new Float32Array(e)}}});/** + * @license + * Copyright 2018 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const Qv=` +struct EllipseQuadraticForm { + highp float A; // x*x coefficient + highp float B; // x*y coefficient + highp float C; // y*y coefficient + highp float D; // x coefficient + highp float E; // y coefficient + highp float F; // 1 coefficient +}; +`,uL=[Qv,` +EllipseQuadraticForm computeCrossSectionEllipse(mat3 A, vec3 c) { + EllipseQuadraticForm p; + p.A = A[0][0]; + p.B = A[0][1] + A[1][0]; + p.C = A[1][1]; + p.D = -2.0 * c[0] * A[0][0] - c[1] * (A[0][1] + A[1][0]) + + c[2] * (A[0][2] + A[2][0]); + p.E = -c[0] * (A[0][1] + A[1][0]) - 2.0 * c[1] * A[1][1] + + c[2] * (A[1][2] + A[2][1]); + p.F = c[0] * c[0] * A[0][0] + c[0] * c[1] * (A[0][1] + A[1][0]) - + c[0] * c[2] * (A[0][2] + A[2][0]) + c[1] * c[1] * A[1][1] - + c[1] * c[2] * (A[1][2] + A[2][1]) + c[2] * c[2] * A[2][2] - 1.0; + return p; +} +`];function hL(i,e){const t=[[i[0],i[1],i[2]],[i[3],i[4],i[5]],[i[6],i[7],i[8]]];return{A:t[0][0],B:t[0][1]+t[1][0],C:t[1][1],D:-2*e[0]*t[0][0]-e[1]*(t[0][1]+t[1][0])+e[2]*(t[0][2]+t[2][0]),E:-e[0]*(t[0][1]+t[1][0])-2*e[1]*t[1][1]+e[2]*(t[1][2]+t[2][1]),F:e[0]*e[0]*t[0][0]+e[0]*e[1]*(t[0][1]+t[1][0])-e[0]*e[2]*(t[0][2]+t[2][0])+e[1]*e[1]*t[1][1]-e[1]*e[2]*(t[1][2]+t[2][1])+e[2]*e[2]*t[2][2]-1}}const pL=[Qv,` +struct CenterOrientEllipse { + vec2 k; // center + vec2 u1; // minor axis direction + vec2 u2; // major axis direction + float a; // semimajor axis + float b; // semiminor axis + bool valid; // indicates if the ellipse is valid +}; +`,` +CenterOrientEllipse computeCenterOrientEllipse(EllipseQuadraticForm p) { + CenterOrientEllipse r; + float a11 = p.A; + float a12 = p.B / 2.0; + float a22 = p.C; + float b1 = p.D; + float b2 = p.E; + float c = p.F; + float kdenom = 2.0 * (a12 * a12 - a11 * a22); + float k1 = r.k.x = (a22 * b1 - a12 * b2) / kdenom; + float k2 = r.k.y = (a11 * b2 - a12 * b1) / kdenom; + float mu = 1.0 / (a11 * k1 * k1 + 2.0 * a12 * k1 * k2 + a22 * k2 * k2 - c); + float m11 = mu * a11; + float m12 = mu * a12; + float m22 = mu * a22; + float lambdaTerm1 = m11 + m22; + float lambdaTerm2 = sqrt((m11 - m22) * (m11 - m22) + 4.0 * m12 * m12); + float lambda1 = ((lambdaTerm1 + lambdaTerm2) / 2.0); + float lambda2 = ((lambdaTerm1 - lambdaTerm2) / 2.0); + r.a = 1.0 / sqrt(lambda1); + r.b = 1.0 / sqrt(lambda2); + r.valid = lambda1 > 0.0 && lambda2 > 0.0; + if (abs(m11 - m22) < 1e-6 && abs(m12) < 1e-6) { + r.u1 = vec2(1.0, 0.0); + } else if (m11 >= m22) { + r.u1 = normalize(vec2(lambda1 - m22, m12)); + } else { + r.u1 = normalize(vec2(m12, lambda1 - m11)); + } + r.u2 = vec2(-r.u1.y, r.u1.x); + return r; +} +`];function fL(i){const e=i.A,t=i.B/2,n=i.C,s=i.D,r=i.E,o=i.F,a=2*(t*t-e*n),l=(n*s-t*r)/a,c=(e*r-t*s)/a,d=1/(e*l*l+2*t*l*c+n*c*c-o),u=d*e,h=d*t,p=d*n,m=u+p,g=Math.sqrt((u-p)*(u-p)+4*h*h),v=(m+g)/2,y=(m-g)/2,S=1/Math.sqrt(v),w=1/Math.sqrt(y);let b;u>=p?b=C.Zc.fromValues(v-p,h):b=C.Zc.fromValues(h,v-u),C.Zc.normalize(b,b);const x=C.Zc.fromValues(-b[1],b[0]);return{k:C.Zc.fromValues(l,c),u1:b,u2:x,a:S,b:w,lambda1:v,lambda2:y,m11:u,m12:h,m22:p,valid:v>0&&y>0}}/** + * @license + * Copyright 2018 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function gL(i,e){const t=new Float32Array((i+1)*(e+1)*3);let n=0;for(let s=0;s<=i;++s){const r=s*Math.PI/i,o=Math.sin(r),a=Math.cos(r);for(let l=0;l<=e;++l){const c=l*2*Math.PI/e,d=Math.sin(c),u=Math.cos(c);t[n++]=u*o,t[n++]=a,t[n++]=d*o}}return t}function mL(i,e){const t=new Uint16Array(i*e*6);let n=0;for(let s=0;s{const r=s.vertexShaderInputBinders.CenterAndRadii;r.enable(1),this.gl.bindBuffer(WebGL2RenderingContext.ARRAY_BUFFER,t.buffer.buffer),r.bind(this.geometryDataStride,t.bufferOffset),n(s),r.disable()})}}class SL extends qv{constructor(){super(...arguments),this.sphereRenderHelper=this.registerDisposer(new vL(this.gl,10,10)),this.shaderGetter=this.getDependentShader("annotation/ellipsoid/projection",e=>{this.defineShader(e),this.sphereRenderHelper.defineShader(e),e.addUniform("highp vec4","uLightDirection"),e.addUniform("highp mat4","uNormalTransform"),e.addVarying("highp float","vClipCoefficient"),e.setVertexMain(` +SubspaceParams params = getSubspaceParams(); +if (params.cull) { + gl_Position = vec4(2.0, 0.0, 0.0, 1.0); + return; +} +vClipCoefficient = params.clipCoefficient; +${this.invokeUserMain} +emitSphere(uModelViewProjection, uNormalTransform, params.subspaceCenter, params.subspaceRadii, uLightDirection); +${this.setPartIndex(e)}; +`),e.setFragmentMain(` +emitAnnotation(vec4(vColor.rgb * vLightingFactor, vColor.a * vClipCoefficient)); +`)}),this.tempLightVec=new Float32Array(4)}draw(e){this.enable(this.shaderGetter,e,t=>{const{gl:n}=t,s=this.tempLightVec,{lightDirection:r,ambientLighting:o,directionalLighting:a}=e.renderContext;C.eR.scale(s,r,a),s[3]=o,n.uniform4fv(t.uniform("uLightDirection"),s),n.uniformMatrix4fv(t.uniform("uNormalTransform"),!1,C.pB.transpose(C.pB.create(),e.renderSubspaceInvModelMatrix)),this.sphereRenderHelper.draw(t,e.count)})}}class bL extends qv{constructor(){super(...arguments),this.shaderGetter=this.getDependentShader("annotation/ellipsoid/crossSection",e=>{xi(e),this.defineShader(e),e.addUniform("highp mat4","uViewportToObject"),e.addUniform("highp mat4","uObjectToViewport"),e.addUniform("highp mat4","uViewportToDevice"),e.addAttribute("highp vec2","aCornerOffset"),e.addVarying("highp vec2","vCircleCoord"),e.addVarying("highp float","vClipCoefficient"),e.addVertexCode(uL),e.addVertexCode(pL),e.addVertexCode(wc),e.setVertexMain(` +SubspaceParams params = getSubspaceParams(); +if (params.cull) { + gl_Position = vec4(2.0, 0.0, 0.0, 1.0); + return; +} +vClipCoefficient = params.clipCoefficient; +mat3 Aobject = mat3(0.0); +for (int i = 0; i < 3; ++i) { + float r = max(params.subspaceRadii[i], 1e-3); + Aobject[i][i] = 1.0 / (r * r); +} +mat3 RviewportToObject = mat3(uViewportToObject); +mat3 Aviewport = transpose(RviewportToObject) * Aobject * RviewportToObject; +vec3 cViewport = (uObjectToViewport * vec4(params.subspaceCenter, 1.0)).xyz; +EllipseQuadraticForm quadraticForm = computeCrossSectionEllipse(Aviewport, cViewport); +vec2 u1, u2; +float a, b; +CenterOrientEllipse centerOrient = computeCenterOrientEllipse(quadraticForm); +vec2 cornerOffset = getQuadVertexPosition(vec2(-1.0, -1.0), vec2(1.0, 1.0)); +vec2 viewportCorner = centerOrient.k + + centerOrient.u1 * cornerOffset.x * centerOrient.a + + centerOrient.u2 * cornerOffset.y * centerOrient.b; +if (centerOrient.valid) { + gl_Position = uViewportToDevice * vec4(viewportCorner, 0.0, 1.0); +} else { + gl_Position = vec4(2.0, 0.0, 0.0, 1.0); +} +vCircleCoord = cornerOffset; +${this.invokeUserMain} +${this.setPartIndex(e)}; +`),e.setFragmentMain(` +if (dot(vCircleCoord, vCircleCoord) > 1.0) { + discard; +} +emitAnnotation(vec4(vColor.rgb, vColor.a * vClipCoefficient)); +`)}),this.vertexIdHelper=this.registerDisposer(Qn.get(this.gl))}draw(e){this.enable(this.shaderGetter,e,t=>{const{gl:n}=t,s=e.renderContext.sliceView.projectionParameters.value,r=C.pB.multiply(Kv,e.renderSubspaceInvModelMatrix,s.invViewMatrix);n.uniformMatrix4fv(t.uniform("uViewportToObject"),!1,r),n.uniformMatrix4fv(t.uniform("uViewportToDevice"),!1,s.projectionMat);const o=Kv;C.pB.invert(o,r),n.uniformMatrix4fv(t.uniform("uObjectToViewport"),!1,o);const{vertexIdHelper:a}=this;if(a.enable(),Ao(n,1,e.count),a.disable(),yL){const l=C.eR.fromValues(3406.98779296875,3234.910400390625,4045),c=C.eR.fromValues(10,10,10),d=C.w0.create();d[0]=1/(c[0]*c[0]),d[4]=1/(c[1]*c[1]),d[8]=1/(c[2]*c[2]);const u=C.w0.fromMat4(C.w0.create(),r),h=C.w0.multiply(C.w0.create(),C.w0.transpose(C.w0.create(),u),d);C.w0.multiply(h,h,u);const p=C.eR.transformMat4(C.eR.create(),l,o);console.log("Aviewport",h),console.log("cViewport",p);const m=hL(h,p),g=fL(m);console.log(m),console.log(g)}})}}Xo(Re.ELLIPSOID,{sliceViewRenderHelper:bL,perspectiveViewRenderHelper:SL,defineShaderNoOpSetters(i){i.addVertexCode(` +void setEllipsoidFillColor(vec4 color) {} +`)},pickIdsPerInstance:1,snapPosition:()=>{},getRepresentativePoint(i,e){i.set(e.center)},updateViaRepresentativePoint(i,e){return{...i,center:new Float32Array(e)}}});/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const Xv=C.pB.create(),Zv=C.eR.create();function ey(i){i.addUniform("highp vec3","uTranslation"),i.addUniform("highp mat4","uProjectionMatrix"),i.addUniform("highp vec3","uChunkDataSize"),i.addUniform("highp vec3","uLowerClipBound"),i.addUniform("highp vec3","uUpperClipBound"),i.setFragmentMain(` +emit(vec4(1.0, 1.0, 1.0, getLineAlpha()), 0u); +`)}const CL={defineShader(i){ey(i),In(i),i.addVertexCode(` +const vec3[24] boxCornerOffsets = vec3[]( + vec3(0, 0, 0), vec3(0, 0, 1), // e1 + vec3(1, 0, 0), vec3(1, 0, 1), // e2 + vec3(0, 1, 0), vec3(0, 1, 1), // e3 + vec3(1, 1, 0), vec3(1, 1, 1), // e4 + vec3(0, 0, 0), vec3(0, 1, 0), // e5 + vec3(0, 0, 1), vec3(0, 1, 1), // e6 + vec3(1, 0, 0), vec3(1, 1, 0), // e7 + vec3(1, 0, 1), vec3(1, 1, 1), // e8 + vec3(0, 0, 0), vec3(1, 0, 0), // e9 + vec3(0, 0, 1), vec3(1, 0, 1), // e10 + vec3(0, 1, 0), vec3(1, 1, 0), // e11 + vec3(0, 1, 1), vec3(1, 1, 1) // e12 +); +`),i.setVertexMain(` +int edgeIndex = gl_VertexID / ${Ut}; +vec3 cornerA = max(uLowerClipBound, min(uUpperClipBound, uTranslation)); +vec3 cornerB = max(uLowerClipBound, min(uUpperClipBound, uTranslation + uChunkDataSize)); +vec3 vertexPosition1 = mix(cornerA, cornerB, boxCornerOffsets[edgeIndex * 2]); +vec3 vertexPosition2 = mix(cornerA, cornerB, boxCornerOffsets[edgeIndex * 2 + 1]); +emitLine(uProjectionMatrix * vec4(vertexPosition1, 1.0), + uProjectionMatrix * vec4(vertexPosition2, 1.0), + 2.0); +`)},initialize(i,e){vn(i,e,1)},draw(i,e,t){const{gl:n}=i,s=Xv,{chunkLayout:r}=e;C.pB.multiply(s,t.viewProjectionMat,r.transform),n.uniformMatrix4fv(i.uniform("uProjectionMatrix"),!1,s),n.uniform3fv(i.uniform("uChunkDataSize"),r.size),n.uniform3fv(i.uniform("uLowerClipBound"),e.lowerClipDisplayBound),n.uniform3fv(i.uniform("uUpperClipBound"),e.upperClipDisplayBound);const o=r.size,{curPositionInChunks:a,chunkDisplayDimensionIndices:l}=e,c=Zv;for(let d=0;d<3;++d){const u=l[d];c[d]=(u===-1?0:a[u])*o[d]}n.uniform3fv(i.uniform("uTranslation"),c),mn(n,Hd,1)}},wL={defineShader(i){Va(i),ey(i),In(i),i.setVertexMain(` +int vertexIndex1 = gl_VertexID / ${Ut}; +int vertexIndex2 = vertexIndex1 == 5 ? 0 : vertexIndex1 + 1; +vec3 vertexPosition1 = getBoundingBoxPlaneIntersectionVertexPosition(uChunkDataSize, uTranslation, uLowerClipBound, uUpperClipBound, vertexIndex1); +vec3 vertexPosition2 = getBoundingBoxPlaneIntersectionVertexPosition(uChunkDataSize, uTranslation, uLowerClipBound, uUpperClipBound, vertexIndex2); +emitLine(uProjectionMatrix * vec4(vertexPosition1, 1.0), + uProjectionMatrix * vec4(vertexPosition2, 1.0), + 2.0); +`)},initialize(i,e){vn(i,e,1)},draw(i,e,t){const{gl:n}=i,s=Xv,{chunkLayout:r}=e;C.pB.multiply(s,t.viewProjectionMat,r.transform),n.uniformMatrix4fv(i.uniform("uProjectionMatrix"),!1,s),n.uniform3fv(i.uniform("uChunkDataSize"),r.size),n.uniform3fv(i.uniform("uLowerClipBound"),e.lowerClipDisplayBound),n.uniform3fv(i.uniform("uUpperClipBound"),e.upperClipDisplayBound);const o=r.size,{curPositionInChunks:a,chunkDisplayDimensionIndices:l}=e,c=Zv;for(let d=0;d<3;++d){const u=l[d];c[d]=(u===-1?0:a[u])*o[d]}n.uniform3fv(i.uniform("uTranslation"),c),zd(i,t.viewportNormalInGlobalCoordinates,t.centerDataPosition,r.transform,r.invTransform),mn(n,6,1)}};var xL=Object.defineProperty,EL=Object.getOwnPropertyDescriptor,TL=(i,e,t,n)=>{for(var s=n>1?void 0:n?EL(e,t):e,r=i.length-1,o;r>=0;r--)(o=i[r])&&(s=(n?o(e,t,s):o(s))||s);return n&&s&&xL(e,t,s),s};/** + * @license + * Copyright 2018 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const DL=C.pB.create();function IL(i){if(i!==void 0)return e=>{const{relatedSegments:t}=e;if(t===void 0)return!1;for(let n=0,s=t.length;n{const r={id:this.rpcId,segmentationStates:this.serializeDisplayState()};this.rpc.invoke(qE,r)};this.registerDisposer(t.changed.add(s))}serializeDisplayState(){const{value:i}=this.segmentationStates;if(i!==void 0)return i.map(e=>e==null?e:jm(e.segmentationGroupState.value))}};Qd=TL([Zt(KE)],Qd);class RL extends T.O8{constructor(e,t){super(),this.chunkManager=e,this.state=t,this.layerChunkProgressInfo=new fo,this.numPickIds=0,this.generation=-1,this.redrawNeeded=new j.IY,this.serializedAnnotations=void 0,this.handleChangeAffectingBuffer=()=>{this.generation=-1,this.redrawNeeded.dispatch()},this.segmentationStates=this.registerDisposer((0,_.Uq)((s,r)=>{const{displayState:o,source:a}=this.state,{relationshipStates:l}=o;return o.displayUnfiltered.value?void 0:a.relationships.map(c=>{const d=l.get(c);return d.showMatches.value?d.segmentationState.value:void 0})},[this.state.displayState.relationshipStates,this.state.displayState.ignoreNullSegmentFilter],(s,r)=>s===void 0||r===void 0?s===r:(0,F.r1)(s,r))),this.registerDisposer(t),this.registerDisposer(this.source.changed.add(this.handleChangeAffectingBuffer)),this.registerDisposer((0,_.no)((s,r)=>{if(this.handleChangeAffectingBuffer(),r!==void 0)for(const o of r)o!=null&&s.registerDisposer((0,_.aM)((a,l)=>{a.registerDisposer(l.visibleSegments.changed.add(()=>this.handleChangeAffectingBuffer())),a.registerDisposer(l.segmentEquivalences.changed.add(()=>this.handleChangeAffectingBuffer()))},o.segmentationGroupState))},this.segmentationStates)),this.source instanceof hs||(this.sharedObject=this.registerDisposer(new Qd(e,this.source,this.segmentationStates,this.layerChunkProgressInfo)));const{displayState:n}=this.state;this.registerDisposer(n.color.changed.add(this.redrawNeeded.dispatch)),this.registerDisposer(n.shader.changed.add(this.redrawNeeded.dispatch)),this.registerDisposer(n.shaderControls.changed.add(this.redrawNeeded.dispatch)),this.registerDisposer(this.hoverState.changed.add(this.redrawNeeded.dispatch)),this.registerDisposer(this.transform.changed.add(this.redrawNeeded.dispatch))}get source(){return this.state.source}get transform(){return this.state.transform}get hoverState(){return this.state.displayState.hoverState}get visibility(){const{sharedObject:e}=this;if(e!==void 0)return e.visibility}get gl(){return this.chunkManager.gl}updateBuffer(){const{source:e}=this;if(e instanceof hs){const t=e.changed.count;if(this.generation!==t){let{buffer:n}=this;n===void 0&&(n=this.buffer=this.registerDisposer(new At(this.chunkManager.gl))),this.generation=t;const s=this.serializedAnnotations=LL(e,IL(this.segmentationStates.value));n.setData(this.serializedAnnotations.data),this.numPickIds=hg(s)}}}}function ty(i){const{chunkTransform:e}=i,{unpaddedRank:t}=e.modelTransform,n=new Float32Array(t*2),s=new Float32Array(t*3);s.fill(0),n.fill(1,t);const{numChunkDisplayDims:r,chunkDisplayDimensionIndices:o}=i;for(let a=0;a{t.addMessage({severity:Tn.error,message:l})};if(i.error!==void 0)return n(i.error);const s=Zh(i.modelTransform,e.displayDimensionIndices);let r;try{r=ep(i,s)}catch(l){return n(l.message)}const{modelClipBounds:o,renderSubspaceTransform:a}=ty(r);return{chunkTransform:i,chunkDisplayTransform:r,modelClipBounds:o,renderSubspaceTransform:a}}function Kd(i,e){class t extends i{constructor(s,r){super(),this.base=s,this.renderScaleHistogram=r,this.curRank=-1,this.renderHelpers=[],this.isAnnotation=!0;const o=s.visibility;o!==void 0&&this.registerDisposer(o.add(this.visibility)),this.registerDisposer(this.renderScaleHistogram.visibility.add(this.visibility)),this.registerDisposer(()=>{for(const a of this.renderHelpers)a.dispose()}),this.role=s.state.role,this.registerDisposer(s.redrawNeeded.add(this.redrawNeeded.dispatch)),this.registerDisposer(s.source.properties.changed.add(()=>{this.handleRankChanged(!0)})),this.handleRankChanged(),this.registerDisposer(this.base.state.displayState.shaderControls.histogramSpecifications.producerVisibility.add(this.visibility))}handleRankChanged(s=!1){const{rank:r}=this.base.source;if(!s&&r===this.curRank)return;this.curRank=r,this.tempChunkPosition=new Float32Array(r);const{renderHelpers:o,gl:a}=this;for(const d of o)d.dispose();const{properties:{value:l}}=this.base.source,{displayState:c}=this.base.state;for(const d of Xt){const u=Tr(d),h=u[e],p=o[d]=new h(a,d,r,l,c.shaderControls,c.fallbackShaderControls,c.shaderError);p.pickIdsPerInstance=u.pickIdsPerInstance,p.targetIsSliceView=e==="sliceViewRenderHelper"}}attach(s){super.attach(s),this.handleRankChanged();const{chunkTransform:r}=this,o=s.view.displayDimensionRenderInfo.value;s.state={chunkTransform:r,displayDimensionRenderInfo:o,chunkRenderParameters:ny(r,o,s.messages)}}updateAttachmentState(s){const r=s.state;this.handleRankChanged();const{chunkTransform:o}=this,a=s.view.displayDimensionRenderInfo.value;return r!==void 0&&r.chunkTransform===o&&r.displayDimensionRenderInfo===a?r.chunkRenderParameters:(r.chunkTransform=o,r.displayDimensionRenderInfo=a,r.chunkRenderParameters=ny(o,a,s.messages))}get chunkTransform(){return this.base.state.chunkTransform.value}updateModelClipBounds(s,r){const{modelClipBounds:o}=r,a=this.curRank,{chunkTransform:l}=r;gs(o.subarray(0,a),s.projectionParameters.globalPosition,this.base.state.localPosition.value,l.layerRank,l.combinedGlobalLocalToChunkTransform)}get gl(){return this.base.chunkManager.gl}drawGeometryChunkData(s,r,o,a=1){if(!s.bufferValid){let{buffer:l}=s;l===void 0&&(l=s.buffer=new At(this.gl));const{serializedAnnotations:c}=s;l.setData(c.data),s.numPickIds=hg(c),s.bufferValid=!0}this.drawGeometry(s,r,o,a)}drawGeometry(s,r,o,a=1){const{base:l}=this,{chunkDisplayTransform:c}=o,{serializedAnnotations:d}=s,{typeToIdMaps:u,typeToOffset:h}=d;let p=0;r.emitPickID&&(p=r.pickIDs.register(this,s.numPickIds,0,0,s));const m=l.hoverState.value,g=C.pB.multiply(DL,r.projectionParameters.viewProjectionMat,c.displaySubspaceModelMatrix),v={annotationLayer:l,renderContext:r,selectedIndex:0,basePickId:p,buffer:s.buffer,bufferOffset:0,count:0,modelViewProjectionMatrix:g,modelClipBounds:o.modelClipBounds,subspaceMatrix:o.renderSubspaceTransform,renderSubspaceModelMatrix:c.displaySubspaceModelMatrix,renderSubspaceInvModelMatrix:c.displaySubspaceInvModelMatrix,chunkDisplayTransform:c},y=this.base.state.displayState.shaderControls.histogramSpecifications.visibleHistograms>0;for(const S of Xt){const w=u[S];let b=w.size;if(b>0){const x=Tr(S);let E=4294967295;if(m!==void 0){const I=w.get(m.id);I!==void 0&&(E=I*x.pickIdsPerInstance)}b=Math.round(b*a),v.count=b,v.bufferOffset=h[S],v.selectedIndex=E;const D=this.renderHelpers[S];D.draw(v),y&&(D.computeHistograms(v,r.frameNumber),r.bindFramebuffer()),v.basePickId+=b*x.pickIdsPerInstance}}}updateMouseState(s,r,o,a){const l=a,{serializedAnnotations:c}=l,{typeToIds:d,typeToOffset:u}=c,h=this.curRank,p=this.chunkTransform;if(p.error===void 0)for(const m of Xt){const g=d[m],v=Tr(m),{pickIdsPerInstance:y}=v;if(oclass extends i{constructor(){super(...arguments),this.layerChunkProgressInfo=this.base.layerChunkProgressInfo}draw(t,n){const s=this.updateAttachmentState(n);if(this.curRank===0||s===void 0)return;this.updateModelClipBounds(t,s);const{source:r}=this.base;if(r instanceof hs){const{base:o}=this;o.updateBuffer(),this.drawGeometry(o,t,s)}else{const{renderScaleHistogram:o}=this;o.begin(this.base.chunkManager.chunkQueueManager.frameNumberCounter.frameNumber),this.drawGeometryChunkData(r.temporary.data,t,s);const{value:a}=this.base.segmentationStates;let l=0,c=0;if(a!==void 0)for(let d=0,u=a.length;d{const g=Sn(m),v=p.get(g);if(v!==void 0&&v.state===Ue.GPU_MEMORY){const{data:y}=v;if(y===void 0)return;this.drawGeometryChunkData(y,t,s),++l}else++c})}o.add(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,l,c)}}isReady(){const{base:t}=this,{source:n}=t;if(!(n instanceof Rr))return!0;const{value:s}=this.base.segmentationStates;if(s===void 0)return!0;for(let r=0,o=s.length;r{const u=Sn(d);l.has(u)||(c=!0)}),c)return!1}return!0}},sy=Kd(Gi,"perspectiveViewRenderHelper");class kL extends iy(sy){}const ry=i=>{class e extends i{constructor(n){super(n.annotationLayer,n.renderScaleHistogram),this.wireFrameRenderHelper=this instanceof Fi?wL:CL,this.wireFrameShaderGetter=Ai(this,this.gl,{memoizeKey:`annotation/wireFrameShader:${this instanceof Fi}`,parameters:(0,_.XZ)(void 0),defineShader:o=>{this.wireFrameRenderHelper.defineShader(o)}}),this.renderScaleTarget=n.renderScaleTarget,this.registerDisposer(this.renderScaleTarget.changed.add(this.redrawNeeded.dispatch));const s=this.registerDisposer(new Dr(this.layerChunkProgressInfo)),r=this.base.chunkManager.rpc;s.RPC_TYPE_ID=YE,s.initializeCounterpart(r,{chunkManager:this.base.chunkManager.rpcId,localPosition:this.registerDisposer(ft.makeFromExisting(r,this.base.state.localPosition)).rpcId,renderScaleTarget:this.registerDisposer(ft.makeFromExisting(r,this.renderScaleTarget)).rpcId}),this.backend=s}attach(n){super.attach(n),n.state.sources=n.registerDisposer((0,_.no)((s,r,o)=>{const a=sa(o,r,l=>this.base.state.source.getSources(l),n.messages,this);for(const l of a)for(const c of l)s.registerDisposer(c.source),Object.assign(c,ty(c.chunkDisplayTransform));return n.view.flushBackendProjectionParameters(),this.backend.rpc.invoke(QE,{layer:this.backend.rpcId,view:n.view.rpcId,displayDimensionRenderInfo:o,sources:ta(a)}),this.redrawNeeded.dispatch(),a},this.base.state.transform,n.view.displayDimensionRenderInfo))}draw(n,s){const r=this.updateAttachmentState(s);if(this.curRank===0||r===void 0)return;const o=s.state.sources.value;if(o.length===0)return;this.updateModelClipBounds(n,r);const{renderScaleHistogram:a}=this;a.begin(this.base.chunkManager.chunkQueueManager.frameNumberCounter.frameNumber);const{projectionParameters:l}=n;let c;if(n.wireFrame){const{shader:d}=this.wireFrameShaderGetter(n.emitter);if(d===null)return;d.bind(),this.wireFrameRenderHelper.initialize(d,l),c=d}ng(l,this.base.state.localPosition.value,this.renderScaleTarget.value,o[0],()=>{},(d,u,h,p,m)=>{const g=d.source.chunks.get(d.curPositionInChunks.join());let v;if(g===void 0||g.state!==Ue.GPU_MEMORY)v=0;else{const{data:y}=g;if(y===void 0)return;c!==void 0?this.wireFrameRenderHelper.draw(c,d,l):this.drawGeometryChunkData(y,n,r,h),v=1}a.add(p,m,v,1-v)})}isReady(n,s){const r=this.updateAttachmentState(s);if(this.curRank===0||r===void 0)return;const o=s.state.sources.value;if(o.length===0)return;this.updateModelClipBounds(n,r);const{projectionParameters:a}=n;let l=!0;return ng(a,this.base.state.localPosition.value,this.renderScaleTarget.value,o[0],()=>{},(c,d,u,h,p)=>{const m=c.source.chunks.get(c.curPositionInChunks.join());if(m===void 0||m.state!==Ue.GPU_MEMORY){l=!1;return}}),l}}return e},PL=ry(sy),AL=ry(Kd(Fi,"sliceViewRenderHelper")),ML=iy(Kd(Fi,"sliceViewRenderHelper"));var Fa=G(4499);/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function qd(i={}){return Ne({svg:Fa,...i})}var NL=G(1252);/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function Mn(i={}){const e=Ne({svg:NL,...i}),t=e.firstElementChild;return t.style.fill="white",e}/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const oy=10,Ua=.5;class OL{constructor(){this.anchorIndex=0,this.anchorClientOffset=0}splice(e){let{anchorIndex:t}=this,n=0;for(const s of e){if(n+=s.retainCount,te;--t)n-=this.getEstimatedSize(t-1);return n}getRangeSize(e,t){let n=0;const{itemSize:s,averageSize:r}=this;for(let o=e;on+s,0),this.numItemsInTotalKnownSize=t.reduce(n=>n+1,0)}}function VL(i,e,t,n,s,r){const{anchorIndex:o,anchorClientOffset:a}=r,l=s.getEstimatedOffset(o);let c,d,u,h,p;if(n===0||s.totalKnownSize===0)c=Math.max(0,o-oy/2),d=Math.min(t,c+oy),p=o,u=0,h=a;else{const m=s.getEstimatedTotalSize(),g=Math.max(0,m-n);h=l-a,h=Math.max(0,Math.min(g,h));const v=h-2*Ua*n,y=h-Ua*n,S=h+n+Ua*n,w=l-a+n+2*Ua*n;c=Math.min(t,e.startIndex);let b=s.getEstimatedOffset(c,o,l);if(b=y)break;b+=E}if(b>=y)for(;b>v&&c>0;--c){const E=s.getEstimatedSize(c-1);b-=E}d=Math.min(t,e.endIndex);let x=s.getEstimatedOffset(d,o,l);if(x=w)for(;d>c;--d){const E=s.getEstimatedSize(d-1);if(x-Ed;--p){const E=s.getEstimatedSize(p-1);u-=E}}i.startIndex=c,i.endIndex=d,i.anchorIndex=p,i.anchorOffset=u,i.scrollOffset=h}function BL(i,e){const t=e.getEstimatedOffset(i.anchorIndex),n=i.anchorOffset;i.anchorOffset=t,i.scrollOffset+=t-n}function FL(i,e){return i.startIndexe.endIndex||i.viewportWidth!==0&&e.viewportWidth===0}class Wr extends T.O8{constructor(e){super(),this.element=document.createElement("div"),this.scrollContent=document.createElement("div"),this.header=document.createElement("div"),this.body=document.createElement("div"),this.topItems=document.createElement("div"),this.bottomItems=document.createElement("div"),this.renderedItems=[],this.renderGeneration=-1,this.listGeneration=-1,this.newRenderedItems=[],this.state=new OL,this.renderParams=new ay,this.newRenderParams=new ay,this.sizes=new _L,this.debouncedUpdateView=this.registerCancellable((0,Qe.t)(()=>this.updateView())),this.resizeObserver=new ResizeObserver(()=>this.updateView());const{selectedIndex:t}=e;t!==void 0&&(this.state.anchorIndex=t,this.state.anchorClientOffset=0);const n=this.source=e.source;this.sizes.itemSize.length=n.length;const{element:s,header:r,body:o,scrollContent:a,topItems:l,bottomItems:c}=this;this.resizeObserver.observe(s),this.registerDisposer(()=>this.resizeObserver.disconnect()),s.appendChild(a),s.style.overflowAnchor="none",a.appendChild(r),a.appendChild(o),r.style.position="sticky",r.style.zIndex="1",r.style.top="0",e.horizontalScroll?(a.style.width="min-content",a.style.minWidth="100%",r.style.width="min-content",r.style.minWidth="100%",c.style.width="min-content",c.style.minWidth="100%"):(a.style.width="100%",r.style.width="100%",c.style.width="100%"),o.appendChild(l),o.appendChild(c),l.style.width="min-content",l.style.position="relative",l.style.height="0",l.style.minWidth="100%",c.style.height="0",c.style.position="relative",s.addEventListener("scroll",()=>{const d=s.scrollTop;this.state.anchorClientOffset=this.renderParams.anchorOffset-d,this.renderParams.scrollOffset=d,this.debouncedUpdateView()}),n.changed!==void 0&&this.registerDisposer(n.changed.add(d=>{this.sizes.splice(d),this.state.splice(d),this.renderedItems.length=0,this.debouncedUpdateView()})),n.renderChanged!==void 0&&this.registerDisposer(n.renderChanged.add(this.debouncedUpdateView))}updateView(){const{element:e}=this,t=e.clientHeight-this.header.offsetHeight,n=e.clientWidth,{source:s,state:r,sizes:o}=this,a=s.length,{body:l,topItems:c,bottomItems:d}=this,{changed:u,renderChanged:h}=s;let p;for(;;){p=this.newRenderParams;const v=this.renderParams;VL(p,v,a,t,o,r),p.viewportWidth=n;let y;if(h!==void 0&&h.count!==this.renderGeneration||u!==void 0&&u.count!==this.listGeneration?(this.renderGeneration=h===void 0?-1:h.count,this.listGeneration=u===void 0?-1:u.count,y=!0,this.renderedItems.length=0):y=!1,!y&&!FL(p,v)){v.scrollOffset=p.scrollOffset,p=v;break}this.renderParams=p,this.newRenderParams=v;const S=this.renderedItems,w=this.newRenderedItems;w.length=0,this.renderedItems=w,this.newRenderedItems=S;const{source:b}=this,{render:x}=b,{startIndex:E,endIndex:D,anchorIndex:I}=p;function*L(N,k){for(let O=N;Os&&n>s+this.element.offsetHeight)this.state.anchorIndex=e+1,this.state.anchorClientOffset=this.element.offsetHeight;else return;this.debouncedUpdateView()}disposed(){at(this.element)}}/** + * @license + * Copyright 2018 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class ly extends T.O8{constructor(){super(...arguments),this.changed=new j.IY,this.isLoadingChanged=new j.IY,this.states=[],this.relationships=[],this.loadingCount=0}get value(){return this.states}get isLoading(){return this.loadingCount!==0}markLoading(){return this.loadingCount++,()=>{--this.loadingCount===0&&this.isLoadingChanged.dispatch()}}sort(){this.states.sort((e,t)=>{const n=e.sourceIndex-t.sourceIndex;return n!==0?n:e.subsourceIndex-t.subsourceIndex})}updateRelationships(){const e=new Set;for(const t of this.states)for(const n of t.source.relationships)e.add(n);this.relationships=Array.from(e)}add(e){return this.states.push(e),this.sort(),this.updateRelationships(),this.changed.dispatch(),()=>{const t=this.states.indexOf(e);this.states.splice(t,1),this.updateRelationships(),this.changed.dispatch()}}}function UL(i,e){switch(e.type){case Re.AXIS_ALIGNED_BOUNDING_BOX:case Re.LINE:i.set(e.pointA);break;case Re.POINT:i.set(e.point);break;case Re.ELLIPSOID:i.set(e.center);break}}function $L(i,e){switch(e.type){case Re.AXIS_ALIGNED_BOUNDING_BOX:case Re.LINE:Ah(i,e.pointA,e.pointB),dC(i,i,.5);break;case Re.POINT:i.set(e.point);break;case Re.ELLIPSOID:i.set(e.center);break}}function cy(i,e,t){e.error===void 0&&i.setLayerPosition(e.modelTransform,t)}function dy(i,e,t){const{layerRank:n}=e,s=new Float32Array(n);Ft[i.type].visitGeometry(i,(r,o)=>{s.set(r);const a=new Float32Array(n);(o?De._U:De.vo)(a,e.chunkToLayerTransform,n+1,s,n),t(a,o)})}const uy=(i,e,t)=>{const n=t.chunkTransform.value,{layerRank:s}=n,r=new Float32Array(s),o=new Float32Array(s);UL(r,e),De.vo(o,n.chunkToLayerTransform,s+1,r,s),cy(i,n,o),t.displayState.swapVisibleSegmentsOnMove.value&&GL(e,t,!0)},GL=(i,e,t=!1)=>{const{relatedSegments:n}=i;if(n){const{source:s,displayState:r}=e,{relationships:o}=s,{relationshipStates:a}=r;for(let l=0,c=o.length;lthis.render(h),changed:new j.HN},this.virtualList=new Wr({source:this.virtualListSource}),this.listElements=[],this.updated=!1,this.mutableControls=document.createElement("div"),this.headerRow=document.createElement("div"),this.attachedAnnotationStates=new Map,this.forceUpdateView=()=>{this.updated=!1,this.updateView()},this.globalDimensionIndices=[],this.localDimensionIndices=[],this.curCoordinateSpaceGeneration=-1,this.prevCoordinateSpaceGeneration=-1,this.columnWidths=[],this.gridTemplate="",this.selectedAnnotationState=(0,_.ol)((h,p)=>{if(h===void 0)return;const{layer:m}=this,g=h.layers.find(S=>S.layer===m)?.state;if(g===void 0)return;const{annotationId:v}=g;if(v===void 0)return;const y=this.annotationStates.states.find(S=>S.sourceIndex===g.annotationSourceIndex&&(g.annotationSubsource===void 0||S.subsourceId===g.annotationSubsource));if(y!==void 0)return{annotationId:v,annotationLayerState:y,pin:p}},this.layer.manager.root.selectionState,this.layer.manager.root.selectionState.pin),this.element.classList.add("neuroglancer-annotation-layer-view"),this.registerDisposer(this.visibility.changed.add(()=>this.updateView())),this.registerDisposer(this.annotationStates.changed.add(()=>this.updateAttachedAnnotationLayerStates())),this.headerRow.classList.add("neuroglancer-annotation-list-header");const n=document.createElement("div");n.className="neuroglancer-annotation-toolbox",e.initializeAnnotationLayerViewTab(this);const s=this.registerDisposer(new hi(this.displayState.color));s.element.title="Change annotation display color",this.registerDisposer(new en((0,_.ol)(h=>h.match(/\bdefaultColor\b/)!==null,t.shaderControls.processedFragmentMain),s.element)),n.appendChild(s.element);const{mutableControls:r}=this,o=Ne({text:Ft[Re.POINT].icon,title:"Annotate point",onClick:()=>{this.layer.tool.value=new yy(this.layer,{})}});r.appendChild(o);const a=Ne({text:Ft[Re.AXIS_ALIGNED_BOUNDING_BOX].icon,title:"Annotate bounding box",onClick:()=>{this.layer.tool.value=new Xd(this.layer,{})}});r.appendChild(a);const l=Ne({text:Ft[Re.LINE].icon,title:"Annotate line",onClick:()=>{this.layer.tool.value=new Ga(this.layer,{})}});r.appendChild(l);const c=Ne({text:Ft[Re.ELLIPSOID].icon,title:"Annotate ellipsoid",onClick:()=>{this.layer.tool.value=new Cy(this.layer,{})}});r.appendChild(c),n.appendChild(r),this.element.appendChild(n),this.element.appendChild(this.headerRow);const{virtualList:d}=this;d.element.classList.add("neuroglancer-annotation-list"),this.element.appendChild(d.element),this.virtualList.element.addEventListener("mouseleave",()=>{this.displayState.hoverState.value=void 0});const u=Im();this.registerDisposer(new tn(this.virtualList.element,u)),this.virtualList.element.title=u.describe(),this.registerDisposer(this.displayState.hoverState.changed.add(()=>this.updateHoverView())),this.registerDisposer(this.selectedAnnotationState.changed.add(()=>this.updateSelectionView())),this.registerDisposer(this.layer.localCoordinateSpace.changed.add(()=>{this.updateCoordinateSpace(),this.updateView()})),this.registerDisposer(this.layer.manager.root.coordinateSpace.changed.add(()=>{this.updateCoordinateSpace(),this.updateView()})),this.updateCoordinateSpace(),this.updateAttachedAnnotationLayerStates(),this.updateSelectionView()}get annotationStates(){return this.layer.annotationStates}updateAttachedAnnotationLayerStates(){const e=this.annotationStates.states,{attachedAnnotationStates:t}=this,n=new Map;for(const[s,r]of t)e.includes(s)||(t.delete(s),r.refCounted.dispose());for(const s of e){const r=t.get(s);if(r!==void 0){n.set(s,r);continue}const o=s.source,a=new T.O8;o instanceof hs&&(a.registerDisposer(o.childAdded.add(l=>this.addAnnotationElement(l,s))),a.registerDisposer(o.childUpdated.add(l=>this.updateAnnotationElement(l,s))),a.registerDisposer(o.childDeleted.add(l=>this.deleteAnnotationElement(l,s)))),a.registerDisposer(s.transform.changed.add(this.forceUpdateView)),n.set(s,{refCounted:a,annotations:[],idToIndex:new Map,listOffset:0})}this.attachedAnnotationStates=n,t.clear(),this.updateCoordinateSpace(),this.forceUpdateView()}updateCoordinateSpace(){const e=this.layer.localCoordinateSpace.value,t=this.layer.manager.root.coordinateSpace.value,n=[],s=[];for(let r=0,o=t.rank;r{const l=a.transform.value;return l.error!==void 0?!1:l.globalToRenderLayerDimensions[r]!==-1})&&n.push(r);for(let r=0,o=e.rank;r{const l=a.transform.value;return l.error!==void 0?!1:l.localToRenderLayerDimensions[r]!==-1})&&s.push(r);(!(0,F.r1)(n,this.globalDimensionIndices)||!(0,F.r1)(s,this.localDimensionIndices))&&(this.localDimensionIndices=s,this.globalDimensionIndices=n,++this.curCoordinateSpaceGeneration)}getRenderedAnnotationListElement(e,t,n=!1){const s=this.attachedAnnotationStates.get(e);if(s===void 0)return;const r=s.idToIndex.get(t);if(r===void 0)return;const o=s.listOffset+r;return n&&this.virtualList.scrollItemIntoView(r),this.virtualList.getItemElement(o)}clearSelectionClass(){const{previousSelectedState:e}=this;if(e===void 0)return;this.previousSelectedState=void 0;const t=this.getRenderedAnnotationListElement(e.annotationLayerState,e.annotationId);t!==void 0&&t.classList.remove("neuroglancer-annotation-selected")}clearHoverClass(){const{previousHoverId:e,previousHoverAnnotationLayerState:t}=this;if(t!==void 0){this.previousHoverAnnotationLayerState=void 0,this.previousHoverId=void 0;const n=this.getRenderedAnnotationListElement(t,e);n!==void 0&&n.classList.remove("neuroglancer-annotation-hover")}}updateSelectionView(){const e=this.selectedAnnotationState.value,{previousSelectedState:t}=this;if(t===e||t!==void 0&&e!==void 0&&t.annotationId===e.annotationId&&t.annotationLayerState===e.annotationLayerState&&t.pin===e.pin||(this.clearSelectionClass(),this.previousSelectedState=e,e===void 0))return;const n=this.getRenderedAnnotationListElement(e.annotationLayerState,e.annotationId,e.pin);n!==void 0&&n.classList.add("neuroglancer-annotation-selected")}updateHoverView(){const e=this.displayState.hoverState.value;let t,n;e!==void 0&&(t=e.id,n=e.annotationLayerState);const{previousHoverId:s,previousHoverAnnotationLayerState:r}=this;if(t===s&&n===r||(this.clearHoverClass(),this.previousHoverId=t,this.previousHoverAnnotationLayerState=n,t===void 0))return;const o=this.getRenderedAnnotationListElement(n,t);o!==void 0&&o.classList.add("neuroglancer-annotation-hover")}render(e){const{annotation:t,state:n}=this.listElements[e],{layer:s,gridTemplate:r,globalDimensionIndices:o,localDimensionIndices:a}=this,[l,c]=xy(s,t,n,r,o,a);for(const[u,h]of c.entries())this.setColumnWidth(u,h);l.addEventListener("mouseenter",()=>{this.displayState.hoverState.value={id:t.id,partIndex:0,annotationLayerState:n}});const d=this.selectedAnnotationState.value;return d!==void 0&&d.annotationLayerState===n&&d.annotationId===t.id&&l.classList.add("neuroglancer-annotation-selected"),l}setColumnWidth(e,t){t+=2;const{columnWidths:n}=this;n[e]>t||(n[e]=t,this.element.style.setProperty(`--neuroglancer-column-${e}-width`,`${t}ch`))}updateView(){if(!this.visible)return;if(this.curCoordinateSpaceGeneration!==this.prevCoordinateSpaceGeneration){this.updated=!1;const{columnWidths:s}=this;s.length=0;const{headerRow:r}=this,o=document.createElement("div");o.style.gridColumn="symbol";const a=document.createElement("div");a.style.gridColumn="delete",Me(r),r.appendChild(o);let l=0,c="[symbol] 2ch";const d=(p,m)=>{const g=document.createElement("div");g.classList.add("neuroglancer-annotations-view-dimension");const v=document.createElement("span");v.classList.add("neuroglancer-annotations-view-dimension-name"),v.textContent=p.names[m];const y=document.createElement("scale");y.classList.add("neuroglancer-annotations-view-dimension-scale"),y.textContent=Ri(p.scales[m],p.units[m],{precision:2}),g.appendChild(v),g.appendChild(y),g.style.gridColumn=`dim ${l+1}`,this.setColumnWidth(l,y.textContent.length+v.textContent.length+3),c+=` [dim] var(--neuroglancer-column-${l}-width)`,++l,r.appendChild(g)},u=this.layer.manager.root.coordinateSpace.value;for(const p of this.globalDimensionIndices)d(u,p);const h=this.layer.localCoordinateSpace.value;for(const p of this.localDimensionIndices)d(h,p);r.appendChild(a),c+=" [delete] 2ch",this.gridTemplate=c,r.style.gridTemplateColumns=c,this.prevCoordinateSpaceGeneration=this.curCoordinateSpaceGeneration}if(this.updated)return;let e=!1;const{listElements:t}=this;t.length=0;for(const[s,r]of this.attachedAnnotationStates){if(s.source.readonly||(e=!0),s.chunkTransform.value.error!==void 0)continue;const{source:o}=s,a=Array.from(o);r.annotations=a;const{idToIndex:l}=r;l.clear();for(let c=0,d=a.length;co.default)},r=t.source.add(s,!0);this.layer.selectAnnotation(t,r.id,!0),r.dispose()}}get description(){return"annotate point"}toJSON(){return fy}}function Hr(i,e){const t=e.chunkTransform.value;if(t.error!==void 0)return;const n=new Float32Array(t.modelTransform.unpaddedRank);if(gs(n,i.unsnappedPosition,e.localPosition.value,t.layerRank,t.combinedGlobalLocalToChunkTransform))return n}class Sy extends py{constructor(){super(...arguments),this.inProgressAnnotation=new _.B0(void 0)}trigger(e){const{annotationLayer:t,inProgressAnnotation:n}=this;if(t!==void 0&&e.updateUnconditionally()){const s=()=>{const r=n.value,o=r.reference,a=this.getUpdatedAnnotation(o.value,e,t);JSON.stringify(_l(a,t.source))!==JSON.stringify(_l(o.value,t.source))&&(r.annotationLayer.source.update(o,a),this.layer.selectAnnotation(t,o.id,!0))};if(n.value===void 0){const r=t.source.add(this.getInitialAnnotation(e,t),!1);this.layer.selectAnnotation(t,r.id,!0);const o=e.changed.add(s),a=()=>{o(),r.dispose()};n.value={annotationLayer:t,reference:r,disposer:a}}else{s();const r=n.value;r.annotationLayer.source.commit(r.reference),r.disposer(),n.value=void 0}}}disposed(){this.deactivate(),super.disposed()}deactivate(){const e=this.inProgressAnnotation.value;e!==void 0&&(e.annotationLayer.source.delete(e.reference),e.disposer(),this.inProgressAnnotation.value=void 0)}}class by extends Sy{getInitialAnnotation(e,t){const n=Hr(e,t);return{id:"",type:this.annotationType,description:"",pointA:n,pointB:n,properties:t.source.properties.value.map(s=>s.default)}}getUpdatedAnnotation(e,t,n){const s=Hr(t,n);return s===void 0?e:{...e,pointB:s}}}class Xd extends by{get description(){return"annotate bounding box"}getUpdatedAnnotation(e,t,n){const s=super.getUpdatedAnnotation(e,t,n),{pointA:r,pointB:o}=s,a=r.length;for(let l=0;l{const c=r[l];return a=a.filter(d=>c.findIndex(u=>P.R.equal(d,u))===-1),[...c,...a]}),s}toJSON(){return gy}}Ga.prototype.annotationType=Re.LINE;class Cy extends Sy{getInitialAnnotation(e,t){const n=Hr(e,t);return{type:Re.ELLIPSOID,id:"",description:"",segments:$a(t),center:n,radii:C.eR.fromValues(0,0,0),properties:t.source.properties.value.map(s=>s.default)}}getUpdatedAnnotation(e,t,n){const s=Hr(t,n);if(s===void 0)return e;const r=e.center,o=r.length;for(let a=0;anew yy(i,e)),Cr(my,(i,e)=>new Xd(i,e)),Cr(gy,(i,e)=>new Ga(i,e)),Cr(vy,(i,e)=>new Cy(i,e));const WL=Ae.fromObject({enter:{action:"commit"},escape:{action:"cancel"}});function HL(i,e,t,n){return new Wt(t,(s,r,o)=>{const a=document.createElement("div");a.classList.add("neuroglancer-related-segment-list"),s!=null&&o.registerDisposer($r(s,a));const l=document.createElement("div");l.classList.add("neuroglancer-related-segment-list-header");const c=Hn({title:"Copy segment IDs",onClick:()=>{mi(e.map(m=>m.toString()).join(", "))}});l.appendChild(c);let d;if(s!=null&&(d=document.createElement("input"),d.type="checkbox",d.addEventListener("change",()=>{const{visibleSegments:m}=s.segmentationGroupState.value,g=e.some(v=>!m.has(v));for(const v of e)m.set(v,g)}),l.appendChild(d)),n!==void 0){const m=Mn({title:"Remove all IDs",onClick:()=>{n([])}});l.appendChild(m)}const u=document.createElement("span");if(u.classList.add("neuroglancer-related-segment-list-title"),u.textContent=i,l.appendChild(u),n!==void 0){const m=qd({title:"Add related segment ID",onClick:()=>{const g=new T.O8,v=o.registerDisposer((0,T.K9)(g)),y=document.createElement("div");y.classList.add("neuroglancer-segment-list-entry"),y.classList.add("neuroglancer-segment-list-entry-new");const S=Hn({});if(S.classList.add("neuroglancer-segment-list-entry-copy"),y.appendChild(S),s!=null){const D=document.createElement("input");D.classList.add("neuroglancer-segment-list-entry-visible-checkbox"),D.type="checkbox",y.appendChild(D)}const w=Mn({title:"Cancel adding new segment ID",onClick:()=>{v()}});w.classList.add("neuroglancer-segment-list-entry-delete"),y.appendChild(w);const b=document.createElement("input");b.autocomplete="off",b.spellcheck=!1,b.classList.add("neuroglancer-segment-list-entry-id");const x=g.registerDisposer(new yn(b,WL));x.allShortcutsAreGlobal=!0;const E=()=>{const D=new P.R;if(D.tryParseString(b.value))return b.dataset.valid="true",D;b.dataset.valid="false"};E(),b.addEventListener("input",()=>{E()}),b.addEventListener("blur",()=>{const D=E();D!==void 0&&n([...e,D]),v()}),Z(b,"cancel",v),Z(b,"commit",()=>{const D=E();D!==void 0&&n([...e,D]),v()}),y.appendChild(b),a.appendChild(y),b.focus(),g.registerDisposer(()=>{b.value="",y.remove()})}});l.appendChild(m)}a.appendChild(l);const h=[],p=Vs.make(s??void 0,!1);for(const m of e){const g=p.get(m);if(h.push(g),n!==void 0){const v=Mn({title:"Remove ID",onClick:y=>{n(e.filter(S=>!P.R.equal(S,m))),y.stopPropagation()}});v.classList.add("neuroglancer-segment-list-entry-delete"),g.children[0].appendChild(v)}a.appendChild(g)}if(s!=null){const m=o.registerCancellable((0,Qe.t)(()=>{const{visibleSegments:g}=s.segmentationGroupState.value;let v=0;for(const y of e)g.has(y)&&++v;for(const y of h)p.update(y);d.checked=v===e.length&&v>0,d.indeterminate=v>0&&v{const l=this.manager.root.selectionState.value;if(l===void 0)return;const c=l.layers.find(v=>v.layer===this)?.state;if(c===void 0)return;const{annotationId:d}=c;if(d===void 0)return;let u=this.annotationStates.states.find(v=>v.sourceIndex===c.annotationSourceIndex&&(c.annotationSubsource===void 0||v.subsourceId===c.annotationSubsource));if(u===void 0)return;let h=this.annotationStates.states.indexOf(u),{source:p}=u,m=Array.from(p),g=m.findIndex(v=>v.id===d);for(;;){if(g=g+a,g===-1)h-=1;else if(g===m.length)h+=1;else{const v=m[g];this.selectAnnotation(u,v.id,!0),uy(this,v,u);return}if(u=this.annotationStates.states[h],u===void 0)return;p=u.source,m=Array.from(p),g=g===-1?m.length:0}},this.annotationDisplayState.color.changed.add(this.specificationChanged.dispatch),this.annotationDisplayState.shader.changed.add(this.specificationChanged.dispatch),this.annotationDisplayState.shaderControls.changed.add(this.specificationChanged.dispatch),this.tabs.add("annotations",{label:"Annotations",order:10,getter:()=>new zL(this)});let s;const r=()=>{const a=this.isReady;a&&s!==void 0?(s(),s=void 0):!a&&s===void 0&&(s=this.annotationStates.markLoading())};this.readyStateChanged.add(r),r();const{mouseState:o}=this.manager.layerSelectedValues;this.registerDisposer(o.changed.add(()=>{if(o.active){const{pickedAnnotationLayer:a}=o;if(a!==void 0&&this.annotationStates.states.includes(a)){const l=this.annotationDisplayState.hoverState.value;(l===void 0||l.id!==o.pickedAnnotationId||l.partIndex!==o.pickedOffset||l.annotationLayerState!==a)&&(this.annotationDisplayState.hoverState.value={id:o.pickedAnnotationId,partIndex:o.pickedOffset,annotationLayerState:a});return}}this.annotationDisplayState.hoverState.value=void 0})),this.registerDisposer(this.registerLayerEvent("select-previous",()=>{this.changeSelectedIndex(-1)})),this.registerDisposer(this.registerLayerEvent("select-next",()=>{this.changeSelectedIndex(1)}))}initializeAnnotationLayerViewTab(n){}restoreState(n){super.restoreState(n),this.annotationDisplayState.color.restoreState(n[wy])}captureSelectionState(n,s){super.captureSelectionState(n,s);const r=s.pickedAnnotationLayer;r===void 0||!this.annotationStates.states.includes(r)||(n.annotationId=s.pickedAnnotationId,n.annotationType=s.pickedAnnotationType,n.annotationBuffer=new Uint8Array(s.pickedAnnotationBuffer,s.pickedAnnotationBufferBaseOffset),n.annotationIndex=s.pickedAnnotationIndex,n.annotationCount=s.pickedAnnotationCount,n.annotationPartIndex=s.pickedOffset,n.annotationSourceIndex=r.sourceIndex,n.annotationSubsource=r.subsourceId)}displayAnnotationState(n,s,r){if(n.annotationId===void 0)return!1;const o=this.annotationStates.states.find(l=>l.sourceIndex===n.annotationSourceIndex&&l.subsubsourceId===n.annotationSubsubsourceId&&(n.annotationSubsource===void 0||l.subsourceId===n.annotationSubsource));if(o===void 0)return!1;const a=r.registerDisposer(o.source.getReference(n.annotationId));return s.appendChild(r.registerDisposer(new Wt(r.registerDisposer(new _.wP(()=>({annotation:a,chunkTransform:o.chunkTransform}))),({annotation:l,chunkTransform:c},d,u)=>{let h;if(l==null)if(n.annotationType!==void 0&&n.annotationBuffer!==void 0){const p=Ft[n.annotationType],m=o.source.rank,g=p.serializedBytes(m),v=n.annotationBuffer.byteOffset,y=new DataView(n.annotationBuffer.buffer),S=U.LITTLE===te,{properties:w}=o.source,b=new Eh(m,g,w.value),x=n.annotationIndex,E=n.annotationCount;l=p.deserialize(y,v+b.propertyGroupBytes[0]*x,S,m,n.annotationId),b.deserialize(y,v,x,E,S,l.properties=new Array(w.value.length)),o.source.hasNonSerializedProperties()&&(h="Loading...")}else h=l===null?"Annotation not found":"Loading...";if(l!=null){const p=c.error===void 0?c.layerRank:0,m=document.createElement("div");m.classList.add("neuroglancer-selected-annotation-details-position-grid"),m.style.gridTemplateColumns=`[icon] 0fr [copy] 0fr repeat(${p}, [dim] 0fr [coord] 0fr) [move] 0fr [delete] 0fr`,d.appendChild(m);const g=Ft[l.type],v=document.createElement("div");if(v.className="neuroglancer-selected-annotation-details-icon",v.textContent=g.icon,m.appendChild(v),p!==0){const{layerDimensionNames:L}=c.modelTransform;for(let N=0;N{const O=Hn({title:"Copy position",onClick:()=>{mi(N.map(V=>Math.floor(V)).join(", "))}});O.style.gridColumn="copy",m.appendChild(O);for(let V=0;V{cy(this,c,N)}});V.style.gridColumn="move",m.appendChild(V)}})}if(!o.source.readonly){const L=Mn({title:"Delete annotation",onClick:()=>{o.source.delete(a)}});L.classList.add("neuroglancer-selected-annotation-details-delete"),m.appendChild(L)}const{relationships:y,properties:{value:S}}=o.source,w=o.source.readonly,b=document.createElement("label");b.classList.add("neuroglancer-annotation-property");const x=document.createElement("span");x.classList.add("neuroglancer-annotation-property-label"),x.textContent="ID",b.appendChild(x);const E=document.createElement("span");E.classList.add("neuroglancer-annotation-property-value"),E.textContent=a.id,b.appendChild(E),d.appendChild(b);const D=[];for(let L=0,N=S.length;L`#${O}`).join(" "),L.appendChild(k),d.appendChild(L)}const{relatedSegments:I}=l;for(let L=0,N=y.length;L{const Y=a.value;if(Y==null)return;let{relatedSegments:Q}=Y;Q===void 0?Q=o.source.relationships.map(()=>[]):Q=Q.slice(),Q[O]=z;const X={...Y,relatedSegments:Q};o.source.update(a,X),o.source.commit(a)})).element)}if(!o.source.readonly||l.description)if(o.source.readonly){const L=document.createElement("div");L.className="neuroglancer-annotation-details-description",L.textContent=l.description||"",d.appendChild(L)}else{const L=document.createElement("textarea");L.value=l.description||"",L.rows=3,L.className="neuroglancer-annotation-details-description",L.placeholder="Description",L.addEventListener("change",()=>{const N=L.value;o.source.update(a,{...l,description:N||void 0}),o.source.commit(a)}),d.appendChild(L)}}if(h!==void 0){const p=document.createElement("div");p.classList.add("neuroglancer-selection-annotation-status"),p.textContent=h,d.appendChild(p)}})).element),!0}displaySelectionState(n,s,r){let o=this.displayAnnotationState(n,s,r);return super.displaySelectionState(n,s,r)&&(o=!0),o}addLocalAnnotations(n,s,r){const{subsourceEntry:o}=n,a=new jo({localPosition:this.localPosition,transform:n.getRenderLayerTransform(),source:s,displayState:this.annotationDisplayState,dataSource:n.loadedDataSource.layerDataSource,subsourceIndex:n.subsourceIndex,subsourceId:o.id,role:r});this.addAnnotationLayerState(a,n)}addStaticAnnotations(n){const{subsourceEntry:s}=n,{staticAnnotations:r}=s.subsource;return r===void 0?!1:(n.activate(()=>{this.addLocalAnnotations(n,r,li.DEFAULT_ANNOTATION)}),!0)}addAnnotationLayerState(n,s){const r=s.activated;r.registerDisposer(this.annotationStates.add(n));const o=new RL(this.manager.chunkManager,n.addRef());if(o.source instanceof Rr){const a=new AL({annotationLayer:o.addRef(),renderScaleTarget:this.annotationCrossSectionRenderScaleTarget,renderScaleHistogram:this.annotationCrossSectionRenderScaleHistogram});r.registerDisposer(s.messages.addChild(a.messages));const l=new PL({annotationLayer:o.addRef(),renderScaleTarget:this.annotationProjectionRenderScaleTarget,renderScaleHistogram:this.annotationProjectionRenderScaleHistogram});r.registerDisposer(s.messages.addChild(l.messages)),r.registerDisposer((0,_.no)((c,d)=>{d&&(c.registerDisposer(this.addRenderLayer(a.addRef())),c.registerDisposer(this.addRenderLayer(l.addRef())))},this.annotationDisplayState.displayUnfiltered))}{const a=new ML(o,this.annotationCrossSectionRenderScaleHistogram);r.registerDisposer(this.addRenderLayer(a)),r.registerDisposer(s.messages.addChild(a.messages))}{const a=new kL(o.addRef(),this.annotationProjectionRenderScaleHistogram);r.registerDisposer(this.addRenderLayer(a)),r.registerDisposer(s.messages.addChild(a.messages))}}selectAnnotation(n,s,r){this.manager.root.selectionState.captureSingleLayerState(this,o=>(o.annotationId=s,o.annotationSourceIndex=n.sourceIndex,o.annotationSubsource=n.subsourceId,o.annotationSubsubsourceId=n.subsubsourceId,!0),r)}toJSON(){const n=super.toJSON();return n[wy]=this.annotationDisplayState.color.toJSON(),n}}return e}function xy(i,e,t,n,s,r){const o=t.chunkTransform.value,a=document.createElement("div");a.classList.add("neuroglancer-annotation-list-entry"),a.dataset.color=t.displayState.color.toString(),a.style.gridTemplateColumns=n;const l=document.createElement("div");l.className="neuroglancer-annotation-icon",l.textContent=Ft[e.type].icon,a.appendChild(l);let c;const d=()=>{t.source.readonly||c===void 0&&(c=Mn({title:"Delete annotation",onClick:g=>{g.stopPropagation(),g.preventDefault();const v=t.source.getReference(e.id);try{t.source.delete(v)}finally{v.dispose()}}}),c.classList.add("neuroglancer-annotation-list-entry-delete"),a.appendChild(c))},u=[];let h=0;if(dy(e,o,(g,v)=>{++h;const y=document.createElement("div");y.className="neuroglancer-annotation-position",a.appendChild(y);let S=0;const w=(b,x)=>{for(const E of b){const D=x[E];if(D!==-1){const I=Math.floor(g[D]),L=document.createElement("div"),N=I.toString();L.textContent=N,L.classList.add("neuroglancer-annotation-coordinate"),L.style.gridColumn=`dim ${S+1}`,u[S]=Math.max(u[S]||0,N.length),y.appendChild(L)}++S}};w(s,o.modelTransform.globalToRenderLayerDimensions),w(r,o.modelTransform.localToRenderLayerDimensions),d()}),e.description){++h;const g=document.createElement("div");g.classList.add("neuroglancer-annotation-description"),g.textContent=e.description,a.appendChild(g)}const{properties:{value:p}}=t.source,m=[];for(let g=0,v=p.length;g`#${v}`).join(" "),a.appendChild(g)}return l.style.gridRow=`span ${h}`,c!==void 0&&(c.style.gridRow=`span ${h}`),a.addEventListener("mouseenter",()=>{i.selectAnnotation(t,e.id,!1)}),a.addEventListener("action:select-position",g=>{g.stopPropagation(),i.selectAnnotation(t,e.id,"toggle")}),a.addEventListener("action:pin-annotation",g=>{g.stopPropagation(),i.selectAnnotation(t,e.id,!0)}),a.addEventListener("action:move-to-annotation",g=>{g.stopPropagation(),g.preventDefault(),uy(i,e,t)}),[a,u]}/** + * /** + * @license + * This work is a derivative of the Google Neuroglancer project, + * Copyright 2016 Google Inc. + * The Derivative Work is covered by + * Copyright 2021 Howard Hughes Medical Institute + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const eu="selectSegments",tu="mousedown0",JL=Ae.fromObject({[`at:alt?+shift?+${tu}`]:"drag-select-segments"});var jL=(i=>(i[i.IDLE=0]="IDLE",i[i.SELECT=1]="SELECT",i[i.DESELECT=2]="DESELECT",i))(jL||{});class YL extends gi{toJSON(){return eu}activate(e){const{layer:t}=this,{body:n,header:s}=Vi(e);let r=0,o=!1;e.bindInputEventMap(JL);const a=()=>Vo.value&sf.ALT?2:1,l=h=>{r!==h&&(r=h,o=!1,c())},c=()=>{Me(n);const h=document.createElement("span");switch(r){case 0:s.textContent="Select/Deselect segments",h.textContent=`${tu} to select segments; alt+${tu} to deselect segments.`;break;case 1:case 2:s.textContent=`${r===1?"Select":"Deselect"} segments`,h.textContent=`Drag to ${r===1?"select":"deselect"} segments (${t.displayState.segmentationGroupState.value.visibleSegments.size} selected).`}n.appendChild(h)};c();const d=()=>{if(r===0)return;const{segmentSelectionState:h}=t.displayState;if(h.hasSelectedSegment){const p=h.selectedSegment,{selectedSegments:m,visibleSegments:g}=t.displayState.segmentationGroupState.value;switch(r){case 1:m.add(p),g.add(p);break;case 2:m.delete(p);break}}};e.registerDisposer(t.displayState.segmentSelectionState.changed.add(()=>{o&&d()})),e.registerDisposer(t.displayState.segmentationGroupState.value.visibleSegments.changed.add(c)),e.registerDisposer(Vo.changed.add(()=>{r!==0&&l(a())}));const u=(h,p)=>{h.stopPropagation(),l(p),d();const m=h.detail.screenX,g=h.detail.screenY;zt(h.detail,(v,y,S)=>{if(!o){const w=v.screenX-m,b=v.screenY-g;w*w+b*b>25&&(d(),o=!0)}},v=>{o=!1,l(0)})};e.bindAction("drag-select-segments",h=>u(h,a()))}get description(){return"select"}}function QL(i){sn(i,eu,e=>new YL(e))}/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const nu="mergeSegments",iu="splitSegments",KL=Ae.fromObject({"at:shift?+mousedown0":{action:"merge-segments"},"at:shift?+mousedown2":{action:"set-anchor"}}),qL=Ae.fromObject({"at:shift?+mousedown0":{action:"split-segments"},"at:shift?+alt+mousedown0":{action:"split-and-select-segments"},"at:shift?+mousedown2":{action:"set-anchor"}});class XL extends gi{constructor(e){super(e),this.lastAnchorBaseSegment=new _.B0(void 0);const t=()=>{const n=e.anchorSegment.value;if(n===void 0)return;const{segmentSelectionState:s}=e.displayState;if(!s.hasSelectedSegment)return;const{segmentEquivalences:r}=e.displayState.segmentationGroupState.value,o=r.get(n);if(!P.R.equal(s.selectedSegment,o))return;const a=s.baseSelectedSegment,l=(0,Rt.YR)(a),c=r.disjointSets.visibleSegmentEquivalencePolicy.value;c&Rt.y6.NONREPRESENTATIVE_EXCLUDED&&l||c&Rt.y6.REPRESENTATIVE_EXCLUDED&&!l||(this.lastAnchorBaseSegment.value=a.clone())};this.registerDisposer(e.displayState.segmentSelectionState.changed.add(t)),this.registerDisposer(e.anchorSegment.changed.add(t))}toJSON(){return nu}activate(e){const t=this.layer.displayState.segmentationGroupState.value,n=()=>{const c=this.layer.anchorSegment.value,d=this.lastAnchorBaseSegment.value;if(c===void 0)return{anchorSegment:void 0,error:"Select anchor segment for merge"};const u=t.segmentEquivalences.get(c);return t.visibleSegments.has(u)?d===void 0||!P.R.equal(t.segmentEquivalences.get(d),u)?{anchorSegment:c,error:"Hover over base segment within anchor segment that is closest to merge location"}:{anchorSegment:d,error:void 0}:{anchorSegment:c,error:"Anchor segment must be in visible set"}},s=()=>{const{anchorSegment:c,error:d}=n();if(c===void 0||d!==void 0)return{anchorSegment:c,error:d,otherSegment:void 0,anchorSegmentValid:!1};const{displayState:u}=this.layer,h=u.segmentSelectionState.baseValue;return h===void 0||P.R.equal(u.segmentSelectionState.selectedSegment,t.segmentEquivalences.get(c))?{anchorSegment:c,otherSegment:void 0,error:"Hover over segment to merge",anchorSegmentValid:!0}:{anchorSegment:c,otherSegment:h,error:void 0,anchorSegmentValid:!0}},{body:r,header:o}=Vi(e);o.textContent="Merge segments",r.classList.add("neuroglancer-merge-segments-status"),e.bindInputEventMap(KL),e.registerDisposer(()=>{Ur(t)});const a=()=>{Me(r);const{displayState:c}=this.layer,{anchorSegment:d,otherSegment:u,anchorSegmentValid:h,error:p}=s(),m=y=>{const S=Id(this.layer.displayState,y);return S.classList.add("neuroglancer-segment-list-entry-double-line"),S};if(d!==void 0&&r.appendChild(m(Yi(c,d))),p!==void 0){const y=document.createElement("span");y.textContent=p,r.appendChild(y)}if(u!==void 0){const y=document.createElement("span");y.textContent=" merge ",r.appendChild(y),r.appendChild(m(Yi(c,u)))}const{segmentEquivalences:g}=t;if(!h){Ur(t);return}t.useTemporaryVisibleSegments.value=!0;const v=t.temporaryVisibleSegments;v.clear(),v.add(g.get(d)),u!==void 0&&v.add(g.get(u))};a(),e.registerDisposer($r(this.layer.displayState,r));const l=e.registerCancellable((0,Qe.t)(a));Bs(this.layer.displayState,e,l),e.registerDisposer(this.layer.anchorSegment.changed.add(l)),e.registerDisposer(this.lastAnchorBaseSegment.changed.add(l)),e.bindAction("merge-segments",c=>{c.stopPropagation(),(async()=>{const{graph:{value:d}}=t;if(d===void 0)return;const{anchorSegment:u,otherSegment:h,error:p}=s();if(!(u===void 0||h===void 0||p!==void 0))try{await d.merge(u,h),pe.showTemporaryMessage("Merge performed")}catch(m){pe.showTemporaryMessage(`Merge failed: ${m}`)}})()}),e.bindAction("set-anchor",c=>{c.stopPropagation();const{segmentSelectionState:d}=this.layer.displayState,u=d.baseValue;if(u===void 0)return;const h=this.layer.anchorSegment.value;if(t.visibleSegments.add(u),h===void 0||!P.R.equal(h,u)){this.layer.anchorSegment.value=u.clone();return}})}get description(){return"merge"}}class ZL extends gi{toJSON(){return iu}activate(e){const t=this.layer.displayState.segmentationGroupState.value,n=()=>{const d=this.layer.anchorSegment.value;if(d===void 0)return{anchorSegment:void 0,error:"Select anchor segment for split"};const u=t.segmentEquivalences.get(d);return t.visibleSegments.has(u)?{anchorSegment:d,error:void 0}:{anchorSegment:d,error:"Anchor segment must be in visible set"}},{body:s,header:r}=Vi(e);r.textContent="Split segments",s.classList.add("neuroglancer-merge-segments-status"),e.bindInputEventMap(qL);const o=()=>{const{anchorSegment:d,error:u}=n();if(d===void 0||u!==void 0)return{anchorSegment:d,error:u,otherSegment:void 0,anchorSegmentValid:!1};const{displayState:h}=this.layer,p=h.segmentSelectionState.baseValue;return p===void 0||!P.R.equal(h.segmentSelectionState.selectedSegment,t.segmentEquivalences.get(d))||P.R.equal(p,d)?{anchorSegment:d,otherSegment:void 0,anchorSegmentValid:!0,error:"Hover over base segment to seed split"}:{anchorSegment:d,otherSegment:p,anchorSegmentValid:!0,error:void 0}};e.registerDisposer(()=>{Ur(t)});const a=()=>{Me(s);const{displayState:d}=this.layer,{anchorSegment:u,otherSegment:h,anchorSegmentValid:p,error:m}=o();let g,v;(()=>{const{segmentEquivalences:w}=t,{graphConnection:{value:b}}=this.layer;if(!p||b===void 0){Ur(t);return}if(t.useTemporaryVisibleSegments.value=!0,h!==void 0){const E=b.computeSplit(u,h);if(E!==void 0){g=new wi(u,E.includeRepresentative),v=new wi(h,E.excludeRepresentative),t.useTemporarySegmentEquivalences.value=!0;const D=E.includeRepresentative,I=E.excludeRepresentative,L=t.temporarySegmentEquivalences;L.clear();for(const k of E.includeBaseSegments)L.link(k,D);for(const k of E.excludeBaseSegments)L.link(k,I);const N=t.temporaryVisibleSegments;N.clear(),N.add(D),N.add(I);return}}t.useTemporarySegmentEquivalences.value=!1;const x=t.temporaryVisibleSegments;x.clear(),x.add(w.get(u))})();const S=w=>{const b=Id(this.layer.displayState,w);return b.classList.add("neuroglancer-segment-list-entry-double-line"),b};if(u!==void 0&&s.appendChild(S(g??Yi(d,u))),m!==void 0){const w=document.createElement("span");w.textContent=m,s.appendChild(w)}if(v!==void 0){const w=document.createElement("span");w.textContent=" split ",s.appendChild(w),s.appendChild(S(v))}};e.registerDisposer($r(this.layer.displayState,s)),a();const l=e.registerCancellable((0,Qe.t)(a));Bs(this.layer.displayState,e,l),e.registerDisposer(this.layer.anchorSegment.changed.add(l));const c=async d=>{const{graph:{value:u}}=t;if(u===void 0)return;const{anchorSegment:h,otherSegment:p,error:m}=o();if(!(h===void 0||p===void 0||m!==void 0))try{await u.split(h,p),d&&t.visibleSegments.add(t.segmentEquivalences.get(p)),pe.showTemporaryMessage("Split performed")}catch(g){pe.showTemporaryMessage(`Split failed: ${g}`)}};e.bindAction("split-segments",d=>{d.stopPropagation(),c(!1)}),e.bindAction("split-and-select-segments",d=>{d.stopPropagation(),c(!0)}),e.bindAction("set-anchor",d=>{d.stopPropagation();const{segmentSelectionState:u}=this.layer.displayState,h=u.baseValue;if(h===void 0)return;t.visibleSegments.add(h);const p=this.layer.anchorSegment.value;if(p===void 0||!P.R.equal(p,h)){this.layer.anchorSegment.value=h.clone();return}})}get description(){return"split"}}function eR(i){sn(i,nu,e=>new XL(e)),sn(i,iu,e=>new ZL(e))}/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const tR=new P.R;class Ey extends T.O8{constructor(e,t){super(),this.segmentationDisplayState=e,this.parentElement=t,this.changed=new j.HN,this.explicitSegmentsVisible=!1,this.debouncedUpdate=(0,Fe.A)(()=>this.update(),0)}updateRendering(e){this.segmentWidgetFactory.update(e)}updateRenderedItems(e){e.forEachRenderedItem(t=>{this.updateRendering(t)})}}class Ty extends Ey{constructor(e,t){super(e,t),this.segmentationDisplayState=e,this.parentElement=t,this.render=n=>{const{explicitSegments:s}=this,r=s[n];return this.segmentWidgetFactory.get(r)},this.update(),this.registerDisposer(e.segmentationGroupState.value.selectedSegments.changed.add(this.debouncedUpdate))}update(){const e=[],{selectedSegments:t}=this.segmentationDisplayState.segmentationGroupState.value,n=[...t],{explicitSegments:s}=this;s===void 0?e.push({retainCount:0,insertCount:n.length,deleteCount:0}):e.push(...(0,F.ak)(s,n,P.R.equal)),this.explicitSegments=n,this.length=n.length,this.changed.dispatch(e)}}class Dy extends Ey{constructor(e,t,n,s){super(n,s),this.query=e,this.segmentPropertyMap=t,this.segmentationDisplayState=n,this.parentElement=s,this.queryResult=new _.B0(void 0),this.prevQueryResult=new _.B0(void 0),this.statusText=new _.B0(""),this.selectedMatches=0,this.visibleMatches=0,this.matchStatusTextPrefix="",this.selectedSegmentsGeneration=-1,this.visibleSegmentsGeneration=-1,this.explicitSegmentsVisible=!1,this.render=r=>{const{explicitSegments:o}=this;let a;if(o!==void 0)a=o[r];else{a=tR;const l=this.queryResult.value.indices[r],{ids:c}=this.segmentPropertyMap.segmentPropertyMap.inlineProperties;a.low=c[l*2],a.high=c[l*2+1]}return this.segmentWidgetFactory.get(a)},this.update(),this.registerDisposer(n.segmentationGroupState.value.selectedSegments.changed.add(this.debouncedUpdate)),this.registerDisposer(n.segmentationGroupState.value.visibleSegments.changed.add(this.debouncedUpdate)),e&&this.registerDisposer(e.changed.add(this.debouncedUpdate))}get numMatches(){return this.queryResult.value?.count??0}update(){const e=this.query.value,{segmentPropertyMap:t}=this;this.prevQueryResult.value=this.queryResult.value;const n=this.prevQueryResult.value;let s;if(this.prevQuery===e)s=n;else{const b=mI(t,e);s=vI(t,b)}const r=[];let o=!1,a="";const l=xI(s.query);l||this.explicitSegments!==void 0&&this.explicitSegmentsVisible&&(r.push({deleteCount:this.explicitSegments.length,retainCount:0,insertCount:0}),this.explicitSegments=void 0,o=!0);const{explicitIds:c}=s;c!==void 0?this.explicitSegments=c:this.explicitSegmentsVisible||(this.explicitSegments=void 0),n!==s&&(r.push({retainCount:0,deleteCount:n?.count??0,insertCount:s.count}),o=!0,this.queryResult.value=s),s.explicitIds!==void 0?a=`${s.count} ids`:l?a=`${s.count} total ids`:s.total>0&&(a=`${s.count} match /${s.total} total ids`);const{selectedSegments:d,visibleSegments:u}=this.segmentationDisplayState.segmentationGroupState.value,h=d.changed.count,p=u.changed.count,m=this.selectedSegmentsGeneration,g=this.visibleSegmentsGeneration,v=n!==s,y=m!==h||v,S=g!==p||v;this.selectedSegmentsGeneration=h,this.visibleSegmentsGeneration=p,y&&(this.selectedMatches=s.count>0?cv(t,s,d):0),S&&(this.visibleMatches=s.count>0?cv(t,s,u):0);let w=a;this.selectedMatches>0&&(this.selectedMatches===this.visibleMatches?w=`${this.selectedMatches} vis/${w}`:this.visibleMatches>0?w=`${this.visibleMatches} vis/${this.selectedMatches} star/${w}`:w=`${this.selectedMatches} star/${w}`),this.statusText.value=w,this.prevQuery=e,this.matchStatusTextPrefix=a,this.length=s.count,o&&this.changed.dispatch(r)}}const Iy=Ae.fromObject({enter:{action:"toggle-listed"},"shift+enter":{action:"hide-listed"},"control+enter":{action:"hide-all"},escape:{action:"cancel"}});function Ly(i){$t(i,Math.max(1,i.value.length+.1))}function su(i,e){let t;if(Number.isInteger(e))t=e.toString();else{const n=e.toString(),s=e.toPrecision(6);t=n.length{t.select()}),t.classList.add(`neuroglancer-segment-query-result-numerical-plot-${i}-bound`),t.classList.add("neuroglancer-segment-query-result-numerical-plot-bound"),t.type="text",t.spellcheck=!1,t.autocomplete="off",t.title=(e===0?"Lower":"Upper")+" bound "+(i==="range"?"range":"for distribution"),t.addEventListener("input",()=>{Ly(t)}),t}function iR(i,e,t){if(i===void 0||i.indices===void 0)return;const n=i.query;let{sortBy:s,includeColumns:r}=n;Pa(n,t)?(s=s.filter(a=>a.fieldId!==t),r=r.filter(a=>a!==t)):r.push(t),e({...n,sortBy:s,includeColumns:r})}function Ry(i,e,t){const n=i?.query,s=n?.sortBy;if(s===void 0)return;const{includeColumns:r}=n,a=s.find(c=>c.fieldId===t)?.order==="<"?">":"<",l=r.filter(c=>c!==t);for(const c of s)c.fieldId!=="id"&&c.fieldId!=="label"&&c.fieldId!==t&&l.push(c.fieldId);e({...n,sortBy:[{fieldId:t,order:a}],includeColumns:l})}function ky(i,e,t){const s=i?.query?.sortBy?.find(r=>r.fieldId===t)?.order;e.textContent=s===">"?"\u25BC":"\u25B2",e.style.visibility=s===void 0?"":"visible",e.title=`Sort by ${t} in ${s==="<"?"descending":"ascending"} order`}class sR extends T.O8{constructor(e,t,n){super(),this.segmentPropertyMap=e,this.queryResult=t,this.setQuery=n,this.propertyHistograms=[],this.bounds={window:new _.B0([]),range:new _.B0([])},this.throttledUpdate=this.registerCancellable((0,la.A)(()=>this.updateHistograms(),100)),this.debouncedRender=this.registerCancellable((0,Qe.t)(()=>this.updateHistogramRenderings())),this.debouncedSetQuery=this.registerCancellable((0,Fe.A)(()=>this.setQueryFromBounds(),200));const s=e?.numericalProperties,r=[];let o;if(s!==void 0&&s.length>0){o=document.createElement("details");const a=document.createElement("summary");a.textContent=`${s.length} numerical propert${s.length>1?"ies":"y"}`,o.appendChild(a),o.classList.add("neuroglancer-segment-query-result-numerical-list");const l=this.bounds.window.value;for(let c=0,d=s.length;c{this.handleNewQueryResult()})),this.registerDisposer(this.bounds.window.changed.add(this.throttledUpdate)),this.registerDisposer(this.bounds.window.changed.add(this.debouncedRender)),this.registerDisposer(this.bounds.range.changed.add(this.debouncedRender)),this.registerDisposer(this.bounds.range.changed.add(this.debouncedSetQuery)),this.handleNewQueryResult()}setQueryFromBounds(){const e=this.queryResult.value;if(e===void 0||e.indices===void 0)return;const t=e.query,n=[],s=this.bounds.range.value,{properties:r}=this;for(let o=0,a=r.length;o0&&(s=[s[1],s[0]]);const r=Ze(n.bounds,t.window),o=this.getBounds(e),{dataType:a}=this.properties[e].property;Bt(a,r,o.window)||(this.bounds.window.value[e]=r,this.bounds.window.changed.dispatch()),Bt(a,s,o.range)||(this.bounds.range.value[e]=s,this.bounds.range.changed.dispatch())}setBound(e,t,n,s){const o=this.segmentPropertyMap.numericalProperties[n].bounds;s=Pe(o,s);const a=this.getBounds(n),l=Sr(a,e,t,s,!0);this.setBounds(n,l)}handleNewQueryResult(){const e=this.queryResult.value,{listElement:t}=this;if(t!==void 0){if(e?.indices!==void 0){const{numericalConstraints:n}=e.query,{numericalProperties:s}=this.segmentPropertyMap,r=this.bounds.range.value,o=n.length,a=s.length;r.length=a;for(let l=0;lu.id===c.fieldId);r[d]=c.bounds}}this.updateHistograms(),this.throttledUpdate.cancel()}}updateHistograms(){const e=this.queryResult.value,{listElement:t}=this;t!==void 0&&(SI(this.segmentPropertyMap,e,this.propertyHistograms,this.bounds.window.value),this.updateHistogramRenderings())}updateHistogramRenderings(){this.debouncedRender.cancel();const{listElement:e}=this;if(e===void 0)return;const{propertyHistograms:t}=this;if(t.length===0){e.style.display="none";return}e.style.display="";const{properties:n}=this;for(let s=0,r=n.length;sthis.getBounds(e),d=>this.setBounds(e,d)),o=document.createElement("span");o.classList.add("neuroglancer-segment-query-result-numerical-plot-sort");const a=document.createElement("input");a.type="checkbox",a.addEventListener("click",()=>{iR(this.queryResult.value,this.setQuery,t.id)});const l=d=>{const u=document.createElement("div");u.classList.add("neuroglancer-segment-query-result-numerical-plot-bounds"),u.classList.add(`neuroglancer-segment-query-result-numerical-plot-bounds-${d}`);const h=g=>{const v=nR(d,g);return v.addEventListener("change",()=>{if(this.bounds[d].value[e]!==void 0){try{const S=qt(t.dataType,v.value);this.setBound(d,g,e,S),this.bounds[d].changed.dispatch()}catch{}su(v,this.bounds[d].value[e][g])}}),v},p=[h(0),h(1)];let m;if(d==="range"){m=[document.createElement("div"),document.createElement("div"),document.createElement("div")],m[1].classList.add("neuroglancer-segment-query-result-numerical-plot-bound-constraint-spacer"),m[1].appendChild(a);const g=document.createElement("span");g.classList.add("neuroglancer-segment-query-result-numerical-plot-label"),g.appendChild(document.createTextNode(t.id)),g.appendChild(o),g.addEventListener("click",()=>{Ry(this.queryResult.value,this.setQuery,t.id)}),m[1].appendChild(g);const{description:v}=t;v&&(m[1].title=v),u.appendChild(m[0]),u.appendChild(p[0]);const y=document.createElement("div");y.textContent="\u2264",y.classList.add("neuroglancer-segment-query-result-numerical-plot-bound-constraint-symbol"),u.appendChild(y),u.appendChild(m[1]);const S=document.createElement("div");S.textContent="\u2264",S.classList.add("neuroglancer-segment-query-result-numerical-plot-bound-constraint-symbol"),u.appendChild(S),u.appendChild(p[1]),u.appendChild(m[2])}else u.appendChild(p[0]),u.appendChild(p[1]);return{container:u,spacers:m,inputs:p}},c={range:l("range"),window:l("window")};return n.appendChild(c.range.container),n.appendChild(s),n.appendChild(c.window.container),{property:t,controller:r,element:n,plotImg:s,boundElements:c,bounds:{window:[NaN,NaN],range:[NaN,NaN]},propertyHistogram:void 0,columnCheckbox:a,sortIcon:o}}updateNumericalPropertySummary(e,t,n){const s=t.bounds.window,r=this.bounds.window.value[e],o=t.bounds.range,a=this.bounds.range.value[e],{property:l}=t,c=this.queryResult.value,d=Pa(c?.query,l.id);if(t.columnCheckbox.checked=d,t.columnCheckbox.title=d?"Remove column from result table":"Add column to result table",ky(c,t.sortIcon,l.id),t.propertyHistogram===n&&Bt(l.dataType,s,r)&&Bt(l.dataType,o,a))return;const{histogram:u}=n,h="http://www.w3.org/2000/svg",p=document.createElementNS(h,"svg");p.setAttribute("width","1"),p.setAttribute("height","1"),p.setAttribute("preserveAspectRatio","none");const m=document.createElementNS(h,"rect"),g=re(r,a[0]),v=re(r,a[1]);m.setAttribute("x",`${g}`),m.setAttribute("y","0"),m.setAttribute("width",`${v-g}`),m.setAttribute("height","1"),m.setAttribute("fill","#4f4f4f"),p.appendChild(m);const y=u.length,S=(L,N,k)=>{const O=document.createElementNS(h,"polyline");let V="",z=0;for(let oe=L;oe{const Ke=oe/(y-2),$e=Y*(1-Ke)+Q*Ke;V+=` ${$e},${1-Se}`};L!==0&&X(L,0);let ce=0;for(let oe=L;oe{e(dv(n,r,!0,!d&&!u))}),c.title=h;const p=d||u,m=v=>{const y=v?o:i.count-o,S=document.createElement("div");if(S.classList.add("neuroglancer-segment-query-result-tag-toggle"),S.classList.add(`neuroglancer-segment-query-result-tag-${v?"include":"exclude"}`),l.appendChild(S),!p&&y===0)return;const w=v?d:u;S.appendChild(new rn({get value(){return w},set value(b){e(dv(n,r,v,b))},changed:j.$$},{text:v?"+":"-",enableTitle:`Add tag to ${v?"required":"exclusion"} set`,disableTitle:`Remove tag from ${v?"required":"exclusion"} set`,backgroundScheme:"dark"}).element)};m(!0),m(!1),l.appendChild(c);const g=document.createElement("span");g.classList.add("neuroglancer-segment-query-result-tag-count"),p||(g.textContent=o.toString()),l.appendChild(g)}return s}class Py extends T.O8{constructor(e,t){super(),this.listSource=e,this.group=t,this.element=document.createElement("div"),this.selectionStatusContainer=document.createElement("span"),this.selectionStatusMessage=document.createElement("span"),this.statusChanged=new j.IY,this.debouncedUpdateStatus=(0,Fe.A)(()=>this.updateStatus(),0);const{element:n}=this;n.style.display="contents",this.starAllButton=Bm({title:"Click to toggle star status, shift+click to unstar non-visible segments.",onClick:r=>{const o=this.starAllButton.classList.contains("neuroglancer-starred");if(r.shiftKey){const a=[];for(const l of this.group.selectedSegments)this.group.visibleSegments.has(l)||a.push(l);this.group.selectedSegments.delete(a);return}this.selectSegments(!o,!1)}}),this.copyAllSegmentsButton=Hn({title:"Copy all segment IDs",onClick:()=>{this.copySegments(!1)}}),this.copyVisibleSegmentsButton=Hn({title:"Copy visible segment IDs",onClick:()=>{this.copySegments(!0)}}),this.visibilityToggleAllButton=Vm({onClick:r=>{if(r.shiftKey){this.invertVisibility();return}this.makeSegmentsVisible(!this.visibilityToggleAllButton.classList.contains("neuroglancer-visible"))}});const{selectionStatusContainer:s}=this;this.selectionStatusMessage.classList.add("neuroglancer-segment-list-status-message"),s.classList.add("neuroglancer-segment-list-status"),s.appendChild(this.copyAllSegmentsButton),s.appendChild(this.starAllButton),s.appendChild(this.visibilityToggleAllButton),s.appendChild(this.copyVisibleSegmentsButton),s.appendChild(this.selectionStatusMessage),this.element.appendChild(s),this.registerDisposer(t.visibleSegments.changed.add(this.debouncedUpdateStatus)),this.registerDisposer(t.selectedSegments.changed.add(this.debouncedUpdateStatus)),this.registerDisposer(e.changed.add(this.debouncedUpdateStatus))}makeSegmentsVisible(e){const{visibleSegments:t}=this.group,n=Array.from(this.listSegments(!0));t.set(n,e)}invertVisibility(){const e=[],t=[],{visibleSegments:n}=this.group;for(const s of this.listSegments(!0))n.has(s)?t.push(s):e.push(s);n.set(e,!0),n.set(t,!1)}selectSegments(e,t=!1){const{selectedSegments:n,visibleSegments:s}=this.group,r=Array.from(this.listSegments(!0));(e||!t)&&n.set(r,e),t&&s.set(r,e)}copySegments(e=!1){let t=[...this.listSegments(!0)];e&&(t=t.filter(n=>this.group.visibleSegments.has(n))),t.sort(P.R.compare),mi(t.join(", "))}*listSegments(e=!1){}updateStatus(){const{listSource:e,group:t,starAllButton:n,selectionStatusMessage:s,copyAllSegmentsButton:r,copyVisibleSegmentsButton:o,visibilityToggleAllButton:a}=this;e.debouncedUpdate.flush();const{visibleSegments:l,selectedSegments:c}=t;let d=0,u=0,h=0,p="";const m=c.size,g=l.size;e instanceof Dy?(h=e.numMatches,d=e.visibleMatches,u=e.selectedMatches,p=e.statusText.value):p=`${g}/${m} visible`;const v=h?d:g,y=h?u:m,S=h||m;n.classList.toggle("neuroglancer-starred",y===S),n.classList.toggle("neuroglancer-indeterminate",y>0&&y!==S),s.textContent=p,r.title=`Copy all ${S} ${h?"matching":"starred"} segment(s)`,o.title=`Copy ${v} ${h?"visible matching":"visible"} segment(s)`,r.style.visibility=S?"visible":"hidden",o.style.visibility=v?"visible":"hidden",n.style.visibility=S?"visible":"hidden",a.style.visibility=S?"visible":"hidden";const w=v===S;a.classList.toggle("neuroglancer-visible",w);const b=v>0&&v!==S;a.classList.toggle("neuroglancer-indeterminate",b);let x;w?x=`Click to hide ${S} segment ID(s).`:x=`Click to show ${S-v} segment ID(s).`,b&&(x+=" Shift+click to invert visibility."),a.title=x,this.statusChanged.dispatch()}}class oR extends Py{constructor(e,t){super(e,t),this.listSource=e,this.group=t}listSegments(e=!1){return this.group.selectedSegments[Symbol.iterator]()}}class aR extends Py{constructor(e,t,n,s,r,o,a){super(t,n),this.listSource=t,this.segmentPropertyMap=s,this.debouncedUpdateQueryModel=a;const l=g=>{o.focus(),o.select();const v=bI(s,g);document.execCommand("insertText",!1,v),r.value=v,o.select()},c=document.createElement("div");c.classList.add("neuroglancer-segment-query-result-statistics");const d=document.createElement("div");d.classList.add("neuroglancer-segment-query-result-statistics-separator");const u=document.createElement("ul");u.classList.add("neuroglancer-segment-query-errors"),this.element.prepend(u,c,d),this.registerEventListener(o,"input",()=>{a()}),this.registerDisposer(Z(o,"cancel",()=>{o.focus(),o.select(),document.execCommand("delete"),o.blur(),o.value="",r.value=""})),this.registerDisposer(Z(o,"toggle-listed",()=>{this.toggleMatches()})),this.registerDisposer(Z(o,"hide-all",()=>{n.visibleSegments.clear()})),this.registerDisposer(Z(o,"hide-listed",()=>{a(),a.flush(),t.debouncedUpdate.flush();const{visibleSegments:g}=n;this.listSource instanceof Ty?g.clear():g.delete(Array.from(this.listSegments()))}));const h=this.registerDisposer(new sR(s,t.queryResult,l));{const{listElement:g}=h;g!==void 0&&c.appendChild(g)}const p=g=>{const v=g?.errors;if(Me(u),v!==void 0)for(const y of v){const S=document.createElement("li");S.textContent=y.message,u.appendChild(S)}};let m;(0,_.W1)(g=>{if(t.segmentWidgetFactory=new Wm(t.segmentationDisplayState,t.parentElement,y=>Pa(g?.query,y.id)),e.scrollToTop(),Me(e.header),s!==void 0){const y=t.segmentWidgetFactory.getHeader();y.container.classList.add("neuroglancer-segment-list-header");for(const S of y.propertyLabels){const{label:w,sortIcon:b,id:x}=S;w.addEventListener("click",()=>{Ry(t.queryResult.value,l,x)}),ky(g,b,x)}e.header.appendChild(y.container)}if(p(g),d.style.display="none",m?.remove(),g===void 0)return;const{query:v}=g;v.errors!==void 0||v.ids!==void 0||(m=rR(g,l),m!==void 0&&c.appendChild(m),(h.properties.length>0||m!==void 0)&&(d.style.display=""))},t.queryResult)}updateQuery(){const{listSource:e,debouncedUpdateQueryModel:t}=this;t(),t.flush(),e.debouncedUpdate.flush()}listSegments(e=!1){const{listSource:t,segmentPropertyMap:n}=this;this.updateQuery();const s=t.queryResult.value;return wI(n,s,e)}toggleMatches(){const{listSource:e}=this;this.updateQuery(),e.debouncedUpdate.flush();const t=e.queryResult.value;if(t===void 0)return;const{visibleMatches:n}=e,s=n!==t.count;return this.selectSegments(s,!0),!0}}class lR extends Gt{constructor(e){super(),this.layer=e;const{element:t}=this;t.classList.add("neuroglancer-segment-display-tab"),t.appendChild(this.registerDisposer(new Wt(e.displayState.segmentationGroupState.value.graph,(l,c,d)=>{if(l===void 0||l.tabContents)return;const u=document.createElement("div");u.className="neuroglancer-segmentation-toolbox",u.appendChild(Wn(d,e.toolBinder,{toolJson:nu,label:"Merge",title:"Merge segments"})),u.appendChild(Wn(d,e.toolBinder,{toolJson:iu,label:"Split",title:"Split segments"})),c.appendChild(u)})).element);const n=document.createElement("div");n.className="neuroglancer-segmentation-toolbox",n.appendChild(Wn(this,e.toolBinder,{toolJson:eu,label:"Select",title:"Select/Deselect segments"})),t.appendChild(n);const s=document.createElement("input");s.classList.add("neuroglancer-segment-list-query"),s.addEventListener("focus",()=>{s.select()});const r=this.registerDisposer(new yn(s,Iy));r.allShortcutsAreGlobal=!0;const{segmentQuery:o}=this.layer.displayState,a=this.registerCancellable((0,Fe.A)(()=>{o.value=s.value},200));s.autocomplete="off",s.title=Iy.describe(),s.spellcheck=!1,s.placeholder="Enter ID, name prefix or /regexp",this.registerDisposer((0,_.W1)(l=>{s.value=l},o)),this.registerDisposer((0,_.W1)(l=>{Date.now()-l<100&&(setTimeout(()=>{s.focus()},0),this.layer.segmentQueryFocusTime.value=Number.NEGATIVE_INFINITY)},this.layer.segmentQueryFocusTime)),t.appendChild(s),t.appendChild(this.registerDisposer(new Wt(e.displayState.segmentPropertyMap,(l,c,d)=>{const u=d.registerDisposer(new Dy(o,l,e.displayState,c)),h=d.registerDisposer(new Ty(e.displayState,c)),p=d.registerDisposer(new Wr({source:u,horizontalScroll:!0})),m=d.registerDisposer(new Wr({source:h,horizontalScroll:!0})),g=e.displayState.segmentationGroupState.value,v=d.registerDisposer(new aR(p,u,g,l,o,s,a));v.element.appendChild(p.element),c.appendChild(v.element);const y=d.registerDisposer(new oR(h,g));y.element.appendChild(m.element),c.appendChild(y.element);const S=()=>{const x=u.query.value!==""||u.numMatches>0,E=h.length>0||!x;v.element.style.display=x?"contents":"none",y.element.style.display=E?"contents":"none"};d.registerDisposer(v.statusChanged.add(S)),d.registerDisposer(y.statusChanged.add(S)),v.updateStatus(),y.updateStatus();const w=d.registerCancellable((0,Qe.t)(()=>{u.updateRenderedItems(p),h.updateRenderedItems(m)})),{displayState:b}=this.layer;Bs(b,d,w),d.registerDisposer(b.segmentationGroupState.value.selectedSegments.changed.add(w)),p.element.classList.add("neuroglancer-segment-list"),p.element.classList.add("neuroglancer-preview-list"),m.element.classList.add("neuroglancer-segment-list"),d.registerDisposer(e.bindSegmentListWidth(p.element)),d.registerDisposer(e.bindSegmentListWidth(m.element)),d.registerDisposer(new tn(p.element,Br())),d.registerDisposer(new tn(m.element,Br())),h.segmentWidgetFactory=new Wm(h.segmentationDisplayState,h.parentElement,x=>Pa(void 0,x.id)),m.scrollToTop(),Me(m.header)})).element)}}var zs=G(4472);/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class cR{constructor(){zs.A.initializeHead(this)}}const ru=new cR,dR=window.top===window,ou=(0,Fe.A)(()=>{if(!dR)return;const{activeElement:i}=document;if(i===null||i===document.body){const e=zs.A.front(ru);e!==null&&e.element.focus({preventScroll:!0})}});window.addEventListener("focus",()=>{ou()},!0),window.addEventListener("blur",()=>{ou()},!0);class za extends T.O8{constructor(e){super(),this.element=e,this.prev0=null,this.next0=null,this.lastFocusedElement=null,this.scheduleUpdateFocus=this.registerCancellable((0,Fe.A)(()=>{const{activeElement:t}=document,{element:n}=this;n.contains(t)||xc(t)||(t!=null&&(t===this.lastFocusedElement||t.contains(n))&&this.element.focus({preventScroll:!0}),this.lastFocusedElement=null)},0)),e.tabIndex=-1,this.registerEventListener(e,"pointerdown",t=>{t.target===e&&(this.lastFocusedElement=null,e.focus({preventScroll:!0}))}),this.registerEventListener(e,"mouseenter",()=>{this.lastFocusedElement=document.activeElement,this.scheduleUpdateFocus()}),this.registerEventListener(e,"mouseleave",()=>{this.scheduleUpdateFocus.cancel()}),zs.A.insertBefore(ru,this),this.registerEventListener(e,"focus",()=>{zs.A.pop(this),zs.A.insertAfter(ru,this)}),ou()}disposed(){zs.A.pop(this),super.disposed()}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const r2=100;let au=0;const uR=Ae.fromObject({escape:{action:"close"}});class Jr extends T.O8{constructor(){super(),this.keyMap=new Ae,this.keyMap.addParent(uR,Number.NEGATIVE_INFINITY),++au;const e=this.container=document.createElement("div");e.className="overlay";const t=this.content=document.createElement("div");this.registerDisposer(new za(t)),t.className="overlay-content",e.appendChild(t),document.body.appendChild(e),this.registerDisposer(new yn(this.container,this.keyMap)),this.registerEventListener(e,"action:close",()=>{this.dispose()}),t.focus()}disposed(){--au,document.body.removeChild(this.container),super.disposed()}}/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function Wa(i={}){return Ne({text:"?",...i})}/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class Ay extends T.O8{constructor(e){super(),this.group=e,this.element=document.createElement("div"),this.topRow=document.createElement("div"),this.label=document.createElement("label"),this.selectElement=document.createElement("select"),this.linkedLayers=document.createElement("div"),this.unlinkButton=document.createElement("button");const{element:t,label:n,topRow:s,selectElement:r,linkedLayers:o,unlinkButton:a}=this;s.appendChild(n),s.appendChild(r),s.appendChild(a),a.textContent="Unlink",a.addEventListener("click",()=>{this.group.isolate()}),t.appendChild(s),t.appendChild(o),this.updateView();const l=(0,Fe.A)(()=>this.updateView(),0);this.registerEventListener(r,"change",()=>{this.updateModel(),l()}),this.registerDisposer(this.group.changed.add(l)),this.registerDisposer(this.group.linkedLayersChanged.add(l)),this.registerDisposer(this.group.layerManager.layersChanged.add(l))}updateModel(){const e=this.selectElement.value;e===""&&this.group.root.value!==this.group.layer?this.group.isolate():this.group.linkByName(e)}updateView(){const{selectElement:e,group:t}=this,{predicate:n}=t;Me(e);const s=this.group.rootGroup.linkedLayers.size!==0;this.unlinkButton.style.display=s?"":"none";const{linkedLayers:r}=this,o=t.linkedLayers.size!==0;if(r.style.display=o?"":"none",this.unlinkButton.textContent=o?"Unlink all":"Unlink",o){this.element.style.display="",e.style.display="none",Me(r);for(const a of t.linkedLayers){const l=document.createElement("div");l.classList.add("neuroglancer-linked-layer-widget-layer");const c=No({title:"Unlink layer",onClick:()=>{this.group.getGroup(a).isolate()}});l.appendChild(c),l.appendChild(document.createTextNode(a.managedLayer.name)),r.appendChild(l)}}else{e.style.display="";const a=document.createElement("option");e.appendChild(a);let l=0;for(const c of this.group.layerManager.managedLayers){const d=c.layer;if(d!==null&&d!==t.layer&&n(d)){++l;const u=document.createElement("option"),{name:h}=c;u.textContent=h,u.value=h,e.appendChild(u)}}e.value=t.toJSON()??"",this.element.style.display=l===0?"none":""}}}var hR=G(4138);/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function Ha(i={}){return Ne({svg:hR,...i})}var o2=G(1561),pR=G(5237),Ti=G.n(pR),fR=G(2205),gR=G.n(fR);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */gR()(Ti());const mR=500;class Ja extends T.O8{constructor(e){super(),this.state=e,this.changingValue=!1,this.debouncedValueUpdater=(0,Fe.A)(()=>{this.changingValue=!0;try{this.state.fragmentMain.value=this.textEditor.getValue()}finally{this.changingValue=!1}},mR),this.textEditor=Ti()(s=>{},{value:this.state.fragmentMain.value,mode:"glsl",gutters:["CodeMirror-lint-markers"]}),this.textEditor.on("change",()=>{this.setValidState(void 0),this.debouncedValueUpdater()}),this.registerDisposer(this.state.fragmentMain.changed.add(()=>{this.changingValue||this.textEditor.setValue(this.state.fragmentMain.value)})),this.element.classList.add("neuroglancer-shader-code-widget"),this.registerDisposer(this.state.shaderError.changed.add(()=>{this.updateErrorState()}));const{shaderControlState:t}=this.state;t!==void 0&&this.registerDisposer(t.parseErrors.changed.add(()=>{this.updateErrorState()})),this.updateErrorState();const n=new IntersectionObserver(s=>{s.some(r=>r.isIntersecting)&&this.textEditor.refresh()},{root:document.body});n.observe(this.element),this.registerDisposer(()=>n.disconnect())}get element(){return this.textEditor.getWrapperElement()}updateErrorState(){const{sourceStringNumber:e=1}=this.state,t=this.state.shaderError.value;let n;const{shaderControlState:s}=this.state;s!==void 0?n=s.parseErrors.value:n=[],t===void 0&&n.length===0?this.setValidState(void 0):t!=null||n.length!==0?(this.textEditor.setOption("lint",{getAnnotations:()=>{const r=[];for(const o of n)r.push({message:o.message,severity:"error",from:Ti().Pos(o.line)});if(t!=null)if(t.name==="ShaderCompilationError")for(const o of t.errorMessages)r.push({message:o.message,severity:"error",from:Ti().Pos(o.file===e&&o.line||0)});else t.name==="ShaderLinkError"?r.push({message:t.log,severity:"error",from:Ti().Pos(0)}):r.push({message:t.message,severity:"error",from:Ti().Pos(0)});return r}}),this.setValidState(!1)):(this.textEditor.setOption("lint",void 0),this.setValidState(!0))}setValidState(e){const{element:t}=this;t.classList.remove("invalid-input"),t.classList.remove("valid-input"),e===!0?t.classList.add("valid-input"):e===!1&&t.classList.add("invalid-input")}disposed(){this.debouncedValueUpdater.flush(),this.debouncedValueUpdater=void 0,at(this.element),this.textEditor=void 0,super.disposed()}}/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function vR(i){return{makeControl:(e,t,n)=>{const{watchableValue:s,channelCoordinateSpaceCombiner:r,dataType:o,defaultChannel:a,histogramSpecifications:l,legendShaderOptions:c,histogramIndex:d}=i(e);if(r!==void 0&&a.length!==0){const h=t.registerDisposer(new ui(r.combined)),p=t.registerDisposer(new xs(h,r,{copyButton:!1}));t.registerDisposer(h.changed.add(()=>{const g=h.value,v=Array.from(g,S=>Math.floor(S)),y=s.value;(0,F.r1)(y.channel,v)||(s.value={...s.value,channel:v})}));const m=()=>{const g=h.value,v=s.value;(0,F.r1)(g,v.channel)||(g.set(v.channel),h.changed.dispatch())};m(),t.registerDisposer(s.changed.add(m)),n.labelContainer.appendChild(p.element)}const u=t.registerDisposer(new bf(n.visibility,n.display,o,s,l,d,a.length===0?c:void 0));return{control:u,controlElement:u.element}},activateTool:(e,t)=>{Cf(e,t)}}}/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function yR(i){return{makeControl:(e,t,n)=>{const{watchableValue:s,properties:r,histogramSpecifications:o,legendShaderOptions:a,histogramIndex:l}=i(e);{const h=document.createElement("select");for(const[g,v]of r){const y=document.createElement("option");y.textContent=`${g} (${R[v].toLowerCase()})`,y.value=g,h.appendChild(y)}const p=()=>{const g=h.value,v=r.get(g),{window:y,range:S}=s.value;s.value={window:y!==void 0?Ce(y,v):void 0,range:S!==void 0?Ce(S,v):void 0,property:g,dataType:v}},m=()=>{h.value=s.value.property};t.registerEventListener(h,"change",p),t.registerDisposer(s.changed.add(m)),m(),n.labelContainer.appendChild(h)}const c={changed:s.changed,get value(){let{dataType:h,window:p,range:m}=s.value;return m===void 0&&(m=he[h]),{window:st(p??m),range:m}},set value(h){const{window:p,range:m}=h;s.value={...s.value,window:p,range:m}}},d=(0,_.Uq)(h=>h.dataType,[s]),u=t.registerDisposer(new Cx(n.visibility,n.display,d,c,o,l,a));return{control:u,controlElement:u.element}},activateTool:(e,t)=>{Cf(e,t)}}}/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function My(i,e){const{shaderControlState:t}=i,n=t.state.get(e);if(n===void 0)return;const{control:s}=n;switch(s.type){case"slider":return Yn(()=>({value:n.trackable,options:{min:s.min,max:s.max,step:s.step}}));case"color":return am(()=>n.trackable);case"checkbox":return Nr(()=>n.trackable);case"imageInvlerp":return vR(()=>({dataType:s.dataType,defaultChannel:s.default.channel,watchableValue:n.trackable,channelCoordinateSpaceCombiner:t.channelCoordinateSpaceCombiner,histogramSpecifications:t.histogramSpecifications,histogramIndex:r(),legendShaderOptions:i.legendShaderOptions}));case"propertyInvlerp":return yR(()=>({properties:s.properties,watchableValue:n.trackable,histogramSpecifications:t.histogramSpecifications,histogramIndex:r(),legendShaderOptions:i.legendShaderOptions}));case"transferFunction":return eE(()=>({dataType:s.dataType,watchableValue:n.trackable,channelCoordinateSpaceCombiner:t.channelCoordinateSpaceCombiner,defaultChannel:s.default.channel,histogramSpecifications:t.histogramSpecifications,histogramIndex:r()}))}function r(o=s.type){const a=c=>{if(o==="imageInvlerp"||o==="transferFunction")return c==="imageInvlerp"||c==="transferFunction";if(o==="propertyInvlerp")return c==="propertyInvlerp";throw new Error(`${o} does not support histogram index.`)};let l=0;for(const[c,{control:{type:d}}]of t.state){if(c===e)break;a(d)&&l++}return l}}function Ny(i,e,t){return{label:t,toolJson:SR(t,e),makeControl:(n,s,r)=>{const o=i(n);return My(o,t).makeControl(n,s,r)},activateTool:(n,s)=>{const r=i(n.tool.layer);return My(r,t).activateTool(n,s)}}}class ja extends Gt{constructor(e,t,n,s={}){super(s.visibility),this.state=e,this.display=t,this.layer=n,this.options=s,this.controlDisposer=void 0;const{toolId:r=Oy}=s;this.toolId=r;const{element:o}=this;o.style.display="contents";const{controls:a}=e;this.registerDisposer(a.changed.add(this.registerCancellable((0,Fe.A)(()=>this.updateControls(),0)))),this.updateControls()}updateControls(){const{element:e}=this;this.controlDisposer!==void 0&&(this.controlDisposer.dispose(),Me(e));const t=this.controlDisposer=new T.O8,n=()=>({shaderControlState:this.state,legendShaderOptions:this.options.legendShaderOptions});for(const s of this.state.state.keys())e.appendChild(fa(t,this.layer,this.visibility,Ny(n,this.toolId,s)))}disposed(){this.controlDisposer?.dispose(),super.disposed()}}const Oy="shaderControl",_y="control";function SR(i,e){return{type:e,[_y]:i}}class bR extends im{constructor(e,t,n,s){super(e,Ny(()=>t,n,s)),this.layerShaderControls=t,this.control=s,this.registerDisposer(t.shaderControlState.controls.changed.add(this.registerCancellable((0,Fe.A)(()=>{t.shaderControlState.state.get(s)===void 0&&this.unbind()}))))}activate(e){const{shaderControlState:t}=this.layerShaderControls;t.state.get(this.control)!==void 0&&super.activate(e)}}function Ya(i,e,t=Oy){sn(i,t,(n,s)=>{const r=(0,f.cQ)(s,_y,f.zr);return new bR(n,e(n),t,r)})}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function Vy(i){return new Ja({fragmentMain:i.displayState.skeletonRenderingOptions.shader,shaderError:i.displayState.shaderError,shaderControlState:i.displayState.skeletonRenderingOptions.shaderControlState})}class CR extends Gt{constructor(e){super(),this.layer=e;const{element:t}=this;t.classList.add("neuroglancer-segmentation-rendering-tab");{const s=this.registerDisposer(new Ay(e.displayState.linkedSegmentationGroup));s.label.textContent="Linked to: ",t.appendChild(s.element)}{const s=this.registerDisposer(new Ay(e.displayState.linkedSegmentationColorGroup));s.label.textContent="Colors linked to: ",t.appendChild(s.element)}for(const s of cm)t.appendChild(fa(this,e,this.visibility,s));const n=this.registerDisposer(new Wt(e.hasSkeletonsLayer,(s,r,o)=>{if(!s)return;const a=document.createElement("div");a.className="neuroglancer-segmentation-dropdown-skeleton-shader-header";const l=document.createElement("div");l.style.flex="1",l.textContent="Skeleton shader:",a.appendChild(l),a.appendChild(Ha({title:"Show larger editor view",onClick:()=>{new wR(this.layer)}})),a.appendChild(Wa({title:"Documentation on skeleton rendering",href:"https://github.com/google/neuroglancer/blob/master/src/sliceview/image_layer_rendering.md"})),r.appendChild(a);const c=o.registerDisposer(Vy(this.layer));r.appendChild(c.element),r.appendChild(o.registerDisposer(new ja(e.displayState.skeletonRenderingOptions.shaderControlState,this.layer.manager.root.display,this.layer,{visibility:this.visibility,toolId:tm})).element),c.textEditor.refresh()},this.visibility));t.appendChild(n.element)}}class wR extends Jr{constructor(e){super(),this.layer=e,this.codeWidget=this.registerDisposer(Vy(this.layer)),this.content.classList.add("neuroglancer-segmentation-layer-skeleton-shader-overlay"),this.content.appendChild(this.codeWidget.element),this.codeWidget.textEditor.refresh()}}var xR=Object.defineProperty,ER=Object.getOwnPropertyDescriptor,TR=(i,e,t,n)=>{for(var s=n>1?void 0:n?ER(e,t):e,r=i.length-1,o;r>=0;r--)(o=i[r])&&(s=(n?o(e,t,s):o(s))||s);return n&&s&&xR(e,t,s),s};/** + * @license + * This work is a derivative of the Google Neuroglancer project, + * Copyright 2016 Google Inc. + * The Derivative Work is covered by + * Copyright 2019 Howard Hughes Medical Institute + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */let jr=class extends vo{constructor(){super(...arguments),this.hashTable=new yd,this.changed=new j.HN}get value(){return this}static makeWithCounterpart(i){const e=new jr;return e.initializeCounterpart(i),e}set_(i,e){return this.hashTable.set(i,e)}set(i,e){if(this.set_(i,e)){const{rpc:t}=this;t&&t.invoke("Uint64Map.set",{id:this.rpcId,key:i,value:e}),this.changed.dispatch(i,!0)}}has(i){return this.hashTable.has(i)}get(i,e){return this.hashTable.get(i,e)}[Symbol.iterator](){return this.hashTable.entries()}unsafeEntries(){return this.hashTable.unsafeEntries()}delete_(i){return this.hashTable.delete(i)}delete(i){if(this.delete_(i)){const{rpc:e}=this;e&&e.invoke("Uint64Map.delete",{id:this.rpcId,key:i}),this.changed.dispatch(i,!1)}}get size(){return this.hashTable.size}assignFrom(i){this.clear();for(const[e,t]of i.unsafeEntries())this.set(e,t)}clear(){if(this.hashTable.clear()){const{rpc:i}=this;i&&i.invoke("Uint64Map.clear",{id:this.rpcId}),this.changed.dispatch(null,!1)}}toJSON(){const i={};for(const[e,t]of this.hashTable.unsafeEntries())i[e.toString()]=t.toString();return i}};jr=TR([yo("Uint64Map")],jr),pt("Uint64Map.set",function(i){const e=this.get(i.id);e.set_(i.key,i.value)&&e.changed.dispatch()}),pt("Uint64Map.delete",function(i){const e=this.get(i.id);e.delete_(i.key)&&e.changed.dispatch()}),pt("Uint64Map.clear",function(i){const e=this.get(i.id);e.hashTable.clear()&&e.changed.dispatch()});/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class DR{constructor(){this.changed=new j.HN,this.data=new Map}dispose(){this.data.clear()}get size(){return this.data.size}get value(){return this}has(e){return this.data.has(BigInt(e.toString()))}add(e){const{data:t}=this;if(Array.isArray(e)){const n=[];for(let s of e){const r=BigInt(s.toString());t.has(r)||(s=s.clone(),n.push(s),t.set(r,s))}n.length!==0&&this.changed.dispatch(n,!0)}else{const n=BigInt(e.toString());if(t.has(n))return;t.set(n,e.clone()),this.changed.dispatch(e,!0)}}[Symbol.iterator](){return this.data.values()}delete(e){const{data:t}=this;if(Array.isArray(e)){const n=[];for(const s of e){const r=BigInt(s.toString());t.has(r)&&(t.delete(r),n.push(s))}n.length!==0&&this.changed.dispatch(n,!1)}else{const n=BigInt(e.toString());if(!t.has(n))return;t.delete(n),this.changed.dispatch(e,!1)}}set(e,t){t?this.add(e):this.delete(e)}clear(){this.data.size>0&&(this.data.clear(),this.changed.dispatch(null,!1))}toJSON(){return Array.from(this.data.keys(),e=>e.toString())}assignFrom(e){this.clear();const t=e.data,{data:n}=this,s=Array.from(t.values());for(const[r,o]of t)n.set(r,o);this.changed.dispatch(s,!0)}}var IR=Object.defineProperty,LR=Object.getOwnPropertyDescriptor,RR=(i,e,t,n)=>{for(var s=n>1?void 0:n?LR(e,t):e,r=i.length-1,o;r>=0;r--)(o=i[r])&&(s=(n?o(e,t,s):o(s))||s);return n&&s&&IR(e,t,s),s};/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */let qn=class extends vo{constructor(){super(...arguments),this.hashTable=new mm,this.changed=new j.HN}get value(){return this}static makeWithCounterpart(i){const e=new qn;return e.initializeCounterpart(i),e}set(i,e){e?this.add(i):this.delete(i)}reserve_(i){return this.hashTable.reserve(i)}reserve(i){if(this.reserve_(i)){const{rpc:e}=this;e&&e.invoke("Uint64Set.reserve",{id:this.rpcId,value:i})}}add_(i){let e=!1;for(const t of i)e=this.hashTable.add(t)||e;return e}add(i){const e=Array().concat(i);if(this.add_(e)){const{rpc:t}=this;t&&t.invoke("Uint64Set.add",{id:this.rpcId,value:e}),this.changed.dispatch(i,!0)}}has(i){return this.hashTable.has(i)}[Symbol.iterator](){return this.hashTable.keys()}unsafeKeys(){return this.hashTable.unsafeKeys()}delete_(i){let e=!1;for(const t of i)e=this.hashTable.delete(t)||e;return e}delete(i){const e=Array().concat(i);if(this.delete_(Array().concat(i))){const{rpc:t}=this;t&&t.invoke("Uint64Set.delete",{id:this.rpcId,value:e}),this.changed.dispatch(i,!1)}}get size(){return this.hashTable.size}clear(){if(this.hashTable.clear()){const{rpc:i}=this;i&&i.invoke("Uint64Set.clear",{id:this.rpcId}),this.changed.dispatch(null,!1)}}toJSON(){const i=new Array;for(const e of this.unsafeKeys())i.push(e.toString());return i.sort(),i}assignFrom(i){this.clear();for(const e of i.unsafeKeys())this.add(e)}};qn=RR([yo("Uint64Set")],qn),pt("Uint64Set.reserve",function(i){const e=this.get(i.id);e.reserve_(i.value)&&e.changed.dispatch()}),pt("Uint64Set.add",function(i){const e=this.get(i.id);e.add_(i.value)&&e.changed.dispatch()}),pt("Uint64Set.delete",function(i){const e=this.get(i.id);e.delete_(i.value)&&e.changed.dispatch()}),pt("Uint64Set.clear",function(i){const e=this.get(i.id);e.hashTable.clear()&&e.changed.dispatch()});/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class kR extends T.O8{constructor(e){super(),this.layer=e,this.specificationChanged=new j.HN,this.localGraph=new RI,this.visibleSegments=this.registerDisposer(qn.makeWithCounterpart(this.layer.manager.rpc)),this.selectedSegments=this.registerDisposer(new DR),this.segmentPropertyMap=new _.B0(void 0),this.graph=new _.B0(void 0),this.segmentEquivalences=this.registerDisposer(Ki.makeWithCounterpart(this.layer.manager.rpc,this.layer.registerDisposer((0,_.Uq)(r=>r?.visibleSegmentEquivalencePolicy||Rt.y6.MIN_REPRESENTATIVE,[this.graph])))),this.localSegmentEquivalences=!1,this.maxIdLength=new _.B0(1),this.hideSegmentZero=new nt(!0,!0),this.segmentQuery=new _.DN("",f.zr),this.temporaryVisibleSegments=this.layer.registerDisposer(qn.makeWithCounterpart(this.layer.manager.rpc)),this.temporarySegmentEquivalences=this.layer.registerDisposer(Ki.makeWithCounterpart(this.layer.manager.rpc,this.segmentEquivalences.disjointSets.visibleSegmentEquivalencePolicy)),this.useTemporaryVisibleSegments=this.layer.registerDisposer(ft.make(this.layer.manager.rpc,!1)),this.useTemporarySegmentEquivalences=this.layer.registerDisposer(ft.make(this.layer.manager.rpc,!1));const{specificationChanged:t}=this;this.hideSegmentZero.changed.add(t.dispatch),this.segmentQuery.changed.add(t.dispatch);const{visibleSegments:n,selectedSegments:s}=this;n.changed.add(t.dispatch),s.changed.add(t.dispatch),s.changed.add((r,o)=>{o||(r?n.delete(r):n.clear())}),n.changed.add((r,o)=>{o&&r&&s.add(r)})}restoreState(e){(0,f.MM)(e,od,t=>this.hideSegmentZero.restoreState(t)),(0,f.MM)(e,ha,t=>{this.localGraph.restoreState(t)}),(0,f.MM)(e,cd,t=>{const{segmentEquivalences:n,selectedSegments:s,visibleSegments:r}=this;(0,f.$v)(t,o=>{let a=String(o);const l=a.startsWith("!");l&&(a=a.substring(1));const c=P.R.parseString(a,10),d=n.get(c);s.add(d),l||r.add(d)})}),(0,f.MM)(e,qg,t=>this.segmentQuery.restoreState(t))}toJSON(){const e={};e[od]=this.hideSegmentZero.toJSON();const{selectedSegments:t,visibleSegments:n}=this;t.size>0?e[cd]=[...t].map(r=>n.has(r)?r.toString():"!"+r.toString()):e[cd]=[];const{segmentEquivalences:s}=this;return this.localSegmentEquivalences&&s.size>0&&(e[ha]=s.toJSON()),e[qg]=this.segmentQuery.toJSON(),e}assignFrom(e){this.maxIdLength.value=e.maxIdLength.value,this.hideSegmentZero.value=e.hideSegmentZero.value,this.selectedSegments.assignFrom(e.selectedSegments),this.visibleSegments.assignFrom(e.visibleSegments),this.segmentEquivalences.assignFrom(e.segmentEquivalences)}}class PR extends T.O8{constructor(e){super(),this.layer=e,this.specificationChanged=new j.HN,this.segmentColorHash=Sd.getDefault(),this.segmentStatedColors=this.registerDisposer(new jr),this.tempSegmentStatedColors2d=this.registerDisposer(new jr),this.segmentDefaultColor=new ne,this.tempSegmentDefaultColor2d=new _.B0(void 0),this.highlightColor=new _.B0(void 0);const{specificationChanged:t}=this;this.segmentColorHash.changed.add(t.dispatch),this.segmentStatedColors.changed.add(t.dispatch),this.tempSegmentStatedColors2d.changed.add(t.dispatch),this.segmentDefaultColor.changed.add(t.dispatch),this.tempSegmentDefaultColor2d.changed.add(t.dispatch),this.highlightColor.changed.add(t.dispatch)}restoreState(e){(0,f.MM)(e,dd,t=>this.segmentColorHash.restoreState(t)),(0,f.MM)(e,fd,t=>this.segmentDefaultColor.restoreState(t)),(0,f.MM)(e,Kg,t=>{const n=(0,f.vS)(t,s=>me(String(s)));for(const[s,r]of n){const o=P.R.parseString(String(s)),a=new P.R(Ie(r));this.segmentStatedColors.set(o,a)}})}toJSON(){const e={};e[dd]=this.segmentColorHash.toJSON(),e[fd]=this.segmentDefaultColor.toJSON();const{segmentStatedColors:t}=this;if(t.size>0){const n=e[Kg]={};for(const[s,r]of t.unsafeEntries())n[s.toString()]=Ge(tt(r.low))}return e}assignFrom(e){this.segmentColorHash.value=e.segmentColorHash.value,this.segmentStatedColors.assignFrom(e.segmentStatedColors),this.tempSegmentStatedColors2d.assignFrom(e.tempSegmentStatedColors2d),this.segmentDefaultColor.value=e.segmentDefaultColor.value,this.highlightColor.value=e.highlightColor.value}}class By extends T.O8{constructor(e,t){super(),this.linkedGroup=e,this.propertyName=t,this.value}get changed(){return this.linkedGroup.root.changed}get value(){const e=this.linkedGroup.root.value;if(e!==this.curRoot){this.curRoot=e;const t=e.displayState[this.propertyName];if(e===this.linkedGroup.layer){const{curGroupState:n}=this;n!==void 0&&(t.assignFrom(n),n.dispose())}this.curGroupState=t.addRef()}return this.curGroupState}disposed(){this.curGroupState?.dispose()}}class AR{constructor(e){this.layer=e,this.segmentSelectionState=new FD,this.selectedAlpha=zr(.5),this.saturation=zr(1),this.notSelectedAlpha=zr(0),this.hoverHighlight=new nt(!0,!0),this.silhouetteRendering=new _.DN(0,f.Zw,0),this.objectAlpha=zr(1),this.ignoreNullVisibleSet=new nt(!0,!0),this.skeletonRenderingOptions=new NI,this.shaderError=dr(),this.renderScaleHistogram=new Ps,this.renderScaleTarget=Bi(1),this.selectSegment=this.layer.selectSegment,this.transparentPickEnabled=this.layer.pick,this.baseSegmentColoring=new nt(!1,!1),this.baseSegmentHighlighting=new nt(!1,!1),this.useTempSegmentStatedColors2d=this.layer.registerDisposer(ft.make(this.layer.manager.rpc,!1)),this.filterBySegmentLabel=this.layer.filterBySegmentLabel,this.moveToSegment=t=>{this.layer.moveToSegment(t)},this.linkedSegmentationGroup=this.layer.registerDisposer(new Vg(this.layer.manager.rootLayers,this.layer,t=>t instanceof Ct,t=>t.displayState.linkedSegmentationGroup)),this.linkedSegmentationColorGroup=this.layer.registerDisposer(new Vg(this.layer.manager.rootLayers,this.layer,t=>t instanceof Ct,t=>t.displayState.linkedSegmentationColorGroup)),this.originalSegmentationGroupState=this.layer.registerDisposer(new kR(this.layer)),this.originalSegmentationColorGroupState=this.layer.registerDisposer(new PR(this.layer)),e.displayState=this,this.segmentationGroupState=this.layer.registerDisposer(new By(this.linkedSegmentationGroup,"originalSegmentationGroupState")),this.segmentationColorGroupState=this.layer.registerDisposer(new By(this.linkedSegmentationColorGroup,"originalSegmentationColorGroupState")),this.hideSegmentZero=this.layer.registerDisposer(new _.rG(this.segmentationGroupState,t=>t.hideSegmentZero)),this.segmentColorHash=this.layer.registerDisposer(new _.DY(this.segmentationColorGroupState,t=>t.segmentColorHash)),this.segmentStatedColors=this.layer.registerDisposer(new _.DY(this.segmentationColorGroupState,t=>t.segmentStatedColors)),this.tempSegmentStatedColors2d=this.layer.registerDisposer(new _.DY(this.segmentationColorGroupState,t=>t.tempSegmentStatedColors2d)),this.segmentDefaultColor=this.layer.registerDisposer(new _.DY(this.segmentationColorGroupState,t=>t.segmentDefaultColor)),this.tempSegmentDefaultColor2d=this.layer.registerDisposer(new _.DY(this.segmentationColorGroupState,t=>t.tempSegmentDefaultColor2d)),this.highlightColor=this.layer.registerDisposer(new _.DY(this.segmentationColorGroupState,t=>t.highlightColor)),this.segmentQuery=this.layer.registerDisposer(new _.rG(this.segmentationGroupState,t=>t.segmentQuery)),this.segmentPropertyMap=this.layer.registerDisposer(new _.rG(this.segmentationGroupState,t=>t.segmentPropertyMap))}}const MR=Zd(Rn);class Ct extends MR{constructor(e){super(e),this.sliceViewRenderScaleHistogram=new Ps,this.sliceViewRenderScaleTarget=Bi(1),this.graphConnection=new _.B0(void 0),this.segmentQueryFocusTime=new _.B0(Number.NEGATIVE_INFINITY),this.selectSegment=(n,s)=>{this.manager.root.selectionState.captureSingleLayerState(this,r=>(r.value=n.clone(),!0),s)},this.filterBySegmentLabel=n=>{const s=Yi(this.displayState,n),{label:r}=s;r&&this.filterSegments(r)},this.filterSegments=n=>{this.displayState.segmentationGroupState.value.segmentQuery.value=n,this.segmentQueryFocusTime.value=Date.now(),this.tabs.value="segments",this.manager.root.selectedLayer.layer=this.managedLayer},this.displayState=new AR(this),this.anchorSegment=new _.DN(void 0,n=>n===void 0?void 0:P.R.parseString(n)),this.has2dLayer=this.registerDisposer((0,_.ol)(n=>n.some(s=>s instanceof Vv),{changed:this.layersChanged,value:this.renderLayers})),this.has3dLayer=this.registerDisposer((0,_.ol)(n=>n.some(s=>s instanceof La||s instanceof Ad||s instanceof Ud||s instanceof wv),{changed:this.layersChanged,value:this.renderLayers})),this.hasSkeletonsLayer=this.registerDisposer((0,_.ol)(n=>n.some(s=>s instanceof Ud),{changed:this.layersChanged,value:this.renderLayers})),this.registerDisposer((0,_.aM)((n,s)=>{n.registerDisposer(s.specificationChanged.add(this.specificationChanged.dispatch)),this.specificationChanged.dispatch()},this.displayState.segmentationGroupState)),this.registerDisposer((0,_.aM)((n,s)=>{n.registerDisposer(s.specificationChanged.add(this.specificationChanged.dispatch)),this.specificationChanged.dispatch()},this.displayState.segmentationColorGroupState)),this.displayState.segmentSelectionState.bindTo(this.manager.layerSelectedValues,this),this.displayState.selectedAlpha.changed.add(this.specificationChanged.dispatch),this.displayState.saturation.changed.add(this.specificationChanged.dispatch),this.displayState.notSelectedAlpha.changed.add(this.specificationChanged.dispatch),this.displayState.objectAlpha.changed.add(this.specificationChanged.dispatch),this.displayState.hoverHighlight.changed.add(this.specificationChanged.dispatch),this.displayState.baseSegmentColoring.changed.add(this.specificationChanged.dispatch),this.displayState.ignoreNullVisibleSet.changed.add(this.specificationChanged.dispatch),this.displayState.skeletonRenderingOptions.changed.add(this.specificationChanged.dispatch),this.displayState.renderScaleTarget.changed.add(this.specificationChanged.dispatch),this.displayState.silhouetteRendering.changed.add(this.specificationChanged.dispatch),this.anchorSegment.changed.add(this.specificationChanged.dispatch),this.sliceViewRenderScaleTarget.changed.add(this.specificationChanged.dispatch),this.displayState.originalSegmentationGroupState.localGraph.changed.add(this.specificationChanged.dispatch),this.displayState.linkedSegmentationGroup.changed.add(()=>this.updateDataSubsourceActivations()),this.tabs.add("rendering",{label:"Render",order:-100,getter:()=>new CR(this)}),this.tabs.add("segments",{label:"Seg.",order:-50,getter:()=>new lR(this)});const t=this.registerDisposer((0,_.Uq)(n=>n===void 0,[this.displayState.segmentationGroupState.value.graph]));this.tabs.add("graph",{label:"Graph",order:-25,getter:()=>new EI(this),hidden:t}),this.tabs.default="rendering"}bindSegmentListWidth(e){return $r(this.displayState,e)}get volumeOptions(){return{volumeType:St.SEGMENTATION}}activateDataSubsources(e){const t=[],n=this.displayState.linkedSegmentationGroup.root.value===this;let s;for(const r of e){if(this.addStaticAnnotations(r))continue;const{volume:o,mesh:a,segmentPropertyMap:l,segmentationGraph:c,local:d}=r.subsourceEntry.subsource;if(o instanceof ln){switch(o.dataType){case R.FLOAT32:r.deactivate("Data type not compatible with segmentation layer");continue}r.activate(()=>r.addRenderLayer(new Vv(o,{...this.displayState,transform:r.getRenderLayerTransform(),renderScaleTarget:this.sliceViewRenderScaleTarget,renderScaleHistogram:this.sliceViewRenderScaleHistogram,localPosition:this.localPosition})),this.displayState.segmentationGroupState.value)}else a!==void 0?r.activate(()=>{const u={...this.displayState,transform:r.getRenderLayerTransform()};if(a instanceof Qi)r.addRenderLayer(new La(this.manager.chunkManager,a,u));else if(a instanceof Ra)r.addRenderLayer(new Ad(this.manager.chunkManager,a,u));else{const h=new OI(this.manager.chunkManager,a,u);r.addRenderLayer(new Ud(h.addRef())),r.addRenderLayer(new wv(h))}},this.displayState.segmentationGroupState.value):l!==void 0?n?(r.activate(()=>{}),t.push(l)):r.deactivate("Not supported on non-root linked segmentation layers"):c!==void 0?n?s!==void 0?r.deactivate("Only one segmentation graph is supported"):(s=c,r.activate(u=>{const h=c.connect(this);u.registerDisposer(()=>{h.dispose(),this.graphConnection.value=void 0});const p={...this.displayState,transform:r.getRenderLayerTransform()},m=h.createRenderLayers(this.manager.chunkManager,p,this.localPosition);this.graphConnection.value=h;for(const g of m)r.addRenderLayer(g)})):r.deactivate("Not supported on non-root linked segmentation layers"):d===As.equivalences?n?s!==void 0?r.deactivate("Only one segmentation graph is supported"):(s=this.displayState.originalSegmentationGroupState.localGraph,r.activate(u=>{this.graphConnection.value=u.registerDisposer(s.connect(this)),u.registerDisposer(()=>{this.graphConnection.value=void 0})})):r.deactivate("Not supported on non-root linked segmentation layers"):r.deactivate("Not compatible with segmentation layer")}this.displayState.originalSegmentationGroupState.segmentPropertyMap.value=fI(this.manager.chunkManager,t),this.displayState.originalSegmentationGroupState.graph.value=s}getLegacyDataSourceSpecifications(e,t,n,s){const r=super.getLegacyDataSourceSpecifications(e,t,n,s),o=(0,f.MM)(t,JT,l=>l===null?null:(0,f.zr)(l)),a=(0,f.MM)(t,jT,l=>l===null?null:(0,f.zr)(l));if(o!==void 0||a!==void 0)for(const l of r)l.enableDefaultSubsources=!1,l.subsources=new Map([["default",{enabled:!0}],["bounds",{enabled:!0}]]);return o!=null&&r.push(Pr(this.manager.dataSourceProviderRegistry.convertLegacyUrl({url:o,type:"mesh"}))),a!=null&&r.push(Pr(this.manager.dataSourceProviderRegistry.convertLegacyUrl({url:a,type:"skeletons"}))),t[ha]!==void 0&&s.find(l=>l.url===jc)===void 0&&r.push({url:jc,enableDefaultSubsources:!0,transform:{outputSpace:ki,sourceRank:0,transform:void 0,inputSpace:ki},subsources:new Map}),r}restoreState(e){super.restoreState(e),this.displayState.selectedAlpha.restoreState(e[td]),this.displayState.saturation.restoreState(e[sd]),this.displayState.notSelectedAlpha.restoreState(e[nd]),this.displayState.hoverHighlight.restoreState(e[rd]),this.displayState.objectAlpha.restoreState(e[id]),this.displayState.baseSegmentColoring.restoreState(e[ad]),this.displayState.silhouetteRendering.restoreState(e[pd]),this.displayState.ignoreNullVisibleSet.restoreState(e[ld]);const{skeletonRenderingOptions:t}=this.displayState;t.restoreState(e[pa]);const n=e[YT];n!==void 0&&t.shader.restoreState(n),this.displayState.renderScaleTarget.restoreState(e[ud]),this.anchorSegment.restoreState(e[em]),this.sliceViewRenderScaleTarget.restoreState(e[hd]);const s=(0,f.MM)(e,Xg,f.zr);s!==void 0&&this.displayState.linkedSegmentationGroup.linkByName(s);const r=(0,f.MM)(e,Zg,o=>o===!1?void 0:(0,f.zr)(o),s);r!==void 0&&this.displayState.linkedSegmentationColorGroup.linkByName(r),this.displayState.segmentationGroupState.value.restoreState(e),this.displayState.segmentationColorGroupState.value.restoreState(e)}toJSON(){const e=super.toJSON();e[td]=this.displayState.selectedAlpha.toJSON(),e[nd]=this.displayState.notSelectedAlpha.toJSON(),e[sd]=this.displayState.saturation.toJSON(),e[id]=this.displayState.objectAlpha.toJSON(),e[rd]=this.displayState.hoverHighlight.toJSON(),e[ad]=this.displayState.baseSegmentColoring.toJSON(),e[ld]=this.displayState.ignoreNullVisibleSet.toJSON(),e[pd]=this.displayState.silhouetteRendering.toJSON(),e[em]=this.anchorSegment.toJSON(),e[pa]=this.displayState.skeletonRenderingOptions.toJSON(),e[ud]=this.displayState.renderScaleTarget.toJSON(),e[hd]=this.sliceViewRenderScaleTarget.toJSON();const{linkedSegmentationGroup:t,linkedSegmentationColorGroup:n}=this.displayState;return e[Xg]=t.toJSON(),n.root.value!==t.root.value&&(e[Zg]=n.toJSON()??!1),e[ha]=this.displayState.originalSegmentationGroupState.localGraph.toJSON(),t.root.value===this&&Object.assign(e,this.displayState.segmentationGroupState.value.toJSON()),n.root.value===this&&Object.assign(e,this.displayState.segmentationColorGroupState.value.toJSON()),e}transformPickedValue(e){return e==null?e:Fm(this.displayState,e,!0)}handleAction(e,t){switch(e){case"recolor":{this.displayState.segmentationColorGroupState.value.segmentColorHash.randomize();break}case"clear-segments":{if(!this.pick.value)break;this.displayState.segmentationGroupState.value.visibleSegments.clear();break}case"select":case"star":{if(!this.pick.value)break;const{segmentSelectionState:n}=this.displayState;if(n.hasSelectedSegment){const s=n.selectedSegment,r=this.displayState.segmentationGroupState.value,o=e==="select"?r.visibleSegments:r.selectedSegments,a=!o.has(s);(a||t.segmentationToggleSegmentState===void 0)&&(t.segmentationToggleSegmentState=a),t.defer(()=>{t.segmentationToggleSegmentState===a&&o.set(s,a)})}break}}}selectionStateFromJson(e,t){super.selectionStateFromJson(e,t);const n=new P.R;let{value:s}=e;typeof s=="number"&&(s=s.toString()),typeof s!="string"||!n.tryParseString(s)?e.value=void 0:e.value=n}selectionStateToJson(e,t){const n=super.selectionStateToJson(e,t),{value:s}=e;return s instanceof wi?t?n.value={key:s.key.toString(),value:s.value?s.value.toString():void 0,label:s.label}:n.value=(s.value||s.key).toString():s instanceof P.R&&(n.value=s.toString()),n}displaySegmentationSelection(e,t,n){const{value:s}=e;let r;if((typeof s=="number"||typeof s=="string")&&(r=new P.R,!r.tryParseString(s.toString())))return!1;if(s instanceof P.R)r=s.clone();else if(s instanceof wi)r=s.key.clone();else return!1;const{displayState:o}=this,a=Yi(o,r),{segmentEquivalences:l,segmentPropertyMap:{value:c}}=this.displayState.segmentationGroupState.value,d=l.get(r),u=Id(this.displayState,a);if(Bs(o,n,n.redraw),n.registerDisposer($r(o,u)),u.classList.add("neuroglancer-selection-details-segment"),t.appendChild(u),c!==void 0){const{inlineProperties:h}=c.segmentPropertyMap;if(h!==void 0){const p=c.getSegmentInlineIndex(d);if(p!==-1){for(const m of h.properties)if(m.type!=="label"){if(m.type==="description"){const g=m.values[p];if(!g)continue;const v=document.createElement("div");v.classList.add("neuroglancer-selection-details-segment-description"),v.textContent=g,t.appendChild(v)}else if(m.type==="number"||m.type==="string"){const g=m.values[p];if(m.type==="number"?Number.isNaN(g):!g)continue;const v=document.createElement("div");v.classList.add("neuroglancer-selection-details-segment-property");const y=document.createElement("div");y.classList.add("neuroglancer-selection-details-segment-property-name"),y.textContent=m.id,m.description&&(y.title=m.description);const S=document.createElement("div");S.classList.add("neuroglancer-selection-details-segment-property-value"),S.textContent=g.toString(),v.appendChild(y),v.appendChild(S),t.appendChild(v)}}}}}return!0}displaySelectionState(e,t,n){let s=this.displaySegmentationSelection(e,t,n);return super.displaySelectionState(e,t,n)&&(s=!0),s}moveToSegment(e){for(const t of this.renderLayers){if(!(t instanceof Ad||t instanceof La))continue;const n=t.displayState.transform.value;if(n.error!==void 0)return;const{rank:s,globalToRenderLayerDimensions:r}=n,{globalPosition:o}=this.manager.root,a=new Float32Array(s),l=[];for(let d=0;d{if(i.mesh!==void 0)return{layerConstructor:Ct,priority:1}}),Ya(Ct,i=>({shaderControlState:i.displayState.skeletonRenderingOptions.shaderControlState}),tm),eR(Ct),QL(Ct);var NR=G(9580);/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function Yr(i,e=i.value){i.style.minWidth=e.length+1+"ch"}const Fy="neuroglancer-coordinate-space-transform-singleton";function Uy(i,e,t){let n;t&&(i+=.5,e+=.5),i===Number.NEGATIVE_INFINITY?n="(-\u221E,":n=`[${Math.floor(i)},`;let s;return e===Number.POSITIVE_INFINITY?s="+\u221E)":s=`${Math.floor(e)})`,{lower:n,upper:s}}const $y=Ae.fromObject({arrowup:{action:"move-up"},arrowdown:{action:"move-down"},arrowleft:{action:"move-left",preventDefault:!1},arrowright:{action:"move-right",preventDefault:!1},enter:{action:"commit"},escape:{action:"cancel"}});function Gy(){const i=document.createElement("div"),e=document.createElement("input");i.classList.add("neuroglancer-coordinate-space-transform-scale-container"),e.spellcheck=!1,e.autocomplete="off",e.size=1,e.classList.add("neuroglancer-coordinate-space-transform-scale"),i.appendChild(e);const t=document.createElement("div"),n=document.createElement("span");n.innerHTML=NR,t.appendChild(n);const s=document.createTextNode("");return t.appendChild(s),t.classList.add("neuroglancer-coordinate-space-transform-scale-suggestion"),i.appendChild(t),{cellElement:i,inputElement:e,suggestionElement:t}}function zy(i,e,t,n,s){if(e===void 0||e.scale===t&&e.unit===n)i.style.display="none";else{i.style.display="";const r=Ri(e.scale,e.unit,{elide1:!1});i.lastChild.textContent=r,i.title=`${s}${r}`}}function Wy(){const i=document.createElement("input");return i.spellcheck=!1,i.autocomplete="off",i.size=1,i.placeholder=" ",i.classList.add("neuroglancer-coordinate-space-transform-output-name"),i}function Hy(i,e,t){const n=i.map(h=>sr(h.value));if(n.includes(void 0))return!1;const s=Float64Array.from(n,h=>h.scale),r=Array.from(n,h=>h.unit),o=t.value,{scales:a,units:l,rank:c}=o;for(let h=0;hs[p]===a[p]&&r[p]===l[p]?h:Date.now()),u=Oe({valid:o.valid,rank:o.rank,scales:s,units:r,timestamps:d,ids:o.ids,names:o.names,boundingBoxes:o.boundingBoxes,coordinateArrays:o.coordinateArrays});return t.value=u,!0}function Jy(i,e,t,n){const s=new Float64Array(i.scales),r=Array.from(i.units);if(s[e]===t&&r[e]===n)return i;const o=Array.from(i.timestamps);return s[e]=t,r[e]=n,o[e]=Date.now(),{...i,scales:s,units:r,timestamps:o}}class OR extends T.O8{constructor(e,t,n){super(),this.transform=e,this.localCombiner=t,this.globalCombiner=n,this.element=document.createElement("div"),this.coefficientContainer=document.createElement("div"),this.translationContainer=document.createElement("div"),this.outputNameContainer=document.createElement("div"),this.outputScaleContainer=document.createElement("div"),this.inputNameContainer=document.createElement("div"),this.inputScaleContainer=document.createElement("div"),this.inputLowerBoundsContainer=document.createElement("div"),this.inputUpperBoundsContainer=document.createElement("div"),this.coefficientElements=[],this.inputNameElements=[],this.outputNameElements=[],this.outputScaleElements=[],this.outputScaleSuggestionElements=[],this.inputScaleSuggestionElements=[],this.inputScaleElements=[],this.inputBoundsElements=[],this.outputBoundsElements=[],this.addSourceDimensionIcon=Ne({svg:Fa,text:"S"}),this.addOutputDimensionIcon=Ne({svg:Fa,text:"V"}),this.addOutputDimensionCell=document.createElement("div"),this.addOutputDimensionInput=Wy(),this.inputScaleModified=[],this.outputScaleModified=[],this.curSourceRank=-1,this.curRank=-1,this.curTransform=void 0,this.addingSourceDimension=!1,this.resetToIdentityButton=Ne({text:"Set to identity",title:"Reset to identity transform",onClick:()=>{const{transform:L}=this,N=L.value.rank;L.transform=(0,De.DA)(Float64Array,N+1)}}),this.resetToDefaultButton=Ne({text:"Reset to default",title:"Reset to default input scales, transform, and output dimensions.",onClick:()=>{const{transform:L}=this;if(L.mutableSourceRank)return;const{defaultTransform:N}=L,{outputSpace:k}=N,O=k.ids.map(()=>fs());L.value={...N,outputSpace:{...k,ids:O}}}});const{element:s}=this,r=this.registerDisposer(new yn(s,$y));r.allShortcutsAreGlobal=!0,s.classList.add("neuroglancer-coordinate-space-transform-widget"),this.registerDisposer(new tn(s,$y));const o=(0,Qe.t)(()=>this.updateView());this.registerDisposer(e.changed.add(o));const{coefficientContainer:a,translationContainer:l,outputNameContainer:c,inputNameContainer:d,inputScaleContainer:u,inputLowerBoundsContainer:h,inputUpperBoundsContainer:p,outputScaleContainer:m,addOutputDimensionCell:g,addOutputDimensionIcon:v,addSourceDimensionIcon:y,resetToIdentityButton:S,resetToDefaultButton:w}=this;a.style.display="contents",l.style.display="contents",c.style.display="contents",d.style.display="contents",u.style.display="contents",m.style.display="contents",h.style.display="contents",p.style.display="contents";const b=document.createElement("div");b.classList.add("neuroglancer-coordinate-space-transform-widget-reset-buttons"),S.classList.add("neuroglancer-coordinate-space-transform-widget-reset-to-identity"),w.classList.add("neuroglancer-coordinate-space-transform-widget-reset-to-default"),b.appendChild(S),b.appendChild(w),s.appendChild(b);for(const[L,N]of[["source","Source dimensions"],["output","Output dimensions"],["input-lower","Lower"],["input-upper","Upper"],["input-scale","Scale"],["translation","Translation"]]){const k=document.createElement("div");k.classList.add(`neuroglancer-coordinate-space-transform-${L}-label`),k.classList.add("neuroglancer-coordinate-space-transform-label"),k.textContent=N,s.appendChild(k)}e.mutableSourceRank&&g.appendChild(y),g.appendChild(v),g.classList.add("neuroglancer-coordinate-space-transform-output-extend");const x="Embed in additional output dimension",E="Extend to additional source dimension";v.title=x,y.title=E,g.appendChild(this.addOutputDimensionInput),g.dataset.isActive="false",v.addEventListener("click",()=>{this.addingSourceDimension=!1,this.addOutputDimensionInput.title=x,this.addOutputDimensionCell.dataset.isActive="true",this.addOutputDimensionInput.focus()}),y.addEventListener("click",()=>{this.addingSourceDimension=!0,this.addOutputDimensionInput.title=E,this.addOutputDimensionCell.dataset.isActive="true",this.addOutputDimensionInput.focus()}),this.addOutputDimensionInput.addEventListener("blur",()=>{this.updateAddOutputDimensionCellStyle()}),s.appendChild(a),s.appendChild(c),s.appendChild(d),s.appendChild(u),s.appendChild(m),s.appendChild(h),s.appendChild(p),a.appendChild(l),s.addEventListener("input",L=>{const{target:N}=L;if(N instanceof HTMLInputElement){Yr(N);let k=this.inputScaleElements.indexOf(N);if(k!==-1){this.inputScaleModified[k]=!0,this.updateScaleValidity(N);return}if(k=this.outputScaleElements.indexOf(N),k!==-1){this.outputScaleModified[k]=!0,this.updateScaleValidity(N);return}if(k=this.outputNameElements.indexOf(N),k!==-1){this.updateOutputNameValidity();return}if(this.coefficientContainer.contains(N)){this.updateCoefficientValidity(N);return}}});const D=(L,N,k)=>{Z(s,L,O=>{O.stopPropagation();const V=O.target;if(!(V instanceof HTMLInputElement)||k!==0&&(V.selectionStart!==V.selectionEnd||V.selectionStart!==(k===1?V.value.length:0)))return;const z=this.getElementGridPosition(V);if(z===void 0)return;const Y=this.getElementByGridPosition(z.row+N,z.col+k);Y!==null&&(Y.focus(),O.preventDefault())})};D("move-up",-1,0),D("move-down",1,0),D("move-left",0,-1),D("move-right",0,1);const I=(L,N)=>{L.addEventListener("focusout",k=>{const{relatedTarget:O}=k;O instanceof Node&&L.contains(O)||N(k)})};I(a,()=>{this.updateModelTransform()||this.updateViewTransformCoefficients()}),I(c,()=>{this.updateModelOutputNames()||this.updateViewOutputNames()}),I(u,()=>{this.updateModelInputScales()||this.updateViewInputScales()}),I(m,()=>{this.updateModelOutputScales()||this.updateViewOutputScales()}),Z(s,"cancel",L=>{this.curTransform=void 0,this.updateView(),L.target.blur()}),Z(a,"commit",()=>{this.updateModelTransform()}),Z(c,"commit",()=>{this.updateModelOutputNames()}),Z(u,"commit",()=>{this.updateModelInputScales()}),Z(m,"commit",()=>{this.updateModelOutputScales()}),s.addEventListener("focusin",L=>{const{target:N}=L;N instanceof HTMLInputElement&&N.select()}),this.updateView()}updateWillBeDeletedAttributes(e){const{rank:t}=this.transform.value;e===void 0&&(e=new Array(t),e.fill(!1));const{coefficientElements:n,inputBoundsElements:s,inputScaleElements:r}=this;for(let o=0;ol.value),{value:{sourceRank:n,rank:s},mutableSourceRank:r}=this.transform;if(e.length!==s+1)return;const o=jl(t),a=new Array(s);a.fill(!1);for(let l=0;l<=s;++l){let c=o[l];t[l].length===0&&(r||l>=n)&&(c=!0,a[l]=!0),e[l].dataset.isValid=c.toString()}this.updateWillBeDeletedAttributes(a),this.updateAddOutputDimensionCellStyle()}updateScaleValidity(e){const t=sr(e.value)!==void 0;e.dataset.isValid=t.toString()}updateCoefficientValidity(e){const t=Number.isFinite(Number(e.value));e.dataset.isValid=t.toString()}getElementGridPosition(e){{const t=this.outputNameElements.indexOf(e);if(t!==-1)return{row:t,col:-2}}{const t=this.inputScaleElements.indexOf(e);if(t!==-1)return{row:-1,col:t}}{const t=this.coefficientElements.indexOf(e),{rank:n}=this.transform.value;if(t!==-1)return{row:t%n,col:Math.floor(t/n)}}{const t=this.outputScaleElements.indexOf(e);if(t!==-1)return{row:t,col:-1}}}getElementByGridPosition(e,t){const{rank:n}=this.transform.value;return e===-1?t<0||t>=n?null:this.inputScaleElements[t]:t===-2?e<0||e>n?null:this.outputNameElements[e]:t===-1?e<0||e>=n?null:this.outputScaleElements[e]:e<0||e>=n||t<0||t>n?null:this.coefficientElements[t*n+e]}dimensionRefCount(e){return(rr(e)?this.localCombiner:this.globalCombiner).dimensionRefCounts.get(e)||0}updateModelInputScales(){return Hy(this.inputScaleElements,this.inputScaleModified,this.transform.inputSpace)}updateModelOutputScales(){return Hy(this.outputScaleElements,this.outputScaleModified,this.transform.outputSpace)}updateModelOutputNames(){const e=this.outputNameElements.map(S=>S.value),{value:t,mutableSourceRank:n}=this.transform,{outputSpace:s,rank:r,sourceRank:o}=t;if(e.length!==r+1)return;const a=[],l=[],c=e[r].length!==0;let d=o;for(let S=0;S<=r;++S){const w=e[S];if(w.length===0){if(SUh(I,r,r+1));this.addingSourceDimension||D.push(Fh(r+1,r)),h=Oe({valid:h.valid,rank:r+1,names:[...h.names,""],ids:[...h.ids,fs()],timestamps:[...h.timestamps,Date.now()],scales:Float64Array.from([...h.scales,E]),units:[...h.units,x],boundingBoxes:D,coordinateArrays:[...h.coordinateArrays,void 0]}),p=Oe({valid:s.valid,rank:r+1,names:[...s.names,S],ids:[...s.ids,fs()],timestamps:[...s.timestamps,Date.now()],scales:Float64Array.from([...s.scales,E]),units:[...s.units,x],coordinateArrays:[...s.coordinateArrays,void 0]}),m=(0,De.Aw)(new Float64Array((r+2)**2),r+1,m,r)}m=Jh(Float64Array,m,h.rank,a,a),h=Kl(h,a),p=Kl(p,a);const g=p.ids.map((S,w)=>{const b=a[w];if(b===r)return S;const x=l[w],E=u[b];return x===E||this.dimensionRefCount(E)===1&&this.dimensionRefCount(x)===(u.includes(x)?1:0)?S:fs()}),v=p.timestamps.map((S,w)=>{const b=a[w];return b===r||l[w]===u[b]?S:Date.now()});p={...p,names:l,ids:g,timestamps:v};const y={rank:p.rank,sourceRank:d,outputSpace:p,inputSpace:h,transform:m};return this.transform.value=y,!0}updateModelTransform(){const e=this.coefficientElements,{rank:t}=this.transform.value,n=new Float64Array((t+1)**2);n[n.length-1]=1;for(let s=0;s{I.classList.add("neuroglancer-coordinate-space-transform-input"),E>=n&&I.classList.add(Fy)};{const I=document.createElement("div");I.classList.add("neuroglancer-coordinate-space-transform-input-name"),D(I),I.style.gridRowStart="sourceNames",I.style.gridColumnStart=`sourceDim ${E+1}`,y.appendChild(I),r.push(I)}{const{cellElement:I,inputElement:L,suggestionElement:N}=Gy();I.classList.add("neuroglancer-coordinate-space-transform-input-scale-container"),D(I),I.style.gridRowStart="sourceScales",I.style.gridColumnStart=`sourceDim ${E+1}`,S.appendChild(I),o.push(L),h.push(N);const k=E;N.addEventListener("click",()=>{const O=qh(this.transform,k);O!==void 0&&(this.transform.inputSpace.value=Jy(this.transform.inputSpace.value,k,O.scale,O.unit))})}{const I=document.createElement("div");D(I),I.classList.add("neuroglancer-coordinate-space-transform-input-bounds"),I.style.gridRowStart="sourceLower",I.style.gridColumnStart=`sourceDim ${E+1}`,w.appendChild(I);const L=document.createElement("div");D(L),L.classList.add("neuroglancer-coordinate-space-transform-input-bounds"),L.style.gridRowStart="sourceUpper",L.style.gridColumnStart=`sourceDim ${E+1}`,b.appendChild(L),s.push({lower:I,upper:L})}}for(let E=0;E{const{value:k}=this.transform,O=Kh(k,N);O!==void 0&&(this.transform.outputSpace.value=Jy(k.outputSpace,N,O.scale,O.unit))}),u.push(I),x.appendChild(D),d.push(L)}{const D=document.createElement("div");D.classList.add("neuroglancer-coordinate-space-transform-output-name-container"),D.style.gridRowStart=`outputDim ${E+1}`,D.style.gridColumnStart="outputNames";const I=Wy();I.title="Rebind to a different dimension",E>=n?I.title+=", or delete to remove singleton dimension":this.transform.mutableSourceRank&&(I.title+=", or delete to remove source dimension"),I.title+=". Names ending in ' or ^ indicate dimensions local to the layer; names ending in ^ indicate channel dimensions (image layers only).",c.push(I),v.appendChild(D),D.appendChild(I);const L=document.createElement("div");L.classList.add("neuroglancer-coordinate-space-transform-output-bounds"),D.appendChild(L);const N=document.createElement("div");N.classList.add("neuroglancer-coordinate-space-transform-output-bounds"),D.appendChild(N),p.push({lower:L,upper:N}),D.addEventListener("mousedown",k=>{k.target!==I&&(I.focus(),k.preventDefault())})}}c.push(this.addOutputDimensionInput),this.addOutputDimensionInput.value="",v.appendChild(this.addOutputDimensionCell),this.curSourceRank=n,this.curRank=t}updateViewInputScales(){this.ensureViewRankUpdated(),this.inputScaleModified.length=0;const{inputSpace:e,rank:t,sourceRank:n}=this.transform.value,{inputBoundsElements:s,inputNameElements:r,inputScaleElements:o,inputScaleSuggestionElements:a}=this,{names:l,scales:c,units:d,bounds:{lowerBounds:u,upperBounds:h,voxelCenterAtIntegerCoordinates:p}}=e;for(let m=0;mp?(i.style.left="",i.style.right=`${u-d.right}px`,c&&(i.style.maxWidth=h-o+"px")):(i.style.right="",i.style.left=`${d.left}px`,c&&(i.style.maxWidth=p-a+"px"))}if(n){const u=i.ownerDocument.documentElement.clientHeight,h=d.top-s,p=u-d.bottom-r;i.style.left=`${d.left}px`,i.style.width=`${d.width}px`,h>p*3?(i.style.top="",i.style.bottom=`${u-d.top}px`,l&&(i.style.maxHeight=h+"px")):(i.style.top=`${d.bottom}px`,i.style.bottom="",l&&(i.style.maxHeight=p+"px"))}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function VR(i){const e=i[Symbol.iterator](),{value:t,done:n}=e.next();if(n)return"";let s=t.length;for(;s>0;){const{value:r,done:o}=e.next();if(o)break;let a=0;for(;a0;){const e=i.match(/[:/_]+/);if(e===null){yield i;return}const t=e.index+e[0].length;yield i.substring(0,t),i=i.substring(t)}}function UR(i){const e=document.createElement("div");e.className="neuroglancer-multiline-autocomplete-completion-with-description",e.textContent=i.value;const t=document.createElement("div");return t.className="neuroglancer-multiline-autocomplete-completion-description",t.textContent=i.description||"",e.appendChild(t),e}const $R=Ae.fromObject({arrowdown:{action:"cycle-next-active-completion"},arrowup:{action:"cycle-prev-active-completion"},home:{action:"home"},end:{action:"end"},tab:{action:"choose-active-completion-or-prefix",preventDefault:!1},enter:{action:"commit"},escape:{action:"cancel",preventDefault:!1,stopPropagation:!1}}),GR=200;class zR extends T.O8{constructor(e){super(),this.element=document.createElement("div"),this.inputElement=document.createElement("span"),this.hintElement=document.createElement("span"),this.completionsVirtualList=void 0,this.onCommit=new j.HN,this.onInput=new j.HN,this.prevInputValue="",this.completionsVisible=!1,this.activeCompletionPromise=null,this.activeCompletionCancellationToken=void 0,this.hasFocus=!1,this.completionResult=null,this.dropdownContentsStale=!0,this.hasResultForDropdown=!1,this.commonPrefix="",this.completionDisabled=-1,this.activeIndex=-1,this.dropdownStyleStale=!0,this.resizeHandler=()=>{this.completionsVisible&&this.updateDropdownStyle()},this.resizeObserver=new ResizeObserver(this.resizeHandler),this.debouncedUpdateHintState=this.registerCancellable((0,Fe.A)(()=>this.updateHintState(),0)),this.completer=e.completer;const{delay:t=GR}=e,n=this.scheduleUpdateCompletions=(0,Fe.A)(()=>{const l=this.activeCompletionCancellationToken=new Je.Qi,c=this.activeCompletionPromise=this.completer(this.value,l);c!==null&&c.then(d=>{this.activeCompletionPromise===c&&(this.setCompletions(d),this.activeCompletionPromise=null)})},t);this.registerDisposer(()=>{n.cancel()});const{element:s,inputElement:r,hintElement:o}=this;s.classList.add("neuroglancer-multiline-autocomplete"),this.registerEventListener(window,"resize",this.resizeHandler),this.resizeObserver.observe(s),this.registerDisposer(()=>this.resizeObserver.unobserve(r)),r.contentEditable="true",r.spellcheck=!1,s.appendChild(document.createTextNode("\u200B")),s.appendChild(r),s.appendChild(o),r.classList.add("neuroglancer-multiline-autocomplete-input"),o.classList.add("neuroglancer-multiline-autocomplete-hint"),r.addEventListener("input",()=>{this.completionDisabled=-1,this.setValueAndSelection(this.value,this.getSelectionRange()),this.debouncedUpdateHintState()}),r.addEventListener("copy",l=>{const{clipboardData:c}=l;if(c!==null){const d=window.getSelection();d!==null&&!d.isCollapsed&&d.containsNode(r,!0)&&c.setData("text/plain",d.toString())}l.preventDefault(),l.stopPropagation()}),this.registerEventListener(document,"selectionchange",()=>{const l=this.getSelectionRange(),{completionDisabled:c}=this;l!==void 0&&l.begin===c&&l.end===c||(this.completionDisabled=-1,this.debouncedUpdateHintState())}),this.setValueAndSelection(""),this.updateHintState(),s.addEventListener("pointerdown",l=>{const{target:c}=l;if(c instanceof Node){if(r.contains(c))return;const{completionsVirtualList:d}=this;if(d?.element.contains(c))return}r===document.activeElement&&(this.moveCaretToEndOfInput(),l.stopPropagation(),l.preventDefault())}),s.addEventListener("click",()=>{r.focus()}),this.registerEventListener(this.inputElement,"focus",()=>{if(!this.hasFocus){this.hasFocus=!0,this.dropdownStyleStale=!0,this.updateDropdown();const l=document.createRange(),{childNodes:c}=r;l.setStart(r,0),c.length===0?l.setEnd(r,0):l.setEndAfter(c[c.length-1]);const d=window.getSelection();d!==null&&(d.removeAllRanges(),d.addRange(l)),this.debouncedUpdateHintState()}}),this.registerEventListener(this.inputElement,"blur",()=>{if(this.hasFocus){if(BR)return;this.hasFocus=!1,this.updateDropdown()}this.debouncedUpdateHintState();const l=window.getSelection();l!==null&&l.containsNode(this.inputElement,!0)&&l.removeAllRanges(),this.onCommit.dispatch(this.value,!1)}),this.registerEventListener(window,"resize",()=>{this.dropdownStyleStale=!0}),this.registerEventListener(window,"scroll",()=>{this.dropdownStyleStale=!0});const a=this.registerDisposer(new yn(r,$R));a.allShortcutsAreGlobal=!0,Z(r,"cycle-next-active-completion",()=>{this.cycleActiveCompletion(1)}),Z(r,"cycle-prev-active-completion",()=>{this.cycleActiveCompletion(-1)}),Z(r,"home",()=>{this.moveCaretToBeginningOfInput()}),Z(r,"end",()=>{this.moveCaretToEndOfInput()}),Z(r,"choose-active-completion-or-prefix",l=>{this.selectActiveCompletion(!0)&&l.preventDefault()}),Z(r,"commit",l=>{if(this.selectActiveCompletion(!1))l.stopPropagation();else{const c=!this.completionsVisible;this.disableCompletion(),this.hideCompletions(),this.onCommit.dispatch(this.value,c)}}),Z(r,"cancel",l=>{l.stopPropagation(),this.cancel()&&(l.detail.preventDefault(),l.detail.stopPropagation())})}disableCompletion(){const e=this.getSelectionRange();this.completionDisabled=e!==void 0&&e.end===e.begin?e.end:-1}get placeholder(){return this.inputElement.dataset.placeholder||""}set placeholder(e){this.inputElement.dataset.placeholder=e}getSelectionRange(){const e=window.getSelection();if(e===null||e.rangeCount===0)return;const t=e.getRangeAt(0),{inputElement:n}=this,s=document.createRange();s.setStart(n,0),s.setEnd(t.startContainer,t.startOffset);const r=s.toString().length,o=e.toString().length;return{begin:r,end:r+o}}setValueAndSelection(e,t=void 0){const n=this.completionDisabled!==-1;this.onInput.dispatch(e);const{inputElement:s}=this;Me(s);let r=0;const o=t!==void 0?document.createRange():void 0;let a=!0;for(const l of jy(e)){a||s.appendChild(document.createElement("wbr")),a=!1;const c=r+l.length,d=document.createTextNode(l);if(s.appendChild(d),o!==void 0){const{begin:u,end:h}=t;u>=r&&u<=c&&o.setStart(d,u-r),h>=r&&h<=c&&o.setEnd(d,h-r)}r=c}if(o!==void 0){a&&(o.setStart(s,0),o.setEnd(s,0));const l=window.getSelection();l!==null&&(l.removeAllRanges(),l.addRange(o))}this.completionDisabled=n&&t!==void 0&&t.end===t.begin?t.end:-1}shouldAttemptCompletion(){const{inputElement:e}=this;if(document.activeElement!==e)return!1;const t=this.getSelectionRange();return t!==void 0&&t.end===t.begin&&t.end!==this.completionDisabled&&t.end===this.value.length}hideCompletions(){this.cancelActiveCompletion(),this.clearCompletions(),this.hintElement.textContent=""}updateHintState(){if(this.debouncedUpdateHintState.cancel(),!this.shouldAttemptCompletion()){this.hideCompletions();return}const{value:e}=this;e!==this.prevInputValue&&(this.hideCompletions(),this.prevInputValue=e,this.scheduleUpdateCompletions())}handleDropdownClick(e){const{completionsVirtualList:t}=this;if(t===void 0)return;const n=t.element;for(let s=e.target;s instanceof HTMLElement&&s!==n;s=s.parentElement){const r=s.dataset.completionIndex;if(r!==void 0){this.selectCompletion(Number(r));break}}}cycleActiveCompletion(e){if(this.completionResult===null)return;let{activeIndex:t}=this;const n=this.completionResult.completions.length;t===-1?e>0?t=0:t=n-1:t=(t+e+n)%n,this.setActiveIndex(t)}shouldShowDropdown(){const{completionResult:e}=this;return e===null||!this.hasFocus?!1:this.hasResultForDropdown}updateDropdownStyle(){const{completionsVirtualList:e,element:t}=this;e!==void 0&&_R(e.element,t,{horizontal:!1}),this.dropdownStyleStale=!1}updateDropdown(){let{completionsVirtualList:e}=this;if(this.shouldShowDropdown()){if(this.dropdownContentsStale){e!==void 0&&e.dispose();const n=this.completionResult,{makeElement:s=FR}=n;e=this.completionsVirtualList=new Wr({source:{length:n.completions.length,render:r=>{const o=n.completions[r],a=s.call(n,o);return a.classList.add("neuroglancer-multiline-autocomplete-completion"),a.dataset.completionIndex=`${r}`,this.activeIndex===r&&a.classList.add(lu),a}},selectedIndex:this.activeIndex===-1?void 0:this.activeIndex}),e.element.classList.add("neuroglancer-multiline-autocomplete-dropdown"),e.element.addEventListener("mousedown",r=>{this.inputElement.focus(),r.preventDefault()}),e.element.addEventListener("mouseup",this.handleDropdownClick.bind(this)),this.element.appendChild(e.element),this.dropdownContentsStale=!1}this.dropdownStyleStale&&this.updateDropdownStyle(),this.completionsVisible||(this.completionsVisible=!0);const{activeIndex:t}=this;t!==-1&&this.completionsVirtualList.scrollItemIntoView(t)}else this.completionsVisible&&(e!==void 0&&(e.dispose(),this.completionsVirtualList=void 0,this.dropdownContentsStale=!0),this.completionsVisible=!1)}setCompletions(e){this.clearCompletions();const{completions:t}=e;if(t.length===0)return;const n=this.prevInputValue;if(n!==void 0){if(this.completionResult=e,t.length===1){const s=t[0];e.showSingleResult?this.hasResultForDropdown=!0:s.value.startsWith(n)?this.hasResultForDropdown=!1:this.hasResultForDropdown=!0,e.selectSingleResult?this.setActiveIndex(0):this.setHintValue(this.getCompletedValueByIndex(0))}else{this.hasResultForDropdown=!0;const s=VR(function*(){for(const o of e.completions)yield o.value}()),r=this.getCompletedValue(s);r.startsWith(n)&&(this.commonPrefix=r,this.setHintValue(r))}this.updateDropdown()}}setHintValue(e){const t=this.prevInputValue;if(t===void 0)return;(e===t||!e.startsWith(t))&&(e=""),e=e.substring(t.length);const{hintElement:n}=this;Me(n);let s=!0;for(const r of jy(e)){s||n.appendChild(document.createElement("wbr")),s=!1;const o=document.createTextNode(r);n.appendChild(o)}}setActiveIndex(e){if(!this.dropdownContentsStale){const{activeIndex:t}=this,{completionsVirtualList:n}=this;if(n!==void 0){if(t!==-1){const s=n.getItemElement(t);s!==void 0&&s.classList.remove(lu)}if(e!==-1){const s=n.getItemElement(e);s!==void 0&&s.classList.add(lu),n.scrollItemIntoView(e)}}}e!==-1&&this.setHintValue(this.getCompletedValueByIndex(e)),this.activeIndex=e}getCompletedValueByIndex(e){return this.getCompletedValue(this.completionResult.completions[e].value)}getCompletedValue(e){const t=this.completionResult,n=this.prevInputValue;return n===void 0?"":n.substring(0,t.offset)+e}moveCaretToBeginningOfInput(){const e=document.createRange(),{inputElement:t}=this;e.setStart(t,0),e.setEnd(t,0);const n=window.getSelection();n!==null&&(n.removeAllRanges(),n.addRange(e),this.debouncedUpdateHintState())}moveCaretToEndOfInput(){const e=document.createRange(),{inputElement:t}=this,{childNodes:n}=t,s=n[n.length-1];s===void 0?(e.setStart(t,0),e.setEnd(t,0)):(e.setStartAfter(s),e.setEndAfter(s));const r=window.getSelection();r!==null&&(r.removeAllRanges(),r.addRange(e),this.debouncedUpdateHintState())}selectActiveCompletion(e){let{activeIndex:t}=this;if(t===-1){if(!e)return!1;const{completionResult:s}=this;if(s!==null&&s.completions.length===1)t=0;else{const{commonPrefix:r}=this;return r.length>this.value.length?(this.value=r,this.moveCaretToEndOfInput(),!0):!1}}const n=this.getCompletedValueByIndex(t);return this.value===n?!1:(this.value=n,this.moveCaretToEndOfInput(),!0)}selectCompletion(e){this.value=this.getCompletedValueByIndex(e),this.moveCaretToEndOfInput()}cancel(){return!1}cancelActiveCompletion(){this.prevInputValue=void 0;const e=this.activeCompletionCancellationToken;e!==void 0&&e.cancel(),this.activeCompletionCancellationToken=void 0,this.activeCompletionPromise=null}clearCompletions(){if(this.completionResult!==null){this.activeIndex=-1,this.completionResult=null,this.dropdownContentsStale=!0,this.dropdownStyleStale=!0,this.commonPrefix="";const{completionsVirtualList:e}=this;e!==void 0&&(e.dispose(),this.completionsVirtualList=void 0),this.updateDropdown()}}get value(){return this.inputElement.textContent||""}set value(e){e!==this.value&&(this.completionDisabled=-1,this.setValueAndSelection(e),this.debouncedUpdateHintState())}disposed(){const{completionsVirtualList:e}=this;e!==void 0&&e.dispose(),at(this.element),this.cancelActiveCompletion(),super.disposed()}}/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class WR extends zR{constructor(e){const{manager:t}=e.source.layer,n=(r,o)=>t.dataSourceProviderRegistry.completeUrl({url:r,chunkManager:t.chunkManager,cancellationToken:o}).then(a=>({completions:a.completions,makeElement:UR,offset:a.offset,showSingleResult:!0}));super({completer:n,delay:0}),this.placeholder="Data source URL",this.dataSourceView=e,this.element.classList.add("neuroglancer-layer-data-source-url-input"),this.dirty=new _.B0(!1);const s=r=>{r!==this.dataSourceView.source.spec.url&&(this.dirty.value=!0)};s(""),this.onInput.add(s)}cancel(){return this.value=this.dataSourceView.source.spec.url,this.dirty.value=!1,this.inputElement.blur(),!0}}class cu extends T.O8{constructor(e){super(),this.model=e,this.element=document.createElement("ul"),this.generation=-1,this.element.classList.add("neuroglancer-layer-data-sources-source-messages");const t=this.registerCancellable((0,Qe.t)(()=>this.updateView()));this.registerDisposer(e.changed.add(t)),this.registerDisposer(()=>at(this.element)),this.updateView()}updateView(){const{model:e}=this,t=e.changed.count;if(t===this.generation)return;this.generation=t;const{element:n}=this;Me(n);const s=new Set;for(const r of e){const o=`${r.severity} ${r.message}`;if(s.has(o))continue;s.add(o);const a=document.createElement("li");n.appendChild(a),a.classList.add("neuroglancer-message"),a.classList.add(`neuroglancer-message-${Tn[r.severity]}`),a.textContent=r.message}}}class HR extends T.O8{constructor(e,t){super(),this.loadedSubsource=t,this.element=document.createElement("div");const{element:n}=this;n.classList.add("neuroglancer-layer-data-source-subsource");const s=document.createElement("label"),r=document.createElement("span"),o=()=>{s.dataset.isActive=(t.activated!==void 0||!t.enabled).toString()};o(),this.registerDisposer(t.isActiveChanged.add(o)),this.registerDisposer(e.enabledSubsourcesChanged.add(o));const a=this.registerDisposer(new pn({get value(){return t.enabled},set value(m){t.enabled=m,e.enableDefaultSubsources=!1,e.enabledSubsourcesChanged.dispatch()},changed:e.enabledSubsourcesChanged}));s.classList.add("neuroglancer-layer-data-sources-info-line"),s.appendChild(a.element);const l=document.createElement("span");l.classList.add("neuroglancer-layer-data-sources-source-id");const{id:c}=t.subsourceEntry;c!=="default"&&(l.textContent=c),s.appendChild(l),r.classList.add("neuroglancer-layer-data-sources-source-type");const d=this.registerDisposer(new cu(this.loadedSubsource.messages));n.appendChild(s),s.appendChild(r),n.appendChild(d.element);let u="";const{subsource:h}=t.subsourceEntry,{volume:p}=h;if(p instanceof ln)u=`${R[p.dataType].toLowerCase()} volume`;else if(h.mesh instanceof Qi)u="meshes (single-res.)";else if(h.mesh instanceof Ra)u="meshes (multi-res.)";else if(h.mesh instanceof Oa)u="skeletons";else if(h.segmentPropertyMap!==void 0)u="segment property map";else if(h.local!==void 0)switch(h.local){case As.annotations:u="Local annotations";break;case As.equivalences:u="local segmentation graph";break}else h.staticAnnotations!==void 0?u="default annotations":h.annotation!==void 0?u="annotations":h.singleMesh!==void 0?u="single mesh":h.segmentationGraph!==void 0&&(u="segmentation graph");r.textContent=u}}class JR extends T.O8{constructor(e){super(),this.source=e,this.element=document.createElement("div");const{element:t}=this,n=document.createElement("label");n.classList.add("neuroglancer-layer-data-sources-source-default"),n.appendChild(this.registerDisposer(new pn({changed:e.enabledSubsourcesChanged,get value(){return e.enableDefaultSubsources},set value(r){if(e.enableDefaultSubsources!==r){if(e.enableDefaultSubsources=r,r)for(const o of e.subsources)o.enabled=o.subsourceEntry.default;e.enabledSubsourcesChanged.dispatch()}}})).element),n.appendChild(document.createTextNode("Enable default subsource set")),n.title="Enable the default set of subsources for this data source.",t.appendChild(n);for(const r of e.subsources)t.appendChild(this.registerDisposer(new HR(e,r)).element);const{transform:s}=e;if(s.mutableSourceRank||s.value.sourceRank!==0){const r=this.registerDisposer(new OR(e.transform,e.layer.localCoordinateSpaceCombiner,e.layer.manager.root.coordinateSpaceCombiner));this.element.appendChild(r.element)}this.registerDisposer(()=>at(this.element))}}class jR extends T.O8{constructor(e,t){super(),this.tab=e,this.source=t,this.element=document.createElement("div"),this.seenGeneration=0,this.generation=-1;const n=this.urlInput=this.registerDisposer(new WR(this)),s=(o,a)=>{const{source:l}=this,c=l.spec,d=this.source.layer;if(o=d.manager.dataSourceProviderRegistry.normalizeUrl({url:o}),o!==n.value&&(n.disableCompletion(),n.setValueAndSelection(o,{begin:o.length,end:o.length})),n.dirty.value=!1,o&&o===c.url){a&&e.detectedLayerConstructor!==void 0&&Yy(l.layer);return}if(d instanceof jn)try{const u=d.manager.dataSourceProviderRegistry.suggestLayerName(o);Jg(d.managedLayer,u)}catch{}l.spec={...c,url:o}};n.onCommit.add(s);const{element:r}=this;r.classList.add("neuroglancer-layer-data-source"),r.appendChild(n.element),r.appendChild(this.registerDisposer(new cu(t.messages)).element),this.updateView()}updateView(){const e=this.source.changed.count;if(e===this.generation)return;this.generation=e,this.urlInput.value=this.source.spec.url,this.urlInput.dirty.value=!1;const{loadState:t}=this.source;let{loadedView:n}=this;if(n!==void 0){if(n.source===t)return;n.dispose(),n=this.loadedView=void 0}t instanceof Yc&&(n=this.loadedView=new JR(t),this.element.appendChild(n.element))}disposed(){const{loadedView:e}=this;e!==void 0&&e.dispose(),at(this.element),super.disposed()}}function Yy(i){if(i instanceof jn){const e=i.detectedLayerConstructor;if(e!==void 0)return Zc(i.managedLayer,e),!0}return!1}class YR extends Gt{constructor(e){super(),this.layer=e,this.generation=-1,this.sourceViews=new Map,this.addDataSourceIcon=qd({title:"Add additional data source"}),this.layerTypeDetection=document.createElement("div"),this.layerTypeElement=document.createElement("span"),this.dataSourcesContainer=document.createElement("div"),this.detectedLayerConstructor=void 0;const{element:t,dataSourcesContainer:n}=this;t.classList.add("neuroglancer-layer-data-sources-tab"),n.classList.add("neuroglancer-layer-data-sources-container");const{addDataSourceIcon:s}=this;if(s.style.alignSelf="start",s.addEventListener("click",()=>{const o=this.layer.addDataSource(void 0);this.updateView();const a=this.sourceViews.get(o);a!==void 0&&a.urlInput.inputElement.focus()}),t.appendChild(this.dataSourcesContainer),e instanceof jn){const{layerTypeDetection:o,layerTypeElement:a}=this;o.style.display="none",a.classList.add("neuroglancer-layer-data-sources-tab-type-detection-type"),o.appendChild(document.createTextNode("Create as ")),o.appendChild(a),o.appendChild(document.createTextNode(" layer")),t.appendChild(o),o.classList.add("neuroglancer-layer-data-sources-tab-type-detection"),o.addEventListener("click",()=>{Yy(e)})}const r=this.reRender=(0,Qe.t)(()=>this.updateView());this.registerDisposer(e.dataSourcesChanged.add(r)),this.registerDisposer(this.visibility.changed.add(r)),this.updateView()}updateLayerTypeDetection(){const e=(()=>{const n=this.layer;if(!(n instanceof jn))return;const s=n.detectedLayerConstructor;if(s!==void 0){for(const r of this.sourceViews.values())if(r.urlInput.dirty.value)return;return s}})();if(e===this.detectedLayerConstructor)return;const{layerTypeDetection:t}=this;if(this.detectedLayerConstructor=e,e!==void 0){const{layerTypeElement:n}=this;n.textContent=e.type,t.title=`Click here or press enter in the data source URL input box to create as ${e.type} layer`,t.style.display=""}else t.style.display="none"}disposed(){const{sourceViews:e}=this;for(const t of e.values())t.dispose();e.clear(),super.disposed()}updateView(){if(!this.visible)return;const e=this.layer.dataSourcesChanged.count;if(e!==this.generation){this.generation=e;const t=Date.now(),{sourceViews:n}=this,{layer:s}=this;function*r(){let o=!0;const{dataSources:a}=s;for(const l of a){let c=n.get(l);c===void 0&&(c=new jR(this,l),c.registerDisposer(c.urlInput.dirty.changed.add(this.reRender)),n.set(l,c)),c.seenGeneration=t,c.updateView();const d=l.spec.url;a.length===1&&d===""&&setTimeout(()=>{c.urlInput.inputElement.focus()},0),o=l.spec.url.length===0,yield c.element}o||(yield this.addDataSourceIcon)}nn(this.dataSourcesContainer,r.call(this));for(const[o,a]of n)a.seenGeneration!==t&&(a.dispose(),n.delete(o))}this.updateLayerTypeDetection()}}Ag.push({id:"source",label:"Source",order:-100,getter:i=>new YR(i)});/** + * @license + * Copyright 2018 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class QR extends T.O8{constructor(e){super(),this.ref=e,this.element=document.createElement("label"),this.selectElement=document.createElement("select"),this.registerDisposer(e);const{element:t,selectElement:n}=this;t.appendChild(n),this.updateView(),this.registerEventListener(n,"change",()=>this.updateModel()),this.registerDisposer(this.ref.changed.add((0,Fe.A)(()=>this.updateView(),0)))}updateModel(){this.ref.layerName=this.selectElement.value||void 0}updateView(){const{selectElement:e,ref:t}=this,{filter:n}=t;Me(e);const s=document.createElement("option");e.appendChild(s);for(const r of this.ref.layerManager.managedLayers)if(n(r)){const o=document.createElement("option"),{name:a}=r;o.textContent=a,o.value=a,e.appendChild(o)}e.value=t.layerName||""}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const KR="points",du="annotations",Qy="annotationProperties",Ky="annotationRelationships",qy="crossSectionAnnotationSpacing",Xy="projectionAnnotationSpacing",Zy="shader",eS="shaderControls";function qR(i,e){e!==void 0&&(0,f.$v)(e,(t,n)=>{i.add({type:Re.POINT,id:""+n,point:(0,f.f4)(t),properties:[]})})}function XR(i){const e=i.layer;return e===null||e instanceof Ct}function ZR(i){if(i===void 0)return null;const e=i.layer;return e===null||!(e instanceof Ct)?null:e.displayState}const tS="linkedSegmentationLayer",nS="filterBySegmentation",iS="ignoreNullSegmentFilter",sS="swapVisbleSegmentsOnMove";class ek extends T.O8{constructor(e,t,n){super(),this.layerManager=e,this.annotationStates=t,this.annotationDisplayState=n,this.changed=new j.IY,this.curGeneration=-1,this.wasLoading=void 0,this.map=new Map,this.registerDisposer(t.changed.add(()=>this.update())),this.registerDisposer(t.isLoadingChanged.add(()=>this.update())),this.update()}update(){const e=this.annotationStates.changed.count,t=this.annotationStates.isLoading;if(this.curGeneration===e&&t===this.wasLoading)return;this.wasLoading=t,this.curGeneration=e;const{map:n}=this;let s=!1;for(const r of this.annotationStates.relationships){let o=n.get(r);o===void 0&&(o=this.addRelationship(r),s=!0),o.seenGeneration=e}if(!t){const{relationshipStates:r}=this.annotationDisplayState;for(const[o,a]of n)a.seenGeneration!==e&&(n.delete(o),r.delete(o),s=!0)}s&&this.changed.dispatch()}addRelationship(e){const t=this.annotationDisplayState.relationshipStates.get(e),n=new zT(this.layerManager.addRef(),XR);n.registerDisposer(n.changed.add(()=>{t.segmentationState.value=n.layerName===void 0?void 0:ZR(n.layer)}));const{showMatches:s}=t,r={layerRef:n,showMatches:s,seenGeneration:-1};return n.changed.add(this.changed.dispatch),s.changed.add(this.changed.dispatch),this.map.set(e,r),r}get(e){return this.update(),this.map.get(e)}unbind(e){e.layerRef.changed.remove(this.changed.dispatch),e.showMatches.changed.remove(this.changed.dispatch)}reset(){for(const e of this.map.values())e.showMatches.reset()}toJSON(){const{map:e}=this;if(e.size===0)return{};let t;const n=[];for(const[s,r]of e){r.showMatches.value&&n.push(s);const{layerName:o}=r.layerRef;o!==void 0&&((t=t||{})[s]=o)}return n.sort(),{[tS]:t,[nS]:n.length===0?void 0:n}}restoreState(e){const{isLoading:t}=this.annotationStates;(0,f.MM)(e,tS,n=>{typeof n=="string"&&(n={segments:n}),(0,f.Rf)(n);for(const s of Object.keys(n)){const r=(0,f.zr)(n[s]);let o=this.map.get(s);if(o===void 0){if(!t)continue;o=this.addRelationship(s)}o.layerRef.layerName=r}for(const[s,r]of this.map)Object.prototype.hasOwnProperty.call(n,s)||(r.layerRef.layerName=void 0)}),(0,f.MM)(e,nS,n=>{typeof n=="boolean"&&(n=n===!0?["segments"]:[]);for(const s of(0,f.si)(n)){let r=this.map.get(s);if(r===void 0){if(!t)continue;r=this.addRelationship(s)}r.showMatches.value=!0}})}disposed(){const{map:e}=this;for(const t of e.values())this.unbind(t);e.clear(),super.disposed()}}class tk extends T.O8{constructor(e,t){super(),this.relationship=e,this.state=t,this.element=document.createElement("label"),this.seenGeneration=-1;const{element:n}=this,s=this.registerDisposer(new pn(t.showMatches)),r=new QR(t.layerRef);n.appendChild(s.element),n.appendChild(document.createTextNode(e)),n.appendChild(r.element)}}class nk extends T.O8{constructor(e){super(),this.linkedSegmentationLayers=e,this.widgets=new Map,this.element=document.createElement("div"),this.element.style.display="contents";const t=this.registerCancellable((0,Qe.t)(()=>this.updateView()));this.registerDisposer(this.linkedSegmentationLayers.annotationStates.changed.add(t)),this.updateView()}updateView(){const{linkedSegmentationLayers:e}=this,{annotationStates:t}=e,n=t.changed.count,{widgets:s}=this;function*r(){for(const o of t.relationships){let a=s.get(o);a===void 0&&(a=new tk(o,e.get(o))),a.seenGeneration=n,yield a.element}}for(const[o,a]of s)a.seenGeneration!==n&&(a.dispose(),s.delete(o));nn(this.element,r.call(this))}disposed(){super.disposed();for(const e of this.widgets.values())e.dispose()}}function uu(i){const{localAnnotations:e}=i;if(e){const t=i.manager.root.selectionState.value?.layers.find(n=>n.layer===i);if(t&&t.state.annotationId)return e.get(t.state.annotationId)}}function hu(i,e){const t=i.getReference(e.id);i.update(t,e),i.commit(t)}const rS=class Jb extends gi{constructor(e,t){super(t,!0),this.propertyIdentifier=e}get tag(){const{localAnnotations:e}=this.layer;if(e){const t=e.properties.value.find(n=>n.identifier===this.propertyIdentifier);if(t&&us(t))return t.tag}return"unknown"}activate(e){const{localAnnotations:t}=this.layer;if(!t)return;const n=uu(this.layer);if(n){const{propertyIdentifier:s}=this,r=t.properties.value.findIndex(o=>o.identifier===s);r>-1&&(n.properties[r]=1-n.properties[r],hu(t,n))}e.cancel()}toJSON(){return`${Jb.TOOL_ID}_${this.propertyIdentifier}`}get description(){return`tag ${this.tag}`}};rS.TOOL_ID="tagTool";let Ws=rS;class ik extends Gt{constructor(e){super(),this.layer=e,this.tools=new Set;const{element:t}=this;t.classList.add("neuroglancer-tags-tab");const{localAnnotations:n}=e;if(!n)return;const{properties:s}=n,r=document.createElement("div");r.classList.add("neuroglancer-tags-container"),t.appendChild(r);let o=0,a=[];const l=new ai,c=v=>(l.clearMessages(),a.includes(v)?(l.addMessage({severity:Tn.error,message:`tag: "${v}" already exists`}),!1):!0),d=v=>{const{properties:y}=v;let S=-1;for(const w of y.value){const b=w.identifier.match(/tag([\d]+)/);S++,b&&b.length>1&&(S=parseInt(b[1]))}return`tag${S+1}`},u=v=>{const{value:y}=v;v.validity.valid&&c(y)&&n.addProperty({type:"uint8",tag:y,default:0,description:void 0,identifier:d(n)})},h={length:1,render:v=>{const y=document.createElement("div");y.classList.add("neuroglancer-tag-list-entry");const S=document.createElement("input");if(S.required=!0,y.append(S),v===h.length-1){y.classList.add("add");const w=Wn(this,e.toolBinder,{toolJson:`${Ws.TOOL_ID}__invalid`});y.prepend(w),S.placeholder="Tag name",o{S.focus()},0),S.addEventListener("keyup",x=>{x.key==="Enter"&&u(S)});const b=qd({title:"Add additional tag",onClick:()=>u(S)});y.append(b),o=h.length}else{const w=n.getTagProperties()[v],{tag:b}=w,x=Wn(this,e.toolBinder,{toolJson:`${Ws.TOOL_ID}_${w.identifier}`,title:`Tag selected annotation with ${b}`});y.prepend(x),S.value=b,S.addEventListener("change",()=>{const{value:D}=S;if(!c(D)||!confirm(`Rename tag ${b} to ${D}?`)){S.value=b;return}w.tag=D,s.changed.dispatch();const I=uu(this.layer);I&&hu(n,I)});const E=Mn({title:"Delete tag",onClick:D=>{D.stopPropagation(),D.preventDefault(),confirm(`Delete tag ${b}?`)&&n.removeProperty(w.identifier);const I=uu(this.layer);I&&hu(n,I)}});E.classList.add("neuroglancer-tag-list-entry-delete"),y.append(E)}return y},changed:new j.IY},p=this.registerDisposer(new Wr({source:h}));r.appendChild(p.element);const m=this.registerDisposer(new cu(l));r.appendChild(m.element),p.body.classList.add("neuroglancer-tag-list"),p.element.classList.add("neuroglancer-tag-list-outer");const g=()=>{let v=1,y=0,S=0;const w=n.getTagProperties().map(b=>b.tag);for(const b of w)a.includes(b)?v++:S++;for(const b of a)w.includes(b)||y++;h.length=w.length+1,a=w,(y>0||S>0)&&h.changed.dispatch([{retainCount:v,deleteCount:y,insertCount:S}])};this.registerDisposer(s.changed.add(g)),g()}}const sk=Zd(Rn),pu=class wh extends sk{constructor(e){super(e),this.localAnnotationProperties=new _.B0([]),this.localAnnotationsJson=void 0,this.pointAnnotationsJson=void 0,this.tagTools=[],this.linkedSegmentationLayers=this.registerDisposer(new ek(this.manager.rootLayers,this.annotationStates,this.annotationDisplayState)),this.syncTagTools=n=>{for(const s of this.tagTools)if(!n.includes(s)){Ix(wh,`${Ws.TOOL_ID}_${s}`);for(const[r,o]of this.toolBinder.bindings.entries())o instanceof Ws&&o.propertyIdentifier===s&&this.toolBinder.deleteTool(r)}this.tagTools=this.tagTools.filter(s=>n.includes(s));for(const s of n)this.tagTools.includes(s)||(this.tagTools.push(s),sn(wh,`${Ws.TOOL_ID}_${s}`,r=>new Ws(s,r)))},this.linkedSegmentationLayers.changed.add(this.specificationChanged.dispatch),this.annotationDisplayState.ignoreNullSegmentFilter.changed.add(this.specificationChanged.dispatch),this.annotationCrossSectionRenderScaleTarget.changed.add(this.specificationChanged.dispatch),this.annotationProjectionRenderScaleTarget.changed.add(this.specificationChanged.dispatch),this.registerDisposer(this.localAnnotationProperties.changed.add(()=>{const{localAnnotations:n}=this;if(n){const s=n.getTagProperties().map(r=>r.identifier);this.syncTagTools(s)}})),this.tabs.add("rendering",{label:"Rendering",order:-100,getter:()=>new ok(this)});const t=this.registerDisposer(new _.ww(()=>this.localAnnotations===void 0,this.dataSourcesChanged));this.tabs.add("tags",{label:"Tags",order:10,getter:()=>new ik(this),hidden:t}),this.tabs.default="annotations"}disposed(){const{localAnnotations:e}=this;e!==void 0&&e.dispose(),super.disposed()}restoreState(e){const t=(0,f.MM)(e,Qy,Dh);t&&this.syncTagTools(t.filter(us).map(n=>n.identifier)),super.restoreState(e),this.linkedSegmentationLayers.restoreState(e),this.localAnnotationsJson=e[du],t&&(this.localAnnotationProperties.value=t||[]),this.localAnnotationRelationships=(0,f.MM)(e,Ky,f.si,["segments"]),this.pointAnnotationsJson=e[KR],this.annotationCrossSectionRenderScaleTarget.restoreState(e[qy]),this.annotationProjectionRenderScaleTarget.restoreState(e[Xy]),this.annotationDisplayState.ignoreNullSegmentFilter.restoreState(e[iS]),this.annotationDisplayState.swapVisibleSegmentsOnMove.restoreState(e[sS]),this.annotationDisplayState.shader.restoreState(e[Zy]),this.annotationDisplayState.shaderControls.restoreState(e[eS])}getLegacyDataSourceSpecifications(e,t,n,s){if(Object.prototype.hasOwnProperty.call(t,"source"))return super.getLegacyDataSourceSpecifications(e,t,n,s);const r=(0,f.MM)(t,"voxelSize",a=>(0,f.Xu)(new Float64Array(3),a,l=>(0,f.Mo)(l)/1e9)),o=["m","m","m"];if(r!==void 0){const a=Oe({rank:3,units:o,scales:r,names:["x","y","z"]});n===void 0?n={outputSpace:a,sourceRank:3,transform:void 0,inputSpace:a}:n={...n,inputSpace:a}}return[{url:bg,transform:n,enableDefaultSubsources:!0,subsources:new Map}]}activateDataSubsources(e){let t=!1,n;for(const s of e){const{subsourceEntry:r}=s,{local:o}=r.subsource,a=c=>n!==void 0&&(0,f.JB)(c.value)!==(0,f.JB)(n.value)?(s.deactivate("Annotation properties are not compatible"),!1):(n=c,!0);if(o===As.annotations){if(t){s.deactivate("Only one local annotations source per layer is supported");continue}if(t=!0,!a(this.localAnnotationProperties))continue;s.activate(c=>{const d=this.localAnnotations=new Ih(s.loadedDataSource.transform,this.localAnnotationProperties,this.localAnnotationRelationships);try{d.restoreState(this.localAnnotationsJson)}catch{}c.registerDisposer(()=>{d.dispose(),this.localAnnotations=void 0}),c.registerDisposer(this.localAnnotations.changed.add(()=>{this.specificationChanged.dispatch()}));try{qR(this.localAnnotations,this.pointAnnotationsJson)}catch{}this.pointAnnotationsJson=void 0,this.localAnnotationsJson=void 0;const u=new jo({localPosition:this.localPosition,transform:c.registerDisposer(Xh(this.manager.root.coordinateSpace,this.localPosition.coordinateSpace,s.loadedDataSource.transform,void 0)),source:d.addRef(),displayState:this.annotationDisplayState,dataSource:s.loadedDataSource.layerDataSource,subsourceIndex:s.subsourceIndex,subsourceId:r.id,role:li.ANNOTATION});this.addAnnotationLayerState(u,s)});continue}const{annotation:l}=r.subsource;if(l!==void 0){if(!a(l.properties))continue;s.activate(()=>{const c=new jo({localPosition:this.localPosition,transform:s.getRenderLayerTransform(),source:l,displayState:this.annotationDisplayState,dataSource:s.loadedDataSource.layerDataSource,subsourceIndex:s.subsourceIndex,subsourceId:r.id,role:li.ANNOTATION});this.addAnnotationLayerState(c,s)});continue}s.deactivate("Not compatible with annotation layer")}n&&(0,f.JB)(this.annotationDisplayState.annotationProperties.value)!==(0,f.JB)(n?.value)&&(this.registerDisposer(n.changed.add(()=>{this.annotationDisplayState.annotationProperties.value=[...n.value]})),this.annotationDisplayState.annotationProperties.value=[...n.value])}initializeAnnotationLayerViewTab(e){const t=e.registerDisposer((0,_.ol)(s=>s.some(r=>r.source instanceof Rr),this.annotationStates)),n=e.registerDisposer(new Wt(t,(s,r,o)=>{if(s){{const a=o.registerDisposer(new ga(this.annotationCrossSectionRenderScaleHistogram,this.annotationCrossSectionRenderScaleTarget));a.label.textContent="Spacing (cross section)",r.appendChild(a.element)}{const a=o.registerDisposer(new ga(this.annotationProjectionRenderScaleHistogram,this.annotationProjectionRenderScaleTarget));a.label.textContent="Spacing (projection)",r.appendChild(a.element)}}}));e.element.insertBefore(n.element,e.element.firstChild);{const s=e.registerDisposer(new pn(this.annotationDisplayState.ignoreNullSegmentFilter)),r=document.createElement("label");r.appendChild(document.createTextNode("Ignore null related segment filter")),r.title="Display all annotations if filtering by related segments is enabled but no segments are selected",r.appendChild(s.element),e.element.appendChild(r)}{const s=e.registerDisposer(new pn(this.annotationDisplayState.swapVisibleSegmentsOnMove)),r=document.createElement("label");r.appendChild(document.createTextNode("Swap visible segments when moving to annotation")),r.title="Swap visible segments when moving to annotation",r.appendChild(s.element),e.element.appendChild(r)}e.element.appendChild(e.registerDisposer(new nk(this.linkedSegmentationLayers)).element)}toJSON(){const e=super.toJSON();e[qy]=this.annotationCrossSectionRenderScaleTarget.toJSON(),e[Xy]=this.annotationProjectionRenderScaleTarget.toJSON(),this.localAnnotations!==void 0?e[du]=this.localAnnotations.toJSON():this.localAnnotationsJson!==void 0&&(e[du]=this.localAnnotationsJson),e[Qy]=tC(this.localAnnotationProperties.value);const{localAnnotationRelationships:t}=this;return e[Ky]=t.length===1&&t[0]==="segments"?void 0:t,e[iS]=this.annotationDisplayState.ignoreNullSegmentFilter.toJSON(),e[sS]=this.annotationDisplayState.swapVisibleSegmentsOnMove.toJSON(),e[Zy]=this.annotationDisplayState.shader.toJSON(),e[eS]=this.annotationDisplayState.shaderControls.toJSON(),Object.assign(e,this.linkedSegmentationLayers.toJSON()),e}};pu.type="annotation",pu.typeAbbreviation="ann";let Qr=pu;function oS(i){return new Ja({shaderError:i.annotationDisplayState.shaderError,fragmentMain:i.annotationDisplayState.shader,shaderControlState:i.annotationDisplayState.shaderControls})}class rk extends Jr{constructor(e){super(),this.layer=e,this.codeWidget=this.registerDisposer(oS(this.layer)),this.content.appendChild(this.codeWidget.element),this.codeWidget.textEditor.refresh()}}class ok extends Gt{constructor(e){super(),this.layer=e,this.codeWidget=this.registerDisposer(oS(this.layer));const{element:t}=this;t.classList.add("neuroglancer-annotation-rendering-tab"),t.appendChild(this.registerDisposer(new Wt(e.annotationDisplayState.annotationProperties,(r,o)=>{if(r===void 0||r.length===0)return;const a=document.createElement("div");o.appendChild(a),a.classList.add("neuroglancer-annotation-shader-property-list");for(const l of r){const c=document.createElement("div");c.classList.add("neuroglancer-annotation-shader-property");const d=document.createElement("span");d.classList.add("neuroglancer-annotation-shader-property-type"),d.textContent=l.type;const u=document.createElement("span");u.classList.add("neuroglancer-annotation-shader-property-identifier"),u.textContent=`prop_${l.identifier}`,c.appendChild(d),c.appendChild(u);const{description:h}=l;if(h!==void 0&&(c.title=h),us(l)){const p=document.createElement("span");p.classList.add("neuroglancer-annotation-tag-property-type"),p.textContent=`(${l.tag})`,c.appendChild(p)}a.appendChild(c)}})).element);const n=document.createElement("div");n.className="neuroglancer-segmentation-dropdown-skeleton-shader-header";const s=document.createElement("div");s.style.flex="1",s.textContent="Annotation shader:",n.appendChild(s),n.appendChild(Ha({title:"Show larger editor view",onClick:()=>{new rk(this.layer)}})),n.appendChild(Wa({title:"Documentation on annotation rendering",href:"https://github.com/google/neuroglancer/blob/master/src/annotation/rendering.md"})),t.appendChild(n),t.appendChild(this.codeWidget.element),t.appendChild(this.registerDisposer(new ja(e.annotationDisplayState.shaderControls,this.layer.manager.root.display,this.layer,{visibility:this.visibility})).element)}}$i(Qr),$i(Qr,"pointAnnotation"),da(i=>{if(i.local===As.annotations)return{layerConstructor:Qr,priority:100};if(i.annotation!==void 0)return{layerConstructor:Qr,priority:1}}),Ya(Qr,i=>({shaderControlState:i.annotationDisplayState.shaderControls}));/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */var fu=(i=>(i[i.DEFAULT=0]="DEFAULT",i[i.ADDITIVE=1]="ADDITIVE",i))(fu||{});const ak=new Map([[0,i=>{i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA)}],[1,i=>{i.blendFunc(i.SRC_ALPHA,i.ONE)}]]);function lk(i=0){return new Oi.F(fu,i)}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const aS=`#uicontrol invlerp normalized +void main() { + emitGrayscale(normalized()); +} +`;function ck(i=aS){return Co(i)}function lS(i,e){i.addFragmentCode(` +#define VOLUME_RENDERING false + +void emitRGBA(vec4 rgba) { + emit(vec4(rgba.rgb, rgba.a * uOpacity)); +} +void emitRGB(vec3 rgb) { + emit(vec4(rgb, uOpacity)); +} +void emitGrayscale(float value) { + emit(vec4(value, value, value, uOpacity)); +} +void emitTransparent() { + emit(vec4(0.0, 0.0, 0.0, 0.0)); +} +void emitIntensity(float value) { +} +`),i.addFragmentCode(Is),Ts(e,i),i.setFragmentMainFunction(ms(e.parseResult.code))}class dk extends Mv{constructor(e,t){const{opacity:n,blendMode:s,shaderControlState:r}=t;super(e,{...t,fallbackShaderParameters:new _.B0(Ho(Er(aS,{imageData:{dataType:e.dataType,channelRank:t.channelCoordinateSpace?.value?.rank??0}}))),encodeShaderParameters:o=>o.key,shaderParameters:r.builderState,dataHistogramSpecifications:r.histogramSpecifications}),this.shaderControlState=r,this.opacity=n,this.blendMode=s,this.registerDisposer(n.changed.add(this.redrawNeeded.dispatch)),this.registerDisposer(s.changed.add(this.redrawNeeded.dispatch)),this.registerDisposer(r.changed.add(this.redrawNeeded.dispatch))}defineShader(e,t){if(t.parseResult.errors.length!==0)throw new Error("Invalid UI control specification");e.addUniform("highp float","uOpacity"),lS(e,t)}initializeShader(e,t,n){const{gl:s}=this;s.uniform1f(t.uniform("uOpacity"),this.opacity.value),vi(s,t,this.shaderControlState,n.parseResult.controls)}setGLBlendMode(e,t){const n=this.blendMode.value;n===fu.ADDITIVE||t>0?(e.enable(e.BLEND),ak.get(n)(e)):e.disable(WebGL2RenderingContext.BLEND)}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function uk(i=1){return new _.DN(i,f.zo)}var cn=(i=>(i[i.OFF=0]="OFF",i[i.ON=1]="ON",i[i.MAX=2]="MAX",i[i.MIN=3]="MIN",i))(cn||{});function cS(i=0){return new Oi.F(cn,i)}function Xi(i){return i===2||i===3}function dS(i){return Xi(i.mode.value)}/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const hk="volume_rendering/VolumeRenderingRenderLayer",pk="volume_rendering/VolumeRenderingRenderLayer/update",fk=!1,gk=C.w0.create();function mk(i,e,t){let n=0,s=0;for(let c=0;c<3;++c){const d=i[16+c],u=d*e[c],h=d*t[c];n+=Math.min(u,h),s+=Math.max(u,h)}const r=-i[19],o=Math.max(r,n),a=i[23],l=Math.min(a,s);return{near:r,far:a,adjustedNear:o,adjustedFar:l}}function uS(i,e,t,n,s,r){if(n.length===0)return;const{viewMatrix:o,projectionMat:a,displayDimensionRenderInfo:l}=i,{voxelPhysicalScales:c}=l,d=(0,C.xK)(c),u=(0,C.sJ)(a),p=(u/t)**3,m=C.w0.determinant((0,C._A)(gk,o)),g={spatialScales:new Map,activeIndex:-1},v=D=>{const I=n[D];return Math.abs(I.chunkLayout.detTransform*m)};let y=n.length-1,S=v(y);for(let D=y;D>=0;--D){const I=v(D),L=Math.cbrt(I*d/m),N=u/Math.cbrt(I);g.spatialScales.set(L,N),I-p>=0&&(S=I,y=D),g.activeIndex=y}if(fk){console.log(n);for(let D=0;D{x&&(s(E,y,w,b,I,g),x=!1),r(E,y,D)})}/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const vk=64,hS=1,yk=10,gu=256,Sk=2**14,bk=!1,mu=Symbol("depthSamplerTextureUnit"),Ck=` +void emitRGBA(vec4 rgba) { + float correctedAlpha = clamp(rgba.a * uBrightnessFactor * uGain, 0.0, 1.0); + float weightedAlpha = correctedAlpha * computeOITWeight(correctedAlpha, depthAtRayPosition); + outputColor += vec4(rgba.rgb * weightedAlpha, weightedAlpha); + revealage *= 1.0 - correctedAlpha; +} +`,wk=C.pB.create(),xk=new Float32Array(24);function pS(){const i=Math.round(hS+mt*Ir);return[hS,i]}function fS(i){const e=pS(),t=[2**e[0],2**e[1]-1];return Pe(t,Math.round(i))}class Ek extends Gi{get gl(){return this.multiscaleSource.chunkManager.gl}get isTransparent(){return!0}get isVolumeRendering(){return!0}getDataHistogramCount(){return this.dataHistogramSpecifications.visibleHistograms}constructor(e){super(),this.gain=e.gain,this.multiscaleSource=e.multiscaleSource,this.transform=e.transform,this.channelCoordinateSpace=e.channelCoordinateSpace,this.shaderControlState=e.shaderControlState,this.localPosition=e.localPosition,this.depthSamplesTarget=e.depthSamplesTarget,this.chunkResolutionHistogram=e.chunkResolutionHistogram,this.mode=e.mode,this.modeOverride=cS(),this.dataHistogramSpecifications=this.shaderControlState.histogramSpecifications,this.histogramIndexBuffer=this.registerDisposer(ci(this.gl,WebGL2RenderingContext.ARRAY_BUFFER,()=>new Uint8Array(gu))),this.registerDisposer(this.chunkResolutionHistogram.visibility.add(this.visibility)),this.registerDisposer(this.dataHistogramSpecifications.producerVisibility.add(this.visibility));const t=this.registerDisposer((0,_.Uq)((o,a,l,c)=>({numChannelDimensions:o.rank,mode:l===cn.OFF?a:l,dataHistogramChannelSpecifications:c}),[this.channelCoordinateSpace,this.mode,this.modeOverride,this.dataHistogramSpecifications.channels]));this.shaderGetter=wo(this,this.gl,{memoizeKey:"VolumeRenderingRenderLayer",parameters:e.shaderControlState.builderState,getContextKey:({emitter:o,chunkFormat:a,wireFrame:l})=>`${xt(o)}:${a.shaderKey}:${l}`,shaderError:e.shaderError,extraParameters:t,defineShader:(o,{emitter:a,chunkFormat:l,wireFrame:c},d,u)=>{if(d.parseResult.errors.length!==0)throw new Error("Invalid UI control specification");xi(o),o.addFragmentCode(` +#define VOLUME_RENDERING true +`);let h=Ck,p=` + emitAccumAndRevealage(outputColor, 1.0 - revealage, 0u); +`,m=` +void emitIntensity(float value) { +} +`,g="";if(Xi(u.mode)){const v=u.mode===cn.MIN?"1.0 - value":"value";o.addFragmentCode(` +float savedDepth = 0.0; +float savedIntensity = 0.0; +vec4 newColor = vec4(0.0); +float userEmittedIntensity = -100.0; +`),m=` +float convertIntensity(float value) { + return clamp(${v}, 0.0, 1.0); +} +void emitIntensity(float value) { + userEmittedIntensity = value; +} +float getIntensity() { + float intensity = userEmittedIntensity > -100.0 ? userEmittedIntensity : defaultMaxProjectionIntensity; + return convertIntensity(intensity); +} +`,h=` +void emitRGBA(vec4 rgba) { + float alpha = clamp(rgba.a, 0.0, 1.0); + newColor = vec4(rgba.rgb * alpha, alpha); +} +`,p=` + gl_FragDepth = savedIntensity; +`,g=` + float newIntensity = getIntensity(); + bool intensityChanged = newIntensity > savedIntensity; + savedIntensity = intensityChanged ? newIntensity : savedIntensity; + savedDepth = intensityChanged ? depthAtRayPosition : savedDepth; + outputColor = intensityChanged ? newColor : outputColor; + emit(outputColor, savedDepth, savedIntensity, uPickId); + defaultMaxProjectionIntensity = 0.0; + userEmittedIntensity = -100.0; +`}if(a(o),o.addUniform("highp float","uNearLimitFraction"),o.addUniform("highp float","uFarLimitFraction"),o.addUniform("highp int","uMaxSteps"),o.addUniform("highp vec3","uTranslation"),o.addUniform("highp mat4","uModelViewProjectionMatrix"),o.addUniform("highp mat4","uInvModelViewProjectionMatrix"),o.addUniform("highp vec3","uChunkDataSize"),o.addUniform("highp float","uChunkNumber"),o.addUniform("highp vec3","uLowerClipBound"),o.addUniform("highp vec3","uUpperClipBound"),o.addUniform("highp float","uBrightnessFactor"),o.addUniform("highp float","uGain"),o.addUniform("highp uint","uPickId"),o.addVarying("highp vec4","vNormalizedPosition"),o.addTextureSampler("sampler2D","uDepthSampler",mu),o.addVertexCode(tL),o.setVertexMain(` +vec3 boxVertex = getBoxFaceVertexPosition(gl_VertexID); +vec3 position = max(uLowerClipBound, min(uUpperClipBound, uTranslation + boxVertex * uChunkDataSize)); +vNormalizedPosition = gl_Position = uModelViewProjectionMatrix * vec4(position, 1.0); +gl_Position.z = 0.0; +`),o.addFragmentCode(` +vec3 curChunkPosition; +float depthAtRayPosition; +vec4 outputColor; +float revealage; +void userMain(); +`),Ev(o,l,u.numChannelDimensions,"curChunkPosition"),o.addFragmentCode([m,h,` +void emitRGB(vec3 rgb) { + emitRGBA(vec4(rgb, 1.0)); +} +void emitGrayscale(float value) { + emitRGBA(vec4(value, value, value, value)); +} +void emitTransparent() { + emitIntensity(0.0); + emitRGBA(vec4(0.0, 0.0, 0.0, 0.0)); +} +float computeDepthFromClipSpace(vec4 clipSpacePosition) { + float NDCDepthCoord = clipSpacePosition.z / clipSpacePosition.w; + return (NDCDepthCoord + 1.0) * 0.5; +} +vec2 computeUVFromClipSpace(vec4 clipSpacePosition) { + vec2 NDCPosition = clipSpacePosition.xy / clipSpacePosition.w; + return (NDCPosition + 1.0) * 0.5; +} +`]),c){let v=` + emit(outputColor, 0u); +`;Xi(u.mode)&&(v=` + emit(outputColor, 1.0, uChunkNumber, uPickId); + `),o.setFragmentMainFunction(` +void main() { + outputColor = vec4(uChunkNumber, uChunkNumber, uChunkNumber, 1.0); + emitIntensity(uChunkNumber); + ${v} +} +`)}else o.setFragmentMainFunction(` +void main() { + vec2 normalizedPosition = vNormalizedPosition.xy / vNormalizedPosition.w; + vec4 nearPointH = uInvModelViewProjectionMatrix * vec4(normalizedPosition, -1.0, 1.0); + vec4 farPointH = uInvModelViewProjectionMatrix * vec4(normalizedPosition, 1.0, 1.0); + vec3 nearPoint = nearPointH.xyz / nearPointH.w; + vec3 farPoint = farPointH.xyz / farPointH.w; + vec3 rayVector = farPoint - nearPoint; + vec3 boxStart = max(uLowerClipBound, uTranslation); + vec3 boxEnd = min(boxStart + uChunkDataSize, uUpperClipBound); + float intersectStart = uNearLimitFraction; + float intersectEnd = uFarLimitFraction; + for (int i = 0; i < 3; ++i) { + float startPt = nearPoint[i]; + float endPt = farPoint[i]; + float boxLower = boxStart[i]; + float boxUpper = boxEnd[i]; + float r = rayVector[i]; + float startFraction; + float endFraction; + if (startPt >= boxLower && startPt <= boxUpper) { + startFraction = 0.0; + } else { + startFraction = min((boxLower - startPt) / r, (boxUpper - startPt) / r); + } + if (endPt >= boxLower && endPt <= boxUpper) { + endFraction = 1.0; + } else { + endFraction = max((boxLower - startPt) / r, (boxUpper - startPt) / r); + } + intersectStart = max(intersectStart, startFraction); + intersectEnd = min(intersectEnd, endFraction); + } + float stepSize = (uFarLimitFraction - uNearLimitFraction) / float(uMaxSteps - 1); + int startStep = int(floor((intersectStart - uNearLimitFraction) / stepSize)); + int endStep = min(uMaxSteps, int(floor((intersectEnd - uNearLimitFraction) / stepSize)) + 1); + outputColor = vec4(0, 0, 0, 0); + revealage = 1.0; + for (int rayStep = startStep; rayStep < endStep; ++rayStep) { + vec3 position = mix(nearPoint, farPoint, uNearLimitFraction + float(rayStep) * stepSize); + vec4 clipSpacePosition = uModelViewProjectionMatrix * vec4(position, 1.0); + depthAtRayPosition = computeDepthFromClipSpace(clipSpacePosition); + vec2 uv = computeUVFromClipSpace(clipSpacePosition); + float depthInBuffer = texture(uDepthSampler, uv).r; + bool rayPositionBehindOpaqueObject = (1.0 - depthAtRayPosition) < depthInBuffer; + if (rayPositionBehindOpaqueObject) { + break; + } + curChunkPosition = position - uTranslation; + userMain(); + ${g} + } + ${p} +} +`);o.addFragmentCode(Is),Ts(d,o),o.addFragmentCode(` +#define main userMain +`+ms(d.parseResult.code)+` +#undef main +`)}}),this.histogramShaderGetter=wo(this,this.gl,{memoizeKey:"VolumeRenderingRenderLayerHistogram",parameters:e.shaderControlState.builderState,getContextKey:({chunkFormat:o})=>`${o.shaderKey}`,shaderError:e.shaderError,extraParameters:t,defineShader:(o,{chunkFormat:a},l,c)=>{o.addOutputBuffer("vec4","outputValue",null),o.addUniform("highp vec3","uChunkDataSize"),o.addUniform("highp int","uHistogramIndex"),o.addAttribute("float","aInput1"),o.addVertexCode(` +vec3 chunkSamplePosition; + `);const d=c.numChannelDimensions;a.defineShader(o,d,!0);const{dataType:u}=a;let h="",p="";if(d===0)h+="highp int ignoredChannelIndex";else for(let S=0;S 1.0) x = 1.0; + else x = (1.0 + x * 253.0) / 255.0; + gl_Position = vec4(2.0 * (x * 255.0 + 0.5) / 256.0 - 1.0, 0.0, 0.0, 1.0); + } + gl_PointSize = 1.0;`),o.setFragmentMain(` +outputValue = vec4(1.0, 1.0, 1.0, 1.0); + `)}}),this.vertexIdHelper=this.registerDisposer(Qn.get(this.gl)),this.registerDisposer(this.depthSamplesTarget.changed.add(this.redrawNeeded.dispatch)),this.registerDisposer(this.gain.changed.add(this.redrawNeeded.dispatch)),this.registerDisposer(this.shaderControlState.changed.add(this.redrawNeeded.dispatch)),this.registerDisposer(this.localPosition.changed.add(this.redrawNeeded.dispatch)),this.registerDisposer(this.transform.changed.add(this.redrawNeeded.dispatch)),this.registerDisposer(this.mode.changed.add(this.redrawNeeded.dispatch)),this.registerDisposer(this.shaderControlState.fragmentMain.changed.add(this.redrawNeeded.dispatch));const{chunkManager:n}=this.multiscaleSource,s=this.registerDisposer(new Dr(this.layerChunkProgressInfo)),r=n.rpc;s.RPC_TYPE_ID=hk,s.initializeCounterpart(r,{chunkManager:n.rpcId,localPosition:this.registerDisposer(ft.makeFromExisting(r,this.localPosition)).rpcId,renderScaleTarget:this.registerDisposer(ft.makeFromExisting(r,this.depthSamplesTarget)).rpcId}),this.backend=s}get dataType(){return this.multiscaleSource.dataType}attach(e){super.attach(e),e.state={sources:e.registerDisposer((0,_.no)((t,n,s)=>{const r=sa(s,n,o=>this.multiscaleSource.getSources(o),e.messages,this);for(const o of r)for(const a of o)t.registerDisposer(a.source);return e.view.flushBackendProjectionParameters(),this.backend.rpc.invoke(pk,{layer:this.backend.rpcId,view:e.view.rpcId,sources:ta(r),displayDimensionRenderInfo:s}),this.redrawNeeded.dispatch(),r},this.transform,e.view.displayDimensionRenderInfo))}}get chunkManager(){return this.multiscaleSource.chunkManager}draw(e,t){if(!e.emitColor)return;const n=t.state.sources.value;if(n.length===0)return;let s=0,r=0,o={spatialScales:new Map,activeIndex:0},a=null,l,c;const d=C.eR.create(),{gl:u}=this;this.vertexIdHelper.enable(),this.modeOverride.value=cn.OFF;const{chunkResolutionHistogram:h}=this;h.begin(this.chunkManager.chunkQueueManager.frameNumberCounter.frameNumber);const p=()=>{const Y=!Xi(this.mode.value)&&!e.isContinuousCameraMotionInProgress;Xi(this.mode.value)||Y?(u.depthMask(!0),u.disable(WebGL2RenderingContext.BLEND),u.depthFunc(WebGL2RenderingContext.GREATER)):(u.depthMask(!1),u.enable(WebGL2RenderingContext.BLEND),u.depthFunc(WebGL2RenderingContext.LESS),e.bindVolumeRenderingBuffer())},m=()=>{if(a===null)return;a.unbindTransferFunctionTextures(),l!==null&&l.endDrawing(u,a);const Y=a.textureUnit(mu);if(u.activeTexture(WebGL2RenderingContext.TEXTURE0+Y),u.bindTexture(WebGL2RenderingContext.TEXTURE_2D,null),S!==0||w!==0){let Q=o.spatialScales.size-1;const X=new Set([fS(r)]);o.spatialScales.forEach((ce,oe)=>{const Se=fS(ce);Q!==o.activeIndex&&!X.has(Se)&&(h.add(oe,ce,0,yk,!0),X.add(Se)),Q--}),h.add(s,r,S,w)}};let g=!0;const{projectionParameters:v}=e;let y,S=0,w=0,b,x=1;const E=this.multiscaleSource.rank,D=C.eR.create(),I=this.getDataHistogramCount()>0&&!e.wireFrame&&!e.sliceViewsPresent&&!e.isContinuousCameraMotionInProgress,L=!Xi(this.mode.value)&&!e.isContinuousCameraMotionInProgress&&!e.wireFrame,k=Xi(this.mode.value)||L?e.pickIDs.register(this):0,O=[],V=[];let z;if(u.enable(WebGL2RenderingContext.CULL_FACE),u.cullFace(WebGL2RenderingContext.FRONT),uS(e.projectionParameters,this.localPosition.value,this.depthSamplesTarget.value,n[0],(Y,Q,X,ce,oe,Se)=>{s=X,r=ce,o=Se;const Ke=Mc(v,Y.chunkLayout),$e=Y.source,{fixedPositionWithinChunk:Tt,chunkDisplayDimensionIndices:we}=Y;for(const ls of we)Tt[ls]=0;const xe=$e.chunkFormat;if(xe!==l&&(l=xe,m(),c=this.shaderGetter({emitter:e.emitter,chunkFormat:xe,wireFrame:e.wireFrame}),a=c.shader,a!==null&&(a.bind(),xe!==null&&(vi(u,a,this.shaderControlState,c.parameters.parseResult.controls),this.bindDepthBufferTexture(e,a),xe.beginDrawing(u,a),xe.beginSource(u,a)))),b=void 0,a===null)return;y=$e.chunks,d.fill(1);const ct=C.pB.multiply(wk,v.viewProjectionMat,Ke.transform),dt=xk;(0,C._S)(dt,ct);const be=C.pB.create();C.pB.invert(be,ct);const{near:Ye,far:bt,adjustedNear:ni,adjustedFar:oo}=mk(dt,Y.lowerClipDisplayBound,Y.upperClipDisplayBound),vh=ce,yh=this.depthSamplesTarget.value,Sh=vh/yh,Dl=(ni-Ye)/(bt-Ye),as=(oo-Ye)/(bt-Ye);z={uNearLimitFraction:Dl,uFarLimitFraction:as,uMaxSteps:this.depthSamplesTarget.value,uBrightnessFactor:Sh,uGain:Math.exp(this.gain.value),uPickId:k,uLowerClipBound:Y.lowerClipDisplayBound,uUpperClipBound:Y.upperClipDisplayBound,uModelViewProjectionMatrix:ct,uInvModelViewProjectionMatrix:be},this.setShaderUniforms(a,z)},Y=>{if(a===null)return;const Q=Y.curPositionInChunks.join(),X=y.get(Q);if(X!==void 0&&X.state===Ue.GPU_MEMORY){const ce=Y.chunkLayout.size,oe=X.chunkDataSize,{chunkDisplayDimensionIndices:Se,fixedPositionWithinChunk:Ke,chunkTransform:{channelToChunkDimensionIndices:$e}}=Y;if(e.wireFrame){const we=x/y.size;u.uniform1f(a.uniform("uChunkNumber"),we),++x}if(oe!==b){b=oe;for(let we=0;we<3;++we){const xe=Se[we];d[we]=xe===-1||xe>=E?1:b[xe]}u.uniform3fv(a.uniform("uChunkDataSize"),d)}const{chunkGridPosition:Tt}=X;for(let we=0;we<3;++we){const xe=Se[we];D[we]=xe===-1||xe>=E?0:ce[we]*Tt[xe]}if(u.uniform3fv(a.uniform("uTranslation"),D),l?.bindChunk(u,a,X,Ke,Se,$e,g),(I||L)&&O.push({chunk:X,fixedPositionWithinChunk:Ke,chunkDisplayDimensionIndices:Se,channelToChunkDimensionIndices:$e,chunkDataDisplaySize:d,chunkFormat:l}),L){const we=C.eR.create(),xe=C.eR.create();C.eR.copy(we,d),C.eR.copy(xe,D),V.push({uChunkDataSize:we,uTranslation:xe})}Fv(u,1,1),g=!1,++S}else++w}),m(),a=null,l=null,L){u.enable(WebGL2RenderingContext.DEPTH_TEST),u.depthMask(!0),u.disable(WebGL2RenderingContext.BLEND),u.depthFunc(WebGL2RenderingContext.GREATER),e.emitter=e.maxProjectionEmit,e.bindMaxProjectionBuffer(),this.modeOverride.value=cn.MAX;const Y=()=>{a!==null&&(a.unbindTransferFunctionTextures(),l!==null&&l.endDrawing(u,a))};g=!0;for(let Q=0;Q{Y!==null&&(Y.unbindTransferFunctionTextures(),l!==null&&l.endDrawing(u,Y))},ce=(we,xe)=>{const ct=Math.ceil(we.reduce((Ye,bt)=>Ye*bt,1)/2),dt=Sk/xe,be=Math.min(ct,dt);return Math.max(Math.round(be/gu),1)};l=null;const{dataType:oe,dataHistogramSpecifications:Se}=this,Ke=Se.getFramebuffers(u),$e=this.getDataHistogramCount();for(let we=0;we<$e;++we)Ke[we].bind(256,1),u.clearColor(0,0,0,1),u.clear(WebGL2RenderingContext.COLOR_BUFFER_BIT);const Tt=this.dataHistogramSpecifications.bounds.value;u.enable(WebGL2RenderingContext.BLEND),u.disable(WebGL2RenderingContext.DEPTH_TEST);for(let we=0;we{},r=>{const o=r.source.chunks.get(r.curPositionInChunks.join());(o===void 0||o.state!==Ue.GPU_MEMORY)&&(s=!0)}),!s}}/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const Tk=Ae.fromObject({arrowup:{action:"tab-backward"},arrowdown:{action:"tab-forward"},tab:{action:"tab-forward"},"shift+tab":{action:"tab-backward"},enter:{action:"commit"},escape:{action:"cancel"}});class Dk{constructor(e){this.id=e,this.element=document.createElement("div"),this.nameContainer=document.createElement("div"),this.nameElement=document.createElement("input"),this.lowerElement=document.createElement("div"),this.upperElement=document.createElement("div");const{element:t,nameContainer:n,nameElement:s,lowerElement:r,upperElement:o}=this;t.classList.add("neuroglancer-channel-dimensions-widget-dim"),n.classList.add("neuroglancer-channel-dimensions-widget-name-container"),s.classList.add("neuroglancer-channel-dimensions-widget-name"),n.appendChild(s),r.classList.add("neuroglancer-channel-dimensions-widget-lower"),o.classList.add("neuroglancer-channel-dimensions-widget-upper"),t.appendChild(n),t.appendChild(r),t.appendChild(o),n.draggable=!0,s.disabled=!0,s.spellcheck=!1,s.autocomplete="off",s.required=!0,s.placeholder=" ",n.title="Drag to reorder, double click to rename. Names ending in ' or ^ indicate dimensions local to the layer; names ending in ^ indicate channel dimensions (image layers only).",n.addEventListener("dblclick",()=>{s.disabled=!1,s.focus(),s.select()}),s.addEventListener("focus",()=>{s.select()})}}class Ik extends T.O8{constructor(e){super(),this.combiner=e,this.element=document.createElement("div"),this.dimensionWidgets=[],this.curCoordinateSpace=void 0,this.dragSource=void 0,this.coordinateSpace=this.combiner.combined;const{element:t}=this;t.classList.add("neuroglancer-channel-dimensions-widget");const n=this.registerCancellable((0,Qe.t)(()=>this.updateView()));this.registerDisposer(e.combined.changed.add(n));const s=this.registerDisposer(new yn(t,Tk));s.allShortcutsAreGlobal=!0,this.registerDisposer(Z(t,"cancel",r=>{this.forceUpdateView();const{target:o}=r;o instanceof HTMLElement&&o.blur()})),this.updateView()}reorderDimensionTo(e,t){if(e===t)return;const{coordinateSpace:n}=this;n.value=Qh(n.value,e,t)}makeNewDimensionWidget(e){const t=new Dk(e);return t.nameContainer.addEventListener("dragstart",n=>{this.dragSource=t,n.stopPropagation(),n.dataTransfer.setData("neuroglancer-dimension","")}),t.nameContainer.addEventListener("dragenter",n=>{const{dragSource:s}=this;if(s===void 0||s===t)return;const{dimensionWidgets:r}=this,o=r.indexOf(s),a=r.indexOf(t);o===-1||a===-1||(n.preventDefault(),this.reorderDimensionTo(a,o))}),t.nameContainer.addEventListener("dragend",n=>{this.dragSource===t&&(this.dragSource=void 0)}),t.nameElement.addEventListener("blur",n=>{t.nameElement.disabled=!0;const{relatedTarget:s}=n;this.dimensionWidgets.some(r=>r.nameElement===s)||this.updateNames()||this.forceUpdateView()}),t.nameElement.addEventListener("input",()=>{const{nameElement:n}=t;$t(n),this.updateNameValidity()}),Z(t.nameElement,"commit",()=>{this.updateNames()}),Z(t.nameElement,"tab-forward",n=>this.selectAdjacentField(n,t,1)),Z(t.nameElement,"tab-backward",n=>this.selectAdjacentField(n,t,-1)),t}selectAdjacentField(e,t,n){e.stopPropagation();const{dimensionWidgets:s}=this,r=s.indexOf(t);if(r===-1)return;const o=r+n;if(o<0||o>=s.length)return;const a=s[o];a.nameElement.disabled=!1,a.nameElement.focus(),e.preventDefault()}updateNames(){const{dimensionWidgets:e,coordinateSpace:t}=this,n=t.value,s=e.map(l=>l.nameElement.value);if(this.combiner.getRenameValidity(s).includes(!1))return!1;const r=n.names;if((0,F.r1)(r,s))return!1;const o=n.timestamps.map((l,c)=>r[c]===s[c]?l:Date.now()),a={...n,names:s,timestamps:o};return t.value=a,!0}updateNameValidity(){const{dimensionWidgets:e}=this,t=e.map(r=>r.nameElement.value),n=t.length,s=this.combiner.getRenameValidity(t);for(let r=0;rn.find(a=>a.id===o)||this.makeNewDimensionWidget(o));function*r(){const{names:o,rank:a,bounds:l}=e;for(let c=0;cbo(()=>MC(t)),this.channelCoordinateSpace)),this.volumeRenderingMode=cS(),this.shaderControlState=this.registerDisposer(new Jo(this.fragmentMain,this.registerDisposer((0,_.Uq)((t,n)=>t===void 0?null:{imageData:{dataType:t,channelRank:n.rank}},[this.dataType,this.channelCoordinateSpace],(t,n)=>JSON.stringify(t)===JSON.stringify(n))),this.channelCoordinateSpaceCombiner)),this.localCoordinateSpaceCombiner.includeDimensionPredicate=rr,this.blendMode.changed.add(this.specificationChanged.dispatch),this.opacity.changed.add(this.specificationChanged.dispatch),this.volumeRenderingGain.changed.add(this.specificationChanged.dispatch),this.fragmentMain.changed.add(this.specificationChanged.dispatch),this.shaderControlState.changed.add(this.specificationChanged.dispatch),this.sliceViewRenderScaleTarget.changed.add(this.specificationChanged.dispatch),this.volumeRenderingMode.changed.add(this.specificationChanged.dispatch),this.volumeRenderingDepthSamplesTarget.changed.add(this.specificationChanged.dispatch),this.tabs.add("rendering",{label:"Rendering",order:-100,getter:()=>new kk(this)}),this.tabs.default="rendering"}markLoading(){const e=super.markLoading(),t=this.channelCoordinateSpaceCombiner.retain();return()=>{e(),t()}}addCoordinateSpace(e){const t=super.addCoordinateSpace(e),n=this.channelCoordinateSpaceCombiner.bind(e);return()=>{t(),n()}}activateDataSubsources(e){let t;for(const n of e){if(this.addStaticAnnotations(n))continue;const{subsourceEntry:s}=n,{subsource:r}=s,{volume:o}=r;if(!(o instanceof ln)){n.deactivate("Not compatible with image layer");continue}if(t&&o.dataType!==t){n.deactivate(`Data type must be ${R[o.dataType].toLowerCase()}`);continue}t=o.dataType,n.activate(a=>{n.addRenderLayer(new dk(o,{opacity:this.opacity,blendMode:this.blendMode,shaderControlState:this.shaderControlState,shaderError:this.shaderError,transform:n.getRenderLayerTransform(this.channelCoordinateSpace),renderScaleTarget:this.sliceViewRenderScaleTarget,renderScaleHistogram:this.sliceViewRenderScaleHistogram,localPosition:this.localPosition,channelCoordinateSpace:this.channelCoordinateSpace}));const l=a.registerDisposer(new Ek({gain:this.volumeRenderingGain,multiscaleSource:o,shaderControlState:this.shaderControlState,shaderError:this.shaderError,transform:n.getRenderLayerTransform(this.channelCoordinateSpace),depthSamplesTarget:this.volumeRenderingDepthSamplesTarget,chunkResolutionHistogram:this.volumeRenderingChunkResolutionHistogram,localPosition:this.localPosition,channelCoordinateSpace:this.channelCoordinateSpace,mode:this.volumeRenderingMode}));a.registerDisposer(n.messages.addChild(l.messages)),a.registerDisposer((0,_.no)((c,d)=>{d!==cn.OFF&&c.registerDisposer(this.addRenderLayer(l.addRef()))},this.volumeRenderingMode)),this.shaderError.changed.dispatch()})}this.dataType.value=t}restoreState(e){super.restoreState(e),this.opacity.restoreState(e[vu]),(0,f.MM)(e,yu,t=>this.blendMode.restoreState(t)),this.fragmentMain.restoreState(e[gS]),this.shaderControlState.restoreState(e[mS]),this.sliceViewRenderScaleTarget.restoreState(e[Su]),this.channelCoordinateSpace.restoreState(e[vS]),(0,f.MM)(e,bu,t=>{typeof t=="boolean"?this.volumeRenderingMode.value=t?cn.ON:cn.OFF:this.volumeRenderingMode.restoreState(t)}),(0,f.MM)(e,Cu,t=>this.volumeRenderingGain.restoreState(t)),(0,f.MM)(e,wu,t=>this.volumeRenderingDepthSamplesTarget.restoreState(t))}toJSON(){const e=super.toJSON();return e[vu]=this.opacity.toJSON(),e[yu]=this.blendMode.toJSON(),e[gS]=this.fragmentMain.toJSON(),e[mS]=this.shaderControlState.toJSON(),e[Su]=this.sliceViewRenderScaleTarget.toJSON(),e[vS]=this.channelCoordinateSpace.toJSON(),e[bu]=this.volumeRenderingMode.toJSON(),e[Cu]=this.volumeRenderingGain.toJSON(),e[wu]=this.volumeRenderingDepthSamplesTarget.toJSON(),e}displayImageSelectionState(e,t){const{value:n}=e;if(n==null)return!1;const s=this.channelSpace.value;if(s.error!==void 0)return!1;const{numChannels:r,coordinates:o,channelCoordinateSpace:{names:a,rank:l}}=s,c=document.createElement("div");c.classList.add("neuroglancer-selection-details-value-grid");let d="[copy] 0fr ";l!==0&&(d+=`repeat(${l}, [dim] 0fr [coord] 0fr) `),d+="[value] 1fr",c.style.gridTemplateColumns=d;for(let u=0;u{mi(p)}});c.appendChild(m);for(let v=0;ve.key,defineShader:(e,t)=>{e.addFragmentCode(` +#define uOpacity 1.0 +`),lS(e,t)},initializeShader:e=>{const t=e.shader;vi(this.manager.root.display.gl,t,this.shaderControlState,e.parameters.parseResult.controls)}}}}Zi.type="image",Zi.typeAbbreviation="img";function SS(i){return new Ja({shaderError:i.shaderError,fragmentMain:i.fragmentMain,shaderControlState:i.shaderControlState})}const bS=[{label:"Resolution (slice)",toolJson:Su,...ma(i=>({histogram:i.sliceViewRenderScaleHistogram,target:i.sliceViewRenderScaleTarget}))},{label:"Blending (slice)",toolJson:yu,...md(i=>i.blendMode)},{label:"Opacity (slice)",toolJson:vu,...Yn(i=>({value:i.opacity}))},{label:"Volume rendering (experimental)",toolJson:bu,...md(i=>i.volumeRenderingMode)},{label:"Gain (3D)",toolJson:Cu,isValid:i=>(0,_.Uq)(e=>e===cn.ON,[i.volumeRenderingMode]),...Yn(i=>({value:i.volumeRenderingGain,options:{min:-10,max:10,step:.1}}))},{label:"Resolution (3D)",toolJson:wu,isValid:i=>(0,_.Uq)(e=>e!==cn.OFF,[i.volumeRenderingMode]),...ma(i=>({histogram:i.volumeRenderingChunkResolutionHistogram,target:i.volumeRenderingDepthSamplesTarget}),eD)}];for(const i of bS)gd(Zi,i);class kk extends Gt{constructor(e){super(),this.layer=e,this.codeWidget=this.registerDisposer(SS(this.layer));const{element:t}=this;t.classList.add("neuroglancer-image-dropdown");for(const r of bS)t.appendChild(fa(this,e,this.visibility,r));const n=document.createElement("div");n.style.flex="1";const s=document.createElement("div");s.className="neuroglancer-image-dropdown-top-row",s.appendChild(document.createTextNode("Shader")),s.appendChild(n),s.appendChild(Ha({title:"Show larger editor view",onClick:()=>{new Pk(this.layer)}})),s.appendChild(Wa({title:"Documentation on image layer rendering",href:"https://github.com/google/neuroglancer/blob/master/src/sliceview/image_layer_rendering.md"})),t.appendChild(s),t.appendChild(this.registerDisposer(new Ik(e.channelCoordinateSpaceCombiner)).element),t.appendChild(this.codeWidget.element),t.appendChild(this.registerDisposer(new ja(e.shaderControlState,this.layer.manager.root.display,this.layer,{visibility:this.visibility,legendShaderOptions:this.layer.getLegendShaderOptions()})).element)}}class Pk extends Jr{constructor(e){super(),this.layer=e,this.codeWidget=this.registerDisposer(SS(this.layer)),this.content.classList.add("neuroglancer-image-layer-shader-overlay"),this.content.appendChild(this.codeWidget.element),this.codeWidget.textEditor.refresh()}}$i(Zi),Hg(St.IMAGE,Zi),da(i=>{const{volume:e}=i;if(e!==void 0&&e.volumeType===St.UNKNOWN)return{layerConstructor:Zi,priority:-100}}),Ya(Zi,i=>({shaderControlState:i.shaderControlState,legendShaderOptions:i.getLegendShaderOptions()}));var CS=G(957),Ak=Object.defineProperty,Mk=Object.getOwnPropertyDescriptor,Nk=(i,e,t,n)=>{for(var s=n>1?void 0:n?Mk(e,t):e,r=i.length-1,o;r>=0;r--)(o=i[r])&&(s=(n?o(e,t,s):o(s))||s);return n&&s&&Ak(e,t,s),s};/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */let xu=class extends hn{constructor(i,e){super(),this.provider=i,this.registerDisposer(i),this.initializeCounterpart(e)}get(i,e){return this.provider.get(i,e)}};xu=Nk([Zt(CS.P)],xu),pp(CS.y,function(i,e){return this.get(i.providerId).get(i.invalidCredentials,e).then(n=>({value:n}))});/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function Eu(i,e){if(e===void 0)return;const t=i.memoize.get({type:"getSharedCredentialsProvider",credentialsProvider:xt(e)},()=>new xu(e.addRef(),i.rpc)),n=t.addCounterpartRef();return t.dispose(),n}function lt(){return i=>{class e extends i{constructor(...n){super(...n);const s=n[1];this.credentialsProvider=s.credentialsProvider?.addRef()}initializeCounterpart(n,s){const{credentialsProvider:r}=this;s.credentialsProvider=Eu(this.chunkManager,r),super.initializeCounterpart(n,s)}static encodeOptions(n){const s=i.encodeOptions(n),{credentialsProvider:r}=n;return s.credentialsProvider=r===void 0?void 0:xt(r),s}}return e}}var Hs=G(6015);const wS=!1;var Js=G(3551),ke=G(9808);/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */async function Ok(i,e,t,n,s){const r=await(0,Js.Y)(i,`${e}?prefix=${encodeURIComponent(t)}&delimiter=${encodeURIComponent(n)}`,{},d=>d.text(),s),o=new DOMParser().parseFromString(r,"application/xml"),a=o.evaluate('//*[name()="CommonPrefixes"]/*[name()="Prefix"]',o,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null),l=[];for(let d=0,u=a.snapshotLength;d({value:l.substring(a)}))}}/** + * @license + * Copyright 2021 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */async function _k(i,e,t,n,s=Je.fx){return await(0,ke.Bk)(`https://${i}.s3.amazonaws.com${e}`,t,n,s)}async function Vk(i,e,t){return await Tu(void 0,`s3://${i}`,`https://${i}.s3.amazonaws.com`,e,t)}/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function Bk(i,e){return i.getCredentialsProvider("middleauthapp",new URL(e).origin)}function Qa(i,e,t){const n=/^\/([^/]+)/,s=t.match(n);if(s!==null)return wS?i.getCredentialsProvider("gcs",{bucket:s[1]}):i.getCredentialsProvider("ngauth_gcs",{authServer:e,bucket:s[1]})}function wn(i,e){const t=(0,ke.Dl)(i);switch(t.protocol){case"gs":case"gs+xml":return{credentialsProvider:wS?e.getCredentialsProvider("gcs",{bucket:t.host}):void 0,url:i};case"gs+ngauth+http":return{credentialsProvider:Qa(e,`http://${t.host}`,t.path),url:"gs:/"+t.path};case"gs+ngauth+https":return{credentialsProvider:Qa(e,`https://${t.host}`,t.path),url:"gs:/"+t.path};case"gs+xml+ngauth+http":return{credentialsProvider:Qa(e,`http://${t.host}`,t.path),url:"gs+xml:/"+t.path};case"gs+xml+ngauth+https":return{credentialsProvider:Qa(e,`https://${t.host}`,t.path),url:"gs+xml:/"+t.path};case"middleauth+https":return i=i.substr(11),{credentialsProvider:Bk(e,i),url:i};case"s3":return{credentialsProvider:void 0,url:i};default:return{credentialsProvider:void 0,url:i}}}async function Nt(i,e,t,n,s=Je.fx){const r=(0,ke.Dl)(e);switch(r.protocol){case"gs":return(0,Js.Y)(i,`https://www.googleapis.com/storage/v1/b/${r.host}/o/${encodeURIComponent(r.path.substring(1))}?alt=media&neuroglancer=${Te()}`,t,n,s);case"gs+xml":return(0,Js.Y)(i,`https://storage.googleapis.com/${r.host}${r.path}?neuroglancer=${Te()}`,t,n,s);case"s3":return _k(r.host,r.path,t,n,s);default:return(0,Js.Y)(i,e,t,n,s)}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class Fk extends T.O8{constructor(e){super(),this.gl=e,this.buffer=this.registerDisposer(new At(e))}resize(e){let t;if(e<256){const n=t=new Uint8Array(e);for(let s=0;s=0&&(this.bindToVertexAttrib(n),t!==0&&this.gl.vertexAttribDivisor(n,t))}}function Uk(i,e,t=!1){const n=e.attribute("aIndexRaw");n>=0&&(t&&i.vertexAttribDivisor(n,0),i.disableVertexAttribArray(n))}function $k(i){return i.memoize.get("IndexBuffer",()=>new Fk(i))}function Gk(i){i.addAttribute("highp uint","aIndexRaw"),i.addVertexCode(To),i.addVertexCode(` +uint getPrimitiveIndex() { + return aIndexRaw; +} +`)}class zk{constructor(e){this.name=e}defineShader(e){e.addAttribute("highp uint",this.name)}bind(e,t){const n=t.attribute(this.name);e.bindToVertexAttribI(n,1,WebGL2RenderingContext.UNSIGNED_INT)}disable(e){e.gl.disableVertexAttribArray(e.attribute(this.name))}}function Wk(i,e){return At.fromData(i,e,WebGL2RenderingContext.ARRAY_BUFFER,WebGL2RenderingContext.STATIC_DRAW)}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const xS=`void main() { + emitGray(); +} +`;class Hk{constructor(){this.shaderError=dr(),this.fragmentMain=Co(xS),this.shaderControlState=new Jo(this.fragmentMain)}}function ES(i){return yt(i.dataType,i.numComponents)}const es=[],TS=Wi(new Ns,R.FLOAT32,3),Jk=TS;function jk(i){return i.split(/[^a-zA-Z0-9]+/).filter(e=>e).join("_")}function DS(i){const e=new Set,t=[];for(const n of i){const s=jk(n);let r="",o=0;for(;e.has(s+r);)r=""+ ++o;t.push(s+r)}return t}class Yk{constructor(e,t){this.attributeNames=e,this.attributeInfo=t,this.tempLightVec=new Float32Array(4),this.textureAccessHelper=new xa("vertexData"),this.indexBufferHelper=new zk("vertexIndex")}defineAttributeAccess(e,t){const{textureAccessHelper:n}=this;n.defineShader(e);const{attributeNames:s}=this;let r=2+s.length;for(let a=es.length;a{e.addTextureSampler(`${Ca(a.dataType)}sampler2D`,`uVertexAttributeSampler${r}`,es[r]);const c=ES(a);e.addVarying(`highp ${c}`,`vCustom${l}`),e.addFragmentCode(` +#define ${s[l]} vCustom${l} +`),e.addVertexCode(n.getAccessor(`readAttribute${l}`,`uVertexAttributeSampler${r}`,a.dataType,a.numComponents)),o+=`vCustom${l} = readAttribute${l}(${t}); +`,++r}),e.addVertexMain(o)}defineShader(e){e.require(Gk),this.indexBufferHelper.defineShader(e),e.addVarying("highp float","vLightingFactor"),e.addUniform("highp vec4","uLightDirection"),e.addUniform("highp vec4","uColor"),e.addUniform("highp mat4","uModelMatrix"),e.addUniform("highp mat4","uProjection"),e.addUniform("highp uint","uPickID"),e.addVarying("highp uint","vPickID","flat"),e.addVertexMain(` +uint triangleIndex = getPrimitiveIndex() / 3u; +vPickID = uPickID + triangleIndex; +`),e.addFragmentCode(` +void emitPremultipliedRGBA(vec4 color) { + emit(vec4(color.rgb * vLightingFactor, color.a), vPickID); +} +void emitRGBA(vec4 color) { + color = clamp(color, 0.0, 1.0); + color.xyz *= color.a; + emitPremultipliedRGBA(color); +} +void emitRGB(vec3 color) { + emitRGBA(vec4(color, 1.0)); +} +void emitGray() { + emitRGB(vec3(1.0, 1.0, 1.0)); +} +`),e.addFragmentCode(Is),this.defineAttributeAccess(e,"vertexIndex"),e.addVertexMain(` +gl_Position = uProjection * (uModelMatrix * vec4(vertexPosition, 1.0)); +vec3 normal = normalize((uModelMatrix * vec4(vertexNormal, 0.0)).xyz); +vLightingFactor = abs(dot(normal, uLightDirection.xyz)) + uLightDirection.w; +`)}beginLayer(e,t,n){const{lightDirection:s,ambientLighting:r,directionalLighting:o,projectionParameters:a}=n,{viewProjectionMat:l}=a;e.uniformMatrix4fv(t.uniform("uProjection"),!1,l);const c=this.tempLightVec;C.eR.scale(c,s,o),c[3]=r,e.uniform4fv(t.uniform("uLightDirection"),c)}setPickID(e,t,n){e.uniform1ui(t.uniform("uPickID"),n)}beginObject(e,t,n){e.uniformMatrix4fv(t.uniform("uModelMatrix"),!1,n)}bindVertexData(e,t,n){let s=0;const r=a=>{const l=WebGL2RenderingContext.TEXTURE0+t.textureUnit(es[s]);e.activeTexture(l),e.bindTexture(WebGL2RenderingContext.TEXTURE_2D,a),++s};r(n.vertexTexture),r(n.normalTexture);const{attributeNames:o}=this;n.vertexAttributeTextures.forEach((a,l)=>{o[l]!==void 0&&r(a)})}disableVertexData(e,t){let n=2;const s=this.attributeInfo.length,{attributeNames:r}=this;for(let o=0;o{const o=e.createTexture();return e.bindTexture(WebGL2RenderingContext.TEXTURE_2D,o),wa(e,r,s),o};this.vertexTexture=n(this.vertexPositions,TS),this.normalTexture=n(this.vertexNormals,Jk),this.vertexAttributeTextures=this.vertexAttributes.map((s,r)=>n(s,t[r])),e.bindTexture(WebGL2RenderingContext.TEXTURE_2D,null)}freeGPUMemory(e){e.deleteTexture(this.vertexTexture),e.deleteTexture(this.normalTexture);const{vertexAttributeTextures:t}=this;for(const n of t)e.deleteTexture(n);t.length=0}}class Kk extends Jn{constructor(e,t){super(e);const n=this.vertexData=new Qk;n.vertexPositions=t.vertexPositions,n.vertexNormals=t.vertexNormals,n.vertexAttributes=t.vertexAttributes;const s=this.indices=t.indices;this.numIndices=s.length}copyToGPU(e){super.copyToGPU(e),this.vertexData.copyToGPU(e,this.source.attributeTextureFormats),this.indexBuffer=Wk(e,this.indices)}freeGPUMemory(e){super.freeGPUMemory(e),this.vertexData.freeGPUMemory(e),this.indexBuffer.dispose()}}function qk(i){return i.map(e=>Wi(new Ns,e.dataType,e.numComponents))}class Xk extends it(lt()(on),Hs.Fe){constructor(){super(...arguments),this.attributeTextureFormats=qk(this.info.vertexAttributes)}get info(){return this.parameters.info}getChunk(e){return new Kk(this,e)}}const Zk=ar(hn);class eP extends Zk{}class tP extends Gi{constructor(e,t,n){super(),this.source=e,this.displayState=t,this.transform=n,this.shaderManager=new Yk(DS(this.source.info.vertexAttributes.map(r=>r.name)),this.source.info.vertexAttributes),this.shaders=new Map,this.sharedObject=this.registerDisposer(new eP),this.shaderGetter=Ai(this,this.gl,{memoizeKey:{t:"single_mesh/RenderLayer",attributes:this.source.info.vertexAttributes},fallbackParameters:new _.B0(Ho(Er(xS))),parameters:this.displayState.shaderControlState.builderState,encodeParameters:r=>r.key,shaderError:this.displayState.shaderError,defineShader:(r,o)=>{if(o.parseResult.errors.length!==0)throw new Error("Invalid UI control specification");Ts(o,r),this.shaderManager.defineShader(r),r.setFragmentMainFunction(ms(o.parseResult.code))}}),this.countingBuffer=this.registerDisposer($k(this.gl)),this.registerDisposer(t.shaderControlState.parseResult.changed.add(this.redrawNeeded.dispatch)),this.registerDisposer(t.shaderControlState.changed.add(this.redrawNeeded.dispatch)),this.registerDisposer(n.changed.add(this.redrawNeeded.dispatch));const{sharedObject:s}=this;s.visibility.add(this.visibility),s.RPC_TYPE_ID=Hs.nG,s.initializeCounterpart(e.chunkManager.rpc,{chunkManager:e.chunkManager.rpcId,source:e.addCounterpartRef()})}disposeShaders(){const{shaders:e}=this;for(const t of e.values())t!==null&&t.dispose();e.clear()}disposed(){this.disposeShaders(),super.disposed()}get isTransparent(){return this.displayState.fragmentMain.value.match(/emitRGBA|emitPremultipliedRGBA/)!==null}get gl(){return this.source.gl}isReady(){const e=this.source.chunks.get(Hs.b7);return!(e===void 0||e.state!==Ue.GPU_MEMORY)}draw(e,t){if(!e.emitColor&&e.alreadyEmittedPickID)return;const n=lr(this.transform.value,e.projectionParameters.displayDimensionRenderInfo,t);if(n===void 0)return;const s=this.source.chunks.get(Hs.b7);if(s===void 0||s.state!==Ue.GPU_MEMORY)return;const r=this.shaderGetter(e.emitter),{shader:o,parameters:a}=r;if(o===null)return;const{gl:l}=this,c=this.shaderManager;o.bind(),c.beginLayer(l,o,e),vi(l,o,this.displayState.shaderControlState,a.parseResult.controls);const{pickIDs:d}=e;c.beginObject(l,o,n),e.emitPickID&&c.setPickID(l,o,d.register(this,s.numIndices/3)),c.drawFragment(l,o,s,this.countingBuffer),c.endLayer(l,o)}transformPickedValue(e){const{pickedOffset:t}=e,n=this.source.chunks.get(Hs.b7);if(n===void 0)return;const s=t*3,{indices:r}=n;if(s>=r.length)return;const o=r[s],a=[],{attributeNames:l}=this.shaderManager;return n.vertexData.vertexAttributes.forEach((c,d)=>{const u=l[d];u!==void 0&&a.push(`${u}=${c[o].toPrecision(6)}`)}),a.join(", ")}}function nP(i,e,t){return i.memoize.getUncounted({type:"single_mesh:getMeshInfo",url:t},async()=>{const{url:n,credentialsProvider:s}=wn(t,e);return{info:await i.rpc.promiseInvoke(Hs.N3,{chunkManager:i.addCounterpartRef(),credentialsProvider:Eu(i,s),parameters:{meshSourceUrl:n}}),url:n,credentialsProvider:s}})}async function IS(i,e,t){const{info:n,url:s,credentialsProvider:r}=await nP(i,e,t);return i.getChunkSource(Xk,{credentialsProvider:r,parameters:{meshSourceUrl:s,info:n}})}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const LS="shader",RS="shaderControls";class Kr extends Rn{constructor(e){super(e),this.managedLayer=e,this.displayState=new Hk,this.vertexAttributes=new _.B0(void 0),this.registerDisposer(this.displayState.shaderControlState.changed.add(this.specificationChanged.dispatch)),this.registerDisposer(this.displayState.fragmentMain.changed.add(this.specificationChanged.dispatch)),this.tabs.add("rendering",{label:"Rendering",order:-100,getter:()=>new sP(this)}),this.tabs.default="rendering"}restoreState(e){super.restoreState(e),this.displayState.fragmentMain.restoreState(e[LS]),this.displayState.shaderControlState.restoreState(e[RS])}activateDataSubsources(e){let t=!1;for(const n of e){const{subsourceEntry:s}=n,{subsource:r}=s,{singleMesh:o}=r;if(o!==void 0){if(t){n.deactivate("Only one single-mesh source supported");continue}t=!0,n.activate(a=>{n.addRenderLayer(new tP(o,this.displayState,n.getRenderLayerTransform())),this.vertexAttributes.value=o.info.vertexAttributes,a.registerDisposer(()=>{this.vertexAttributes.value=void 0})});continue}n.deactivate("Not compatible with image layer")}}toJSON(){const e=super.toJSON();return e[LS]=this.displayState.fragmentMain.toJSON(),e[RS]=this.displayState.shaderControlState.toJSON(),e}}Kr.type="mesh",Kr.typeAbbreviation="mesh";function kS(i){return new Ja({fragmentMain:i.displayState.fragmentMain,shaderError:i.displayState.shaderError,shaderControlState:i.displayState.shaderControlState})}class iP extends T.O8{constructor(e){super(),this.attributes=e,this.element=document.createElement("div"),this.element.className="neuroglancer-single-mesh-attribute-widget",this.updateView(),this.registerDisposer(e.changed.add(()=>{this.updateView()}))}updateView(){const{element:e}=this,t=this.attributes.value;if(t===void 0){Me(e);return}const n=DS(t.map(r=>r.name)),s=t.length;for(let r=0;r{new rP(this.layer)}})),n.appendChild(Wa({title:"Documentation on single mesh layer rendering",href:"https://github.com/google/neuroglancer/blob/master/src/sliceview/image_layer_rendering.md"})),t.appendChild(n),t.appendChild(this.attributeWidget.element),t.appendChild(this.codeWidget.element),t.appendChild(this.registerDisposer(new ja(e.displayState.shaderControlState,this.layer.manager.root.display,this.layer,{visibility:this.visibility})).element)}}class rP extends Jr{constructor(e){super(),this.layer=e,this.attributeWidget=this.registerDisposer(PS(this.layer)),this.codeWidget=this.registerDisposer(kS(this.layer)),this.content.classList.add("neuroglancer-single-mesh-layer-shader-overlay"),this.content.appendChild(this.attributeWidget.element),this.content.appendChild(this.codeWidget.element),this.codeWidget.textEditor.refresh()}}$i(Kr),da(i=>{if(i.singleMesh!==void 0)return{layerConstructor:Kr,priority:2}}),Ya(Kr,i=>({shaderControlState:i.displayState.shaderControlState}));var Ka=G(2366);/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const AS="boss";function js(i,e,t,n,s=Je.fx){return(0,ke.Bk)(e,t,n,s).catch(r=>{if(r.status!==500&&r.status!==401&&r.status!==403&&r.status!==504)throw r;return(0,Ka.R)(i,e,t,n,o=>{const a=new Headers(t.headers);return a.set("Authorization",`Bearer ${o}`),{...t,headers:a}},o=>{const{status:a}=o;if(a===403||a===401)return"refresh";throw o},s)})}var MS=G(6650);/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class oP extends it(lt()(Kn),MS.jj){}class aP extends it(lt()(Qi),MS.Ve){}const Du=new Map;Du.set("image",St.IMAGE),Du.set("annotation",St.SEGMENTATION);const lP=new Set(["npz","jpeg"]),cP=Uint32Array.of(512,512,16);var NS=(i=>(i[i.NANOMETERS=0]="NANOMETERS",i[i.MICROMETERS=1]="MICROMETERS",i[i.MILLIMETERS=2]="MILLIMETERS",i[i.CENTIMETERS=3]="CENTIMETERS",i))(NS||{});function dP(i){switch(i){case 1:return 1e6;case 2:return 1e3;case 3:return 100;case 0:return 1e9}}function uP(i,e){(0,f.Rf)(i);const t=(0,f.cQ)(i,"voxel_unit",c=>(0,f.sl)(c,NS)),n=dP(t),s=new Float32Array(3),r=new Float64Array(3),o=new Float64Array(3),a=new Float64Array(3),l=["x","y","z"];for(let c=0;c<3;++c){const d=l[c];s[c]=(0,f.cQ)(i,`${d}_voxel_size`,f.Mo),r[c]=s[c]/n,o[c]=(0,f.cQ)(i,`${d}_start`,f.bX),a[c]=(0,f.cQ)(i,`${d}_stop`,f.bX)}return e.coordFrame={voxelSizeBaseInMeters:r,voxelSizeBaseInOriginalUnits:s,voxelOffsetBase:o,imageSizeBase:a,voxelUnit:t,names:l},e}function hP(i){let e=Du.get(i);return e===void 0&&(e=St.UNKNOWN),e}function pP(i){(0,f.Rf)(i);const e=(0,f.cQ)(i,"type",f.zr);let t=!1;return(0,f.cQ)(i,"downsample_status",f.zr)==="DOWNSAMPLED"&&(t=!0),{channelType:e,description:(0,f.cQ)(i,"description",f.zr),volumeType:hP(e),dataType:(0,f.cQ)(i,"datatype",s=>(0,f.sl)(s,R)),downsampled:t,scales:[],key:(0,f.cQ)(i,"name",f.zr),baseResolution:(0,f.cQ)(i,"base_resolution",f.bX)}}function fP(i,e,t,n,s,r){(0,f.Rf)(i);const o=(0,f.cQ)(i,"channels",a=>(0,f.$v)(a,l=>vP(e,t,n,r,s,l)));return Promise.all(o).then(a=>{const l=new Map;a.forEach(d=>{l.set(d.key,d)});const c={channels:l,scalingLevels:(0,f.cQ)(i,"num_hierarchy_levels",f.bX),coordFrameKey:(0,f.cQ)(i,"coord_frame",f.zr),coordFrame:void 0,key:(0,f.cQ)(i,"name",f.zr),collection:(0,f.cQ)(i,"collection",f.zr)};return EP(e,t,n,c)})}class gP extends ln{constructor(e,t,n,s,r,o){if(super(e),this.baseUrl=t,this.credentialsProvider=n,this.experimentInfo=s,this.parameters=o,this.meshPath=void 0,this.meshUrl=void 0,r===void 0){const u=Array.from(s.channels.keys());if(u.length!==1)throw new Error(`Experiment contains multiple channels: ${JSON.stringify(u)}`);r=u[0]}const a=s.channels.get(r);if(a===void 0)throw new Error(`Specified channel ${JSON.stringify(r)} is not one of the supported channels ${JSON.stringify(Array.from(s.channels.keys()))}`);if(this.channel=r,this.channelInfo=a,this.scales=a.scales,s.coordFrame===void 0)throw new Error(`Specified experiment ${JSON.stringify(s.key)} does not have a valid coordinate frame`);this.coordinateFrame=s.coordFrame,this.channelInfo.downsampled===!1&&(this.scales=[a.scales[0]]),this.experiment=s.key;const l=(0,f.z$)(o.window);if(l!==void 0){const u=C.Zc.create(),h=l.split(/,/);if(h.length===2)u[0]=(0,f.zo)(h[0]),u[1]=(0,f.zo)(h[1]);else if(h.length===1)u[0]=0,u[1]=(0,f.zo)(h[1]);else throw new Error(`Invalid window. Must be either one value or two comma separated values: ${JSON.stringify(l)}`);if(this.window=u,this.window[0]===this.window[1])throw new Error(`Invalid window. First element must be different from second: ${JSON.stringify(l)}.`)}const c=(0,f.z$)(o.meshurl);c!==void 0&&(this.meshUrl=c);let d=(0,f.z$)(o.encoding);if(d===void 0)d=this.dataType===R.UINT8?"jpeg":"npz";else if(!lP.has(d))throw new Error(`Invalid encoding: ${JSON.stringify(d)}.`);this.encoding=d}get dataType(){return this.channelInfo.dataType}get volumeType(){return this.channelInfo.volumeType}get rank(){return 3}getSources(e){const t=this.scales[0].downsampleFactors,{rank:n}=this;return(0,F.RO)(this.scales.map(s=>{const r=this.coordinateFrame.voxelOffsetBase,o=C.eR.create();for(let u=0;u<3;++u)o[u]=Math.ceil(r[u]);const a=s.downsampleFactors,l=n+1,c=new Float32Array(l*l);c[c.length-1]=1;for(let u=0;u<3;++u){const h=a[u]/t[u];c[l*u+u]=h,c[l*n+u]=o[u]*h}n===4&&(c[l*3+3]=1);const d=s.imageSize;return qi({rank:3,volumeType:this.volumeType,dataType:this.dataType,chunkToMultiscaleTransform:c,chunkDataSizes:[cP],baseVoxelOffset:o,upperVoxelBound:d,volumeSourceOptions:e}).map(u=>({chunkSource:this.chunkManager.getChunkSource(oP,{credentialsProvider:this.credentialsProvider,spec:u,parameters:{baseUrl:this.baseUrl,collection:this.experimentInfo.collection,experiment:this.experimentInfo.key,channel:this.channel,resolution:s.key,encoding:this.encoding,window:this.window}}),chunkToMultiscaleTransform:c}))}))}getMeshSource(){return this.meshUrl!==void 0?this.chunkManager.getChunkSource(aP,{credentialsProvider:this.credentialsProvider,parameters:{baseUrl:this.meshUrl}}):null}}const mP=/^([^/?]+)\/([^/?]+)(?:\/([^/?]+))?(?:\?(.*))?$/;function OS(i,e,t,n,s){return i.memoize.getUncounted({hostname:e,collection:s,experiment:n,type:"boss:getExperimentInfo"},()=>js(t,`${e}/latest/collection/${s}/experiment/${n}/`,{},ke.cj).then(r=>fP(r,i,e,t,s,n)))}function vP(i,e,t,n,s,r){return i.memoize.getUncounted({hostname:e,collection:s,experiment:n,channel:r,type:"boss:getChannelInfo"},()=>js(t,`${e}/latest/collection/${s}/experiment/${n}/channel/${r}/`,{},ke.cj).then(pP))}function yP(i,e,t,n,s,r){return i.memoize.getUncounted({hostname:e,collection:n,experiment:s.key,channel:r,downsample:!0,type:"boss:getDownsampleInfoForChannel"},()=>js(t,`${e}/latest/downsample/${n}/${s.key}/${r}`,{},ke.cj)).then(o=>bP(o,s,r))}function SP(i,e){(0,f.Rf)(i);const t=(0,f.cQ)(i,"voxel_size",o=>(0,f.vS)(o,f.by)),n=(0,f.cQ)(i,"extent",o=>(0,f.vS)(o,f.gG)),s=(0,f.cQ)(i,"num_hierarchy_levels",f.bX),r=new Array;for(let o=0;o{const c=await OS(i,e,t,o,r),d=await yP(i,e,t,r,c,a),u=new gP(i,e,t,d,a,l),h=d.coordFrame,p={lowerBounds:h.voxelOffsetBase,upperBounds:Float64Array.from(h.imageSizeBase,(v,y)=>h.voxelOffsetBase[y]+v)},m=Oe({rank:3,names:h.names,units:["m","m","m"],scales:h.voxelSizeBaseInMeters,boundingBoxes:[En(p)]});return{modelTransform:wt(m),subsources:[{id:"default",default:!0,subsource:{volume:u}},{id:"bounds",default:!0,subsource:{staticAnnotations:xn(p)}}]}})}const _S=/^((?:http|https):\/\/[^/?]+)\/(.*)$/;function wP(i,e,t){return i.memoize.getUncounted({hostname:e,type:"boss:getCollections"},()=>js(t,`${e}/latest/collection/`,{},ke.cj).then(n=>(0,f.cQ)(n,"collections",s=>(0,f.$v)(s,f.zr))))}function xP(i,e,t,n){return i.memoize.getUncounted({hostname:e,collection:n,type:"boss:getExperiments"},()=>js(t,`${e}/latest/collection/${n}/experiment/`,{},ke.cj).then(s=>(0,f.cQ)(s,"experiments",r=>(0,f.$v)(r,f.zr))))}function EP(i,e,t,n){const s=n.coordFrameKey;return i.memoize.getUncounted({hostname:e,coordinateframe:s,experimentInfo:n,type:"boss:getCoordinateFrame"},()=>js(t,`${e}/latest/coord/${s}/`,{},ke.cj).then(r=>uP(r,n)))}function TP(i,e,t,n){const s=n.match(/^(?:([^/]+)(?:\/?([^/]*)(?:\/?([^/]*)(?:\/?([^/]*)?))?)?)?$/);if(s===null||s[1]===void 0)return Promise.reject(null);if(s[2]===void 0){const r=s[1]||"";return wP(i,e,t).then(o=>({offset:0,completions:Ht(r,o,a=>a+"/",()=>{})}))}if(s[3]===void 0){const r=s[2]||"";return xP(i,e,t,s[1]).then(o=>({offset:s[1].length+1,completions:Ht(r,o,a=>a+"/",()=>{})}))}return OS(i,e,t,s[2],s[1]).then(r=>{const o=Ht(s[3],r.channels,a=>a[0],a=>`${a[1].channelType} (${R[a[1].dataType]})`);return{offset:s[1].length+s[2].length+2,completions:o}})}function DP(i){const e=i.match(/^(?:https:\/\/[^.]+([^/]+))/);if(e===null)throw new Error(`Unable to construct auth server hostname from base hostname ${i}.`);return`https://auth${e[1]}/auth`}class IP extends Jt{constructor(e){super(),this.credentialsManager=e}get description(){return"bossDB: Block & Object Storage System"}getCredentialsProvider(e){const t=DP(e);return this.credentialsManager.getCredentialsProvider(AS,t)}get(e){const t=e.providerUrl.match(_S);if(t===null)throw new Error(`Invalid boss volume path: ${JSON.stringify(e.providerUrl)}`);const n=this.getCredentialsProvider(e.providerUrl);return CP(e.chunkManager,t[1],n,t[2])}async completeUrl(e){const t=e.providerUrl.match(_S);if(t===null)throw null;const n=t[1],s=this.getCredentialsProvider(t[1]),r=t[2],o=await TP(e.chunkManager,n,s,r);return yi(t[1].length+1,o)}}/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const VS=new Map;function Ot(i,e){VS.set(i,e)}function LP(i){const e=new xT(i.credentialsManager);for(const[t,n]of VS)try{e.register(t,n(i))}catch(s){console.warn(`Skipping ${t} data source: ${s}`)}return e}/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */Ot("boss",i=>new IP(i.credentialsManager));/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class Nn extends T.O8{constructor(){super(...arguments),this.errorHandler=async(e,t)=>{const{status:n}=e;if(n===401||n===403&&!t.accessToken)return"refresh";throw e instanceof Error&&t.email!==void 0&&(e.message+=` (Using credentials for ${JSON.stringify(t.email)})`),e}}}function BS(i){let e,t,n;return(s,r)=>t!==void 0&&(e===void 0||s===void 0||e.generation!==s.generation)?(e===void 0&&n.addConsumer(r),t):(e=void 0,n=new Je.y3,t=i(s,n).then(o=>(e=o,n=void 0,o),o=>{throw n.isCanceled&&(n=void 0,t=void 0),o}),t)}function Xn(i){let e=0;return BS((t,n)=>i(n).then(s=>({generation:++e,credentials:s})))}class RP{constructor(){this.providers=new Map,this.topLevelManager=this}register(e,t){this.providers.set(e,t)}getCredentialsProvider(e,t){const n=this.providers.get(e);if(n===void 0)throw new Error(`No registered credentials provider: ${JSON.stringify(e)}`);return n(t,this.topLevelManager)}}class kP extends T.O8{constructor(e){super(),this.base=e,this.memoize=new rg.e}getCredentialsProvider(e,t){return this.memoize.get({key:e,parameters:t},()=>this.registerDisposer(this.base.getCredentialsProvider(e,t).addRef()))}}class PP extends kP{constructor(){super(new RP),this.base.topLevelManager=this}register(e,t){this.base.register(e,t)}}class AP extends Nn{constructor(e,t){super(),this.baseProvider=e,this.anonymousCredentials=t,this.anonymous=!0,this.get=BS(n=>this.anonymous&&n===void 0?Promise.resolve({generation:-10,credentials:this.anonymousCredentials}):(this.anonymous=!1,this.baseProvider.get(n)))}}/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const Zn=new PP;/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class MP{constructor(){this.finished=new j.HN}}class NP{constructor(){this.oidcCallbackService="bossAuthCallback",this.pendingRequests=new Map,this.registerListener()}registerListener(){addEventListener("message",e=>{if(e.origin===location.origin)try{const t=(0,f.Rf)(JSON.parse(e.data));if((0,f.zr)(t.service)===this.oidcCallbackService){const s=(0,f.zr)(t.access_token),r=(0,f.zr)(t.state),o=this.pendingRequests.get(r);if(o===void 0)return;o.finished.dispatch(s)}}catch{}})}addPendingRequest(e){const t=new MP;return this.pendingRequests.set(e,t),t.finished.add(()=>{this.pendingRequests.delete(e)}),t}makeAuthRequestUrl(e){let t=`${e.authServer}/realms/BOSS/protocol/openid-connect/auth?`;return t+=`client_id=${encodeURIComponent(e.clientId)}`,t+=`&redirect_uri=${encodeURIComponent(e.redirect_uri)}`,t+="&response_mode=fragment",t+="&response_type=code%20id_token%20token",e.state&&(t+=`&state=${e.state}`),e.nonce&&(t+=`&nonce=${e.nonce}`),t}}let Iu;function OP(){return Iu===void 0&&(Iu=new NP),Iu}function _P(i,e=Je.fx){const t=Te(),n=Te(),s=OP(),r=s.makeAuthRequestUrl({state:t,clientId:i.clientId,redirect_uri:new URL(G(2974),G.b).href,authServer:i.authServer,nonce:n}),o=s.addPendingRequest(t),a=new Promise((l,c)=>{o.finished.add((d,u)=>{d!==void 0?l(d):c(u)})});if(o.finished.add(e.add(()=>{o.finished.dispatch(void 0,Je.wS)})),!e.isCanceled){const l=open(r);l!==null&&o.finished.add(()=>{l.close()})}return a}class VP extends Nn{constructor(e){super(),this.authServer=e,this.get=Xn(t=>{const n=new pe(!0);let s;return new Promise((r,o)=>{const a=()=>{s=void 0,n.dispose()};t.add(()=>{s!==void 0&&(s.cancel(),s=void 0,n.dispose(),o(Je.wS))});function l(u="Boss authorization required.",h="Request authorization."){n.setText(u+" ");const p=document.createElement("button");p.textContent=h,n.element.appendChild(p),p.addEventListener("click",()=>{d()}),n.setVisible(!0)}const c=this.authServer;function d(){s!==void 0&&s.cancel(),s=new Je.Qi,l("Waiting for Boss authorization...","Retry"),_P({realm:"boss",clientId:"endpoint",authServer:c},s).then(u=>{s!==void 0&&(a(),r(u))},u=>{s!==void 0&&(s=void 0,l(`Boss authorization failed: ${u}.`,"Retry"))})}l()})})}}/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */Zn.register(AS,i=>new VP(i));/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const Lu="google-brainmaps";function Ys(i,e,t,n=Je.fx){return(0,Js.Y)(e,`${i.serverUrl}${t.path}`,{method:t.method,body:t.payload},t.responseType==="json"?ke.cj:ke.Rc,n)}var jt=G(2020);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class BP extends it(lt()(Kn),jt.CR){}class FP extends it(lt()(Ra),jt.Ip){}class UP extends it(lt()(Qi),jt.Ve){}class $P extends it(lt()(Oa),jt.NV){}class GP extends it(lt()(ra),jt.Rw){}const qr=new Map;qr.set("UINT8",R.UINT8),qr.set("FLOAT",R.FLOAT32),qr.set("UINT32",R.UINT32),qr.set("UINT64",R.UINT64);function zP(i){(0,f.Rf)(i);try{return{corner:(0,f.cQ)(i,"corner",e=>(0,f.DW)(C.eR.create(),e,f.zo)),size:(0,f.cQ)(i,"size",e=>(0,f.DW)(C.eR.create(),e,f.Mo)),metadata:(0,f.cQ)(i,"metadata",f.z$)}}catch(e){throw new Error(`Failed to parse bounding box: ${e.message}`)}}class WP{constructor(e){try{(0,f.Rf)(e),this.numChannels=(0,f.cQ)(e,"channelCount",f.We),this.dataType=(0,f.cQ)(e,"channelType",t=>(0,f.j3)(t,qr)),this.voxelSize=(0,f.cQ)(e,"pixelSize",t=>(0,f.DW)(C.eR.create(),t,f.Mo)),this.upperVoxelBound=(0,f.cQ)(e,"volumeSize",t=>(0,f.DW)(C.eR.create(),t,f.We)),this.boundingBoxes=(0,f.cQ)(e,"boundingBox",t=>t===void 0?[]:(0,f.$v)(t,zP))}catch(t){throw new Error(`Failed to parse BrainMaps volume geometry: ${t.message}`)}}}function HP(i){return(0,f.Rf)(i),{name:(0,f.cQ)(i,"name",f.zr),type:(0,f.cQ)(i,"type",f.zr)}}function JP(i){try{return(0,f.Rf)(i),(0,f.cQ)(i,"meshes",e=>e===void 0?[]:(0,f.$v)(e,HP))}catch(e){throw new Error(`Failed to parse BrainMaps meshes specification: ${e.message}`)}}const jP="([0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?)",Ru="([0-9]+)",FS=new RegExp(`^(.*)_${Ru}x${Ru}x${Ru}_lod([0-9]+)_${jP}$`);function YP(i,e){const t=new Map,n=i.scales[0],s=new Set;for(const o of e){if(o.type!=="TRIANGLES")continue;const a=o.name.match(FS);if(a===null)continue;const l=a[1];let c=t.get(l);c===void 0&&(c={key:l,chunkShape:C.eR.create(),lods:[]},t.set(l,c));const d=parseInt(a[5]);if(c.lods[d]!==void 0){s.add(l);continue}const u=C.eR.fromValues(parseInt(a[2],10),parseInt(a[3],10),parseInt(a[4],10)),h=new Uint32Array(3);for(let p=0;p<3;++p)h[p]=Math.ceil(n.upperVoxelBound[p]/u[p]);c.lods[d]={info:o,scale:parseFloat(a[6]),relativeBlockShape:u,gridShape:h}}const r=[];e:for(const o of t.values()){if(s.has(o.key))continue;const a=o.lods[0];if(a===void 0)continue;const l=a.relativeBlockShape;C.eR.multiply(o.chunkShape,l,n.voxelSize);for(let c=1;c{n.some(a=>a.name===o.name)||n.push(o)},r=new Set;for(const o of t){s({multi:o,single:void 0,name:o.key,partOfMultiscale:!1});for(const a of o.lods)r.add(a.info)}for(const o of e)s({single:o,multi:void 0,name:o.name,partOfMultiscale:r.has(o)});return n}class KP{constructor(e){try{(0,f.Rf)(e);const t=this.scales=(0,f.cQ)(e,"geometry",o=>(0,f.$v)(o,a=>new WP(a)));if(t.length===0)throw new Error("Expected at least one scale.");const n=t[0],s=this.numChannels=n.numChannels,r=this.dataType=n.dataType;for(let o=1,a=t.length;ol/1e9),o=[0,0,0],a=Array.from(t.upperVoxelBound);return e&&(n.push("c^"),s.push(""),r.push(1),o.push(0),a.push(this.numChannels)),Oe({names:n,units:s,scales:Float64Array.from(r),boundingBoxes:[En({lowerBounds:new Float64Array(n.length),upperBounds:Float64Array.from(a)})]})}}class qP extends ln{constructor(e,t,n,s,r,o,a){super(e),this.instance=t,this.credentialsProvider=n,this.volumeId=s,this.changeSpec=r,this.multiscaleVolumeInfo=o,this.encoding=a.encoding,this.jpegQuality=a.jpegQuality,this.chunkLayoutPreference=a.chunkLayoutPreference;let l=St.IMAGE;this.dataType===R.UINT64&&(l=St.SEGMENTATION),this.volumeType=l}get scales(){return this.multiscaleVolumeInfo.scales}get dataType(){return this.multiscaleVolumeInfo.dataType}get rank(){return this.multiscaleVolumeInfo.numChannels!==1?4:3}getSources(e){let t=jt.r7.RAW;(this.dataType===R.UINT64||this.dataType===R.UINT32)&&this.volumeType===St.SEGMENTATION&&this.encoding!==jt.r7.RAW?t=jt.r7.COMPRESSED_SEGMENTATION:this.volumeType===St.IMAGE&&this.dataType===R.UINT8&&this.multiscaleVolumeInfo.numChannels===1&&this.encoding!==jt.r7.RAW&&e.discreteValues!==!0&&(t=jt.r7.JPEG);const n=t===jt.r7.JPEG?this.jpegQuality:void 0,s=this.scales[0],{upperVoxelBound:r}=s,o=C.eR.create(),{rank:a}=this;return(0,F.RO)(this.scales.map((l,c)=>{C.eR.divide(o,l.voxelSize,s.voxelSize);let d=l.upperVoxelBound,u;const{numChannels:h}=l,p=new Float32Array((a+1)**2);p[(a+1)*a+a]=1;const m=new Float32Array(a);h!==1&&(d=Float32Array.of(...d,h),u=Uint32Array.of(1,1,1,h),p[(a+1)*3+3]=1,m[3]=h);for(let g=0;g<3;++g)p[(a+1)*g+g]=o[g],m[g]=r[g]/o[g];return qi({rank:a,minBlockSize:u,chunkToMultiscaleTransform:p,dataType:l.dataType,upperVoxelBound:d,volumeType:this.volumeType,volumeSourceOptions:e,chunkLayoutPreference:this.chunkLayoutPreference,maxCompressedSegmentationBlockSize:C.eR.fromValues(64,64,64)}).map(g=>({chunkSource:this.chunkManager.getChunkSource(BP,{credentialsProvider:this.credentialsProvider,spec:g,parameters:{volumeId:this.volumeId,changeSpec:this.changeSpec,scaleIndex:c,encoding:t,jpegQuality:n,instance:this.instance}}),chunkToMultiscaleTransform:p,upperClipBound:m}))}))}}function XP(i){const e=C.pB.create(),t=i.scales[0].voxelSize;for(let n=0;n<3;++n)e[5*n]=1/t[n];return e}function ZP(i){const e=i.match(/^([^:?/]+:[^:?/]+:[^:?/]+)(?::([^:?/]+))?(?:\/([^?]+))?(?:\?(.*))?$/);if(e===null)throw new Error(`Invalid Brain Maps volume key: ${JSON.stringify(i)}.`);let t;e[2]!==void 0&&(t={changeStackId:e[2]});const n=(0,f.bL)(e[4]||"");return{volumeId:e[1],changeSpec:t,meshName:e[3],parameters:n}}function e1(i){try{return(0,f.Rf)(i),{id:(0,f.cQ)(i,"id",f.zr),label:(0,f.cQ)(i,"label",f.zr),description:(0,f.cQ)(i,"description",f.z$)}}catch(e){throw new Error(`Failed to parse project: ${e.message}`)}}function US(i){try{return(0,f.Rf)(i),(0,f.cQ)(i,"project",e=>e===void 0?[]:(0,f.$v)(e,e1))}catch(e){throw new Error(`Error parsing project list: ${e.message}`)}}function $S(i,e){try{return(0,f.Rf)(i),(0,f.cQ)(i,e,t=>t===void 0?[]:(0,f.$v)(t,f.zr))}catch(t){throw new Error(`Error parsing dataset list: ${t.message}`)}}class a2{constructor(e,t){this.projects=new Map,this.hierarchicalVolumeIds=new Map;const{projects:n}=this;for(const s of US(e))n.set(s.id,s);try{verifyObject(t);const s=this.volumeIds=verifyObjectProperty(t,"volumeId",a=>a===void 0?[]:parseArray(a,verifyString));s.sort();const r=new Map;for(const a of s){let l=0;for(;;){let c=a.indexOf(":",l);c===-1?c=void 0:++c;const d=a.substring(0,l);let u=r.get(d);if(u===void 0&&(u=new Set,r.set(d,u)),u.add(a.substring(l,c)),c===void 0)break;l=c}}const{hierarchicalVolumeIds:o}=this;for(const[a,l]of r)o.set(a,Array.from(l))}catch(s){throw new Error(`Failed to parse Brain Maps volume list reply: ${s.message}`)}}}function t1(i){return(0,f.cQ)(i,"changeStackId",e=>e===void 0?void 0:(0,f.$v)(e,f.zr))}const n1=it(lt()(Rr),jt.rl);class i1 extends n1{constructor(e,t){super(e,{rank:3,relationships:["segments"],properties:[],...t}),this.credentialsProvider=this.registerDisposer(t.credentialsProvider.addRef())}hasNonSerializedProperties(){return!0}getSources(){const{upperVoxelBound:e}=this.parameters,t=Ko({rank:3,chunkDataSize:e,upperVoxelBound:e}),n=C.pB.create();return[[{chunkSource:this.chunkManager.getChunkSource(GP,{parent:this,spec:{limit:0,chunkToMultiscaleTransform:n,...t},parameters:this.parameters,credentialsProvider:this.credentialsProvider}),chunkToMultiscaleTransform:n}]]}}const s1=[{key:{value:"encoding",description:"Volume chunk data encoding"},values:[{value:"raw",description:""},{value:"jpeg",description:""},{value:"compressed_segmentation",description:""}]},{key:{value:"chunkLayout",description:"Volume chunk layout preference"},values:[{value:"isotropic",description:""},{value:"flat",description:""}]},{key:{value:"jpegQuality",description:"JPEG quality (1 to 100)"},values:[]}];class GS extends Jt{constructor(e,t){super(),this.instance=e,this.credentialsProvider=t}get description(){return this.instance.description}getMultiscaleInfo(e,t){return e.memoize.getUncounted({type:"brainmaps:getMultiscaleInfo",volumeId:t,instance:this.instance,credentialsProvider:xt(this.credentialsProvider)},()=>Ys(this.instance,this.credentialsProvider,{method:"GET",path:`/v1beta2/volumes/${t}`,responseType:"json"}).then(n=>new KP(n)))}getMeshesInfo(e,t){return e.memoize.getUncounted({type:"brainmaps:getMeshesInfo",volumeId:t,instance:this.instance,credentialsProvider:xt(this.credentialsProvider)},()=>Ys(this.instance,this.credentialsProvider,{method:"GET",path:`/v1beta2/objects/${t}/meshes`,responseType:"json"}).then(n=>JP(n)))}get(e){const{volumeId:t,changeSpec:n,meshName:s,parameters:r}=ZP(e.providerUrl);(0,f.Rf)(r);const o=(0,f.MM)(r,"encoding",d=>(0,f.sl)(d,jt.r7)),a=(0,f.MM)(r,"jpegQuality",d=>{const u=(0,f.bX)(d);if(u<1||u>100)throw new Error(`Expected integer in range [1, 100], but received: ${d}`);return u},70),l=(0,f.MM)(r,"chunkLayout",d=>(0,f.sl)(d,qf)),c={encoding:o,chunkLayoutPreference:l,jpegQuality:a};return e.chunkManager.memoize.getUncounted({type:"brainmaps:get",instance:this.instance,volumeId:t,changeSpec:n,brainmapsOptions:c},async()=>{const[d,u]=await Promise.all([this.getMultiscaleInfo(e.chunkManager,t),this.getMeshesInfo(e.chunkManager,t)]),h=new qP(e.chunkManager,this.instance,this.credentialsProvider,t,n,d,c),p={modelTransform:wt(d.getModelSpace(d.numChannels!==1)),subsources:[{id:s===void 0?"default":"volume",subsource:{volume:h},default:s===void 0}]},m=xn(d.box);d.scales[0].boundingBoxes.forEach((S,w)=>{m.add({type:Re.AXIS_ALIGNED_BOUNDING_BOX,description:S.metadata,pointA:S.corner,pointB:C.eR.add(C.eR.create(),S.corner,S.size),id:`boundingBox${w}`,properties:[]})}),p.subsources.push({id:"bounds",subsource:{staticAnnotations:m},default:!0});const v=QP(d,u),y=(S,w)=>{let b;const{single:x}=S;if(x!==void 0)x.type==="TRIANGLES"?b=e.chunkManager.getChunkSource(UP,{credentialsProvider:this.credentialsProvider,parameters:{instance:this.instance,volumeId:t,meshName:x.name,changeSpec:n}}):b=e.chunkManager.getChunkSource($P,{credentialsProvider:this.credentialsProvider,parameters:{instance:this.instance,volumeId:t,meshName:S.name,changeSpec:n}});else{const E=S.multi;b=e.chunkManager.getChunkSource(FP,{credentialsProvider:this.credentialsProvider,format:{fragmentRelativeVertices:!1,vertexPositionFormat:bn.Pc.float32},parameters:{instance:this.instance,volumeId:t,info:E,changeSpec:n}})}p.subsources.push({id:s===void 0?`/${S.name}`:"default",subsource:{mesh:b},subsourceToModelSubspaceTransform:XP(d),modelSubspaceDimensionIndices:[0,1,2],default:w})};if(s!==void 0){const S=v.find(w=>w.name===s);if(S===void 0)throw new Error(`Mesh/skeleton source not found: ${JSON.stringify(S)}`);y(S,!0)}else{let S=!0;for(const w of v)w.partOfMultiscale||(y(w,S),S=!1)}return n!==void 0&&p.subsources.push({id:"spatials",default:!0,modelSubspaceDimensionIndices:[0,1,2],subsource:{annotation:e.chunkManager.getChunkSource(i1,{parameters:{volumeId:t,changestack:n.changeStackId,instance:this.instance,upperVoxelBound:d.scales[0].upperVoxelBound},credentialsProvider:this.credentialsProvider})}}),p})}getProjectList(e){return e.memoize.getUncounted({instance:this.instance,type:"brainmaps:getProjectList"},()=>{const t=Ys(this.instance,this.credentialsProvider,{method:"GET",path:"/v1beta2/projects",responseType:"json"}).then(s=>US(s)),n=`${this.instance.description} project list`;return pe.forPromise(t,{delay:!0,initialMessage:`Retrieving ${n}.`,errorPrefix:`Error retrieving ${n}: `}),t})}getDatasetList(e,t){return e.memoize.getUncounted({instance:this.instance,type:`brainmaps:${t}:getDatasetList`},()=>{const n=Ys(this.instance,this.credentialsProvider,{method:"GET",path:`/v1beta2/datasets?project_id=${t}`,responseType:"json"}).then(r=>$S(r,"datasetIds")),s=`${this.instance.description} dataset list`;return pe.forPromise(n,{delay:!0,initialMessage:`Retrieving ${s}`,errorPrefix:`Error retrieving ${s}`}),n})}getVolumeList(e,t,n){return e.memoize.getUncounted({instance:this.instance,type:`brainmaps:${t}:${n}:getVolumeList`},()=>{const s=Ys(this.instance,this.credentialsProvider,{method:"GET",path:`/v1beta2/volumes?project_id=${t}&dataset_id=${n}`,responseType:"json"}).then(o=>{const a=$S(o,"volumeId"),l=t.length+n.length+2,c=[];for(const d of a)c.push(d.substring(l));return c}),r=`${this.instance.description} volume list`;return pe.forPromise(s,{delay:!0,initialMessage:`Retrieving ${r}`,errorPrefix:`Error retrieving ${r}`}),s})}getChangeStackList(e,t){return e.memoize.getUncounted({instance:this.instance,type:"brainmaps:getChangeStackList",volumeId:t},()=>{const n=Ys(this.instance,this.credentialsProvider,{method:"GET",path:`/v1beta2/changes/${t}/change_stacks`,responseType:"json"}).then(r=>t1(r)),s=`change stacks for ${t}`;return pe.forPromise(n,{delay:!0,initialMessage:`Retrieving ${s}.`,errorPrefix:`Error retrieving ${s}: `}),n})}async completeUrl(e){const{providerUrl:t}=e,n=t.match(/^([^:/?]*)(?::([^:/?]*)(?::([^:/?]*)(?::([^:/?]*))?(?:\/([^?]*))?(?:\?(.*))?)?)?$/);if(n===null)throw null;const[,s,r,o,a,l,c]=n;if(c!==void 0)return yi(t.length-c.length,await vg(c,s1));if(l!==void 0){const u=`${s}:${r}:${o}`,h=await this.getMeshesInfo(e.chunkManager,u),p=[],m=new Set;for(const g of h)if(g.name.startsWith(l))switch(g.type){case"LINE_SEGMENTS":p.push({value:g.name,description:"Skeletons"});break;case"TRIANGLES":{p.push({value:g.name,description:"Mesh (single-resolution)"});const v=g.name.match(FS);if(v!==null){const y=v[1];if(m.has(y))break;m.add(y),p.push({value:y,description:"Mesh (multi-resolution)"})}break}}return p.sort((g,v)=>(0,kr.e)(g.value,v.value)),{offset:t.length-l.length,completions:p}}if(a!==void 0){const u=`${s}:${r}:${o}`,h=await this.getChangeStackList(e.chunkManager,u);if(h===void 0)throw null;return{offset:t.length-a.length,completions:Hc(a,h)}}if(o!==void 0)return{offset:t.length-o.length,completions:Hc(o,await this.getVolumeList(e.chunkManager,s,r))};if(r!==void 0){const u=await this.getDatasetList(e.chunkManager,s);return{offset:t.length-r.length,completions:Hc(r,u.map(h=>`${h}:`))}}const d=await this.getProjectList(e.chunkManager);return{offset:0,completions:Ht(s,d,u=>`${u.id}:`,u=>u.label)}}}const r1={description:"Google Brain Maps",serverUrl:"https://brainmaps.googleapis.com"};/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */if(Ot("brainmaps",i=>new GS(r1,i.credentialsManager.getCredentialsProvider(Lu))),typeof NEUROGLANCER_BRAINMAPS_SERVERS<"u")for(const[i,e]of Object.entries(NEUROGLANCER_BRAINMAPS_SERVERS))Ot(`brainmaps-${i}`,t=>new GS(e,t.credentialsManager.getCredentialsProvider(Lu)));/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const o1="email",a1="openid",l1="https://accounts.google.com/o/oauth2/v2/auth";function c1(i){const e=i.split(".");try{if(e.length!==3)throw new Error("Invalid JWT format");const t=atob(e[1]),n=JSON.parse(t);return(0,f.Rf)(n),(0,f.cQ)(n,"email",f.zr)}catch(t){throw new Error(`Failed to decode id token: ${t.message}`)}}async function d1(i,e,t){const n=new T.O8;try{return await new Promise((s,r)=>{n.registerDisposer(t.add(()=>r(Je.wS))),n.registerEventListener(window,"message",o=>{if(o.origin===location.origin&&o.source===i)try{const a=(0,f.Rf)(o.data);if((0,f.cQ)(a,"state",f.zr)!==e)throw new Error("invalid state");const c=(0,f.cQ)(a,"id_token",f.zr),d={accessToken:(0,f.cQ)(a,"access_token",f.zr),tokenType:(0,f.cQ)(a,"token_type",f.zr),expiresIn:(0,f.cQ)(a,"expires_in",f.zr),scope:(0,f.cQ)(a,"scope",f.zr),email:c1(c)};s(d)}catch(a){r(new Error(`Received unexpected authentication response: ${a.message}`)),console.error("Response received: ",o.data)}})})}finally{n.dispose()}}function u1(i){let e=`${l1}?client_id=${encodeURIComponent(i.clientId)}`;const t=new URL(G(3956),G.b).href;e+=`&redirect_uri=${t}`;let n="token";const{scopes:s}=i;return s.includes("email")&&s.includes("openid")&&(n="token%20id_token"),e+=`&response_type=${n}`,e+="&include_granted_scopes=true",e+=`&scope=${encodeURIComponent(s.join(" "))}`,i.state&&(e+=`&state=${i.state}`),i.loginHint&&(e+=`&login_hint=${encodeURIComponent(i.loginHint)}`),i.immediate&&(e+="&immediate=true"),i.nonce!==void 0&&(e+=`&nonce=${i.nonce}`),i.authUser!==void 0&&(e+=`&authuser=${i.authUser}`),e}async function h1(i,e=Je.fx){const t=Te(),n=Te(),s=u1({state:t,nonce:n,clientId:i.clientId,scopes:i.scopes,approvalPrompt:i.approvalPrompt,loginHint:i.loginHint,immediate:i.immediate,authUser:i.authUser});let r,o;const a=[];if(i.immediate){const l=document.createElement("iframe");l.src=s,l.style.display="none",a.push(new Promise((c,d)=>{l.addEventListener("load",()=>{console.log("iframe loaded",l.contentDocument),l.contentDocument==null&&d(new Error("Immediate authentication failed"))})})),document.body.appendChild(l),r=l.contentWindow,o=()=>{at(l)}}else{const l=open(s);r=l,l!==null&&(o=()=>{try{l.close()}catch{}})}try{return await Promise.race([...a,d1(r,t,e)])}finally{o?.()}}class p1 extends Nn{constructor(e){super(),this.options=e,this.get=Xn(t=>{const{options:n}=this,s=new pe(!0);let r;return new Promise((o,a)=>{const l=()=>{r=void 0,s.dispose()};t.add(()=>{r!==void 0&&(r.cancel(),r=void 0,s.dispose(),a(Je.wS))});function c(u=`${n.description} authorization required.`,h="Request authorization."){s.setText(u+" ");const p=document.createElement("button");p.textContent=h,s.element.appendChild(p),p.addEventListener("click",()=>{d(!1)}),s.setVisible(!0)}function d(u){r!==void 0&&r.cancel(),r=new Je.Qi,c(`Waiting for ${n.description} authorization...`,"Retry"),h1({clientId:n.clientId,scopes:n.scopes,immediate:u,authUser:0},r).then(h=>{r!==void 0&&(l(),o(h))},h=>{r!==void 0&&(r=void 0,u?c():c(`${n.description} authorization failed: ${h}.`,"Retry"))})}d(!0)})})}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const f1="https://www.googleapis.com/auth/brainmaps";class g1 extends p1{constructor(e){super({clientId:e,scopes:[f1,a1,o1],description:"Brain Maps"})}}/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */Zn.register(Lu,()=>new g1("639403125587-4k5hgdfumtrvur8v48e3pr7oo91d765k.apps.googleusercontent.com"));var zS=G(5990);/** + * @license + * This work is a derivative of the Google Neuroglancer project, + * Copyright 2016 Google Inc. + * The Derivative Work is covered by + * Copyright 2019 Howard Hughes Medical Institute + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const ku="DVID";class l2{constructor(e,t){this.baseUrl=e,this.nodeKey=t}getNodeApiUrl(e=""){return`${this.baseUrl}/api/node/${this.nodeKey}${e}`}getRepoInfoUrl(){return`${this.baseUrl}/api/repos/info`}getKeyValueUrl(e,t){return`${this.getNodeApiUrl()}/${e}/key/${t}`}getKeyValueRangeUrl(e,t,n){return`${this.getNodeApiUrl()}/${e}/keyrange/${t}/${n}`}getKeyValuesUrl(e){return`${this.getNodeApiUrl()}/${e}/keyvalues?jsontar=false`}}function c2(i,e){return i.includes("?")?i+="&":i+="?",i+="app=Neuroglancer",e&&(i+=`&u=${e}`),i}function qa(i){return i.text()}function d2(i,e=uncancelableToken){const t=`${i.url}`,n={method:i.method,body:i.payload};return i.responseType===""?cancellableFetchOk(t,n,qa,e):cancellableFetchOk(t,n,responseJson,e)}function m1(i,e,t=Je.fx){return v1(i,e.url,{method:e.method,body:e.payload},e.responseType===""?qa:e.responseType==="json"?ke.cj:ke.Rc,t)}function v1(i,e,t,n,s=Je.fx){return(0,Ka.R)(i,e,t,n,(r,o)=>{const a={...o};return r.token&&(a.headers={...a.headers,Authorization:`Bearer ${r}`}),a},r=>{const{status:o}=r;if(o===403||o===401)return"refresh";throw r},s)}var Vt=G(3819);/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */async function y1(i,e,t,n,s){const r=await(0,Js.Y)(i,`https://www.googleapis.com/storage/v1/b/${e}/o?delimiter=${encodeURIComponent(n)}&prefix=${encodeURIComponent(t)}&neuroglancerOrigin=${encodeURIComponent(location.origin)}`,{},ke.cj,s);(0,f.Rf)(r);const o=(0,f.MM)(r,"prefixes",f.si,[]),a=(0,f.MM)(r,"items",l=>(0,f.$v)(l,c=>((0,f.Rf)(c),(0,f.cQ)(c,"name",f.zr))),[]).filter(l=>!l.endsWith("_$folder$"));return[...o,...a]}async function S1(i,e,t,n,s){if(!n.startsWith("/"))throw null;const o=await y1(i,t,n.substring(1),"/",s),a=n.lastIndexOf("/");return{offset:a+e.length+1,completions:o.map(l=>({value:l.substring(a)}))}}/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */async function b1(i,e,t){const{text:n,contentType:s}=await Nt(t,i,{headers:{accept:"text/html"}},async l=>({text:await l.text(),contentType:l.headers.get("content-type")}),e);if(s===null||/\btext\/html\b/i.exec(s)===null)return[];const r=new DOMParser().parseFromString(n,"text/html"),o=r.evaluate("//a/@href",r,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null),a=[];for(let l=0,c=o.snapshotLength;lu.value,u=>u.description)};const{url:n,credentialsProvider:s}=wn(e,i),r=e.length-n.length;let o;try{o=(0,ke.Dl)(n)}catch{throw null}const{protocol:a,host:l,path:c}=o,d=await(async()=>{if(a==="gs+xml"&&c.length>0)return await Tu(s,`${a}://${l}`,`https://storage.googleapis.com/${l}`,c,t);if(a==="gs"&&c.length>0)return await S1(s,`${a}://${l}`,l,c,t);if(a==="s3"&&c.length>0)return await Vk(l,c,t);const u=n.match(/^((?:http|https):\/\/(?:storage\.googleapis\.com\/[^/]+|[^/]+\.storage\.googleapis\.com|[^/]+\.s3(?:[^./]+)?\.amazonaws.com))(\/.*)$/);if(u!==null)return await Tu(s,u[1],u[1],u[2],t);if((a==="http"||a==="https")&&c.length>0)return await C1(n,t,s);throw null})();return{offset:r+d.offset,completions:d.completions}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class x1 extends it(lt()(Kn),Vt.jj){}class E1 extends it(lt()(Qi),Vt.Ve){}class T1 extends it(lt()(Ra),Vt.Ip){}class D1 extends it(lt()(Oa),Vt.NV){get skeletonVertexCoordinatesInVoxels(){return!1}get vertexAttributes(){return this.parameters.metadata.vertexAttributes}}function On(i,e){const t=i.split("/");for(const n of e.split("/")){if(n===".."&&t.length!==0){t.length=t.length-1;continue}t.push(n)}return t.join("/")}class I1{constructor(e,t){(0,f.Rf)(e);const n=t===1?3:4,s=this.resolution=new Float64Array(n),r=this.voxelOffset=new Float32Array(n),o=this.size=new Float32Array(n);if(n===4&&(s[3]=1,o[3]=t),(0,f.cQ)(e,"resolution",l=>(0,f.Xu)(s.subarray(0,3),l,f.Mo)),(0,f.MM)(e,"voxel_offset",l=>(0,f.Xu)(r.subarray(0,3),l,f.bX)),(0,f.cQ)(e,"size",l=>(0,f.Xu)(o.subarray(0,3),l,f.We)),this.chunkSizes=(0,f.cQ)(e,"chunk_sizes",l=>(0,f.$v)(l,c=>{const d=new Uint32Array(n);return n===4&&(d[3]=t),(0,f.Xu)(d.subarray(0,3),c,f.We),d})),this.chunkSizes.length===0)throw new Error("No chunk sizes specified.");if(this.sharding=(0,f.cQ)(e,"sharding",Xa),this.sharding!==void 0&&this.chunkSizes.length!==1)throw new Error("Sharding requires a single chunk size per scale");(this.encoding=(0,f.cQ)(e,"encoding",l=>(0,f.sl)(l,Vt.r7)))===Vt.r7.COMPRESSED_SEGMENTATION&&(this.compressedSegmentationBlockSize=(0,f.cQ)(e,"compressed_segmentation_block_size",l=>(0,f.Xu)(C.eR.create(),l,f.We))),this.key=(0,f.cQ)(e,"key",f.zr),this.hidden=(0,f.cQ)(e,"hidden",f.uS)??!1}}function WS(i){(0,f.Rf)(i);const e=(0,f.cQ)(i,"data_type",y=>(0,f.sl)(y,R)),t=(0,f.cQ)(i,"num_channels",f.We),n=(0,f.cQ)(i,"type",y=>(0,f.sl)(y,St)),s=(0,f.cQ)(i,"mesh",f.z$),r=(0,f.cQ)(i,"skeletons",f.z$),o=(0,f.cQ)(i,"segment_properties",f.z$),a=(0,f.cQ)(i,"scales",y=>(0,f.$v)(y,S=>new I1(S,t)));if(a.length===0)throw new Error("Expected at least one scale");const l=a[0],c=t===1?3:4,d=new Float64Array(c),u=new Float64Array(c),h=new Float64Array(c),p=["x","y","z"],m=["m","m","m"];for(let y=0;y<3;++y)d[y]=l.resolution[y]/1e9,u[y]=l.voxelOffset[y],h[y]=u[y]+l.size[y];c===4&&(d[3]=1,h[3]=t,p[3]="c^",m[3]="");const v=Oe({rank:c,names:p,units:m,scales:d,boundingBoxes:[En({lowerBounds:u,upperBounds:h})]});return{dataType:e,volumeType:n,mesh:s,skeletons:r,segmentPropertyMap:o,scales:a,modelSpace:v}}class HS extends ln{constructor(e,t,n,s){super(e),this.credentialsProvider=t,this.url=n,this.info=s}get dataType(){return this.info.dataType}get volumeType(){return this.info.volumeType}get rank(){return this.info.modelSpace.rank}getSources(e){const t=this.info.scales[0].resolution,{rank:n}=this;return(0,F.RO)(this.info.scales.filter(s=>!s.hidden).filter(s=>s.key!=="placeholder").map(s=>{const{resolution:r}=s,o=n+1,a=new Float32Array(o*o);a[a.length-1]=1;const{lowerBounds:l,upperBounds:c}=this.info.modelSpace.boundingBoxes[0].box,d=new Float32Array(n),u=new Float32Array(n);for(let h=0;h<3;++h){const p=r[h]/t[h];a[o*h+h]=p;const m=s.voxelOffset[h];a[o*n+h]=m*p,d[h]=l[h]/p-m,u[h]=c[h]/p-m}return n===4&&(a[o*3+3]=1,d[3]=l[3],u[3]=c[3]),qi({rank:n,dataType:this.dataType,chunkToMultiscaleTransform:a,upperVoxelBound:s.size,volumeType:this.volumeType,chunkDataSizes:s.chunkSizes,baseVoxelOffset:s.voxelOffset,compressedSegmentationBlockSize:s.compressedSegmentationBlockSize,volumeSourceOptions:e}).map(h=>({chunkSource:this.chunkManager.getChunkSource(x1,{credentialsProvider:this.credentialsProvider,spec:h,parameters:{url:On(this.url,s.key),encoding:s.encoding,sharding:s.sharding}}),chunkToMultiscaleTransform:a,lowerClipBound:d,upperClipBound:u}))}))}}const L1=it(lt()(Rr),Vt.rl);class R1 extends it(lt()(ra),Vt.Rw){}class k1 extends L1{constructor(e,t){const{parameters:n}=t;super(e,{rank:n.rank,relationships:n.relationships.map(s=>s.name),properties:n.properties,parameters:n}),this.readonly=!0,this.metadata=t.metadata,this.credentialsProvider=t.credentialsProvider}getSources(){return[this.metadata.spatialIndices.map(e=>{const{spec:t}=e;return{chunkSource:this.chunkManager.getChunkSource(R1,{credentialsProvider:this.credentialsProvider,parent:this,spec:t,parameters:e.parameters}),chunkToMultiscaleTransform:t.chunkToMultiscaleTransform}})]}}function P1(i,e,t){return i.getChunkSource(E1,{parameters:t,credentialsProvider:e})}function JS(i){return(0,f.cQ)(i,"transform",e=>{const t=C.pB.create();return e!==void 0&&(0,f.Xu)(t.subarray(0,12),e,f.zo),C.pB.transpose(t,t),t})}function A1(i){(0,f.Rf)(i);const e=(0,f.cQ)(i,"@type",f.zr);let t;if(e==="neuroglancer_legacy_mesh")t=void 0;else{if(e!=="neuroglancer_multilod_draco")throw new Error(`Unsupported mesh type: ${JSON.stringify(e)}`);{const s=(0,f.cQ)(i,"lod_scale_multiplier",f.Mo),r=(0,f.cQ)(i,"vertex_quantization_bits",f.We),o=JS(i),a=(0,f.cQ)(i,"sharding",Xa);t={lodScaleMultiplier:s,transform:o,sharding:a,vertexQuantizationBits:r}}}const n=(0,f.cQ)(i,"segment_properties",f.z$);return{metadata:t,segmentPropertyMap:n}}async function M1(i,e,t){let n;try{n=await Qs(i,e,t)}catch(s){if((0,ke.El)(s))return{metadata:void 0};throw s}return A1(n)}function jS(i){return i===void 0?Vt.Y1.RAW:(0,f.sl)(i,Vt.Y1)}function Xa(i){if(i===void 0)return;(0,f.Rf)(i);const e=(0,f.cQ)(i,"@type",f.zr);if(e!=="neuroglancer_uint64_sharded_v1")throw new Error(`Unsupported sharding format: ${JSON.stringify(e)}`);const t=(0,f.cQ)(i,"hash",l=>(0,f.sl)(l,Vt.TV)),n=(0,f.cQ)(i,"preshift_bits",f.bX),s=(0,f.cQ)(i,"shard_bits",f.bX),r=(0,f.cQ)(i,"minishard_bits",f.bX),o=(0,f.cQ)(i,"minishard_index_encoding",jS),a=(0,f.cQ)(i,"data_encoding",jS);return{hash:t,preshiftBits:n,shardBits:s,minishardBits:r,minishardIndexEncoding:o,dataEncoding:a}}function N1(i){(0,f.Rf)(i);const e=(0,f.cQ)(i,"@type",f.zr);if(e!=="neuroglancer_skeletons")throw new Error(`Unsupported skeleton type: ${JSON.stringify(e)}`);const t=JS(i),n=new Map;(0,f.cQ)(i,"vertex_attributes",o=>{o!==void 0&&(0,f.$v)(o,a=>{(0,f.Rf)(a);const l=(0,f.cQ)(a,"id",f.zr);if(l==="")throw new Error("vertex attribute id must not be empty");if(n.has(l))throw new Error(`duplicate vertex attribute id ${JSON.stringify(l)}`);const c=(0,f.cQ)(a,"data_type",u=>(0,f.sl)(u,R)),d=(0,f.cQ)(a,"num_components",f.We);n.set(l,{dataType:c,numComponents:d})})});const s=(0,f.cQ)(i,"sharding",Xa),r=(0,f.cQ)(i,"segment_properties",f.z$);return{metadata:{transform:t,vertexAttributes:n,sharding:s},segmentPropertyMap:r}}async function O1(i,e,t){const n=await Qs(i,e,t);return N1(n)}function YS(){return Oe({names:["x","y","z"],units:["m","m","m"],scales:Float64Array.of(1e-9,1e-9,1e-9)})}async function QS(i,e,t){const{metadata:n,segmentPropertyMap:s}=await M1(i,e,t);if(n===void 0)return{source:P1(i,e,{url:t,lod:0}),transform:C.pB.create(),segmentPropertyMap:s};let r;const{vertexQuantizationBits:o}=n;if(o===10)r=bn.Pc.uint10;else if(o===16)r=bn.Pc.uint16;else throw new Error(`Invalid vertex quantization bits: ${o}`);return{source:i.getChunkSource(T1,{credentialsProvider:e,parameters:{url:t,metadata:n},format:{fragmentRelativeVertices:!0,vertexPositionFormat:r}}),transform:n.transform,segmentPropertyMap:s}}async function KS(i,e,t){const{metadata:n,segmentPropertyMap:s}=await O1(i,e,t);return{source:i.getChunkSource(D1,{credentialsProvider:e,parameters:{url:t,metadata:n}}),transform:n.transform,segmentPropertyMap:s}}function Qs(i,e,t){return i.memoize.getUncounted({type:"precomputed:metadata",url:t,credentialsProvider:xt(e)},async()=>await Nt(e,`${t}/info`,{},ke.cj))}function qS(i){const e=C.pB.create(),t=i.scales[0].resolution;for(let n=0;n<3;++n)e[5*n]=1/t[n];return e}async function _1(i,e,t,n){const s=WS(n),r=new HS(i.chunkManager,e,t,s),{modelSpace:o}=s,a=[{id:"default",default:!0,subsource:{volume:r}},{id:"bounds",default:!0,subsource:{staticAnnotations:xn(o.bounds)}}];if(s.segmentPropertyMap!==void 0){const l=On(t,s.segmentPropertyMap),c=await Qs(i.chunkManager,e,l),d=Xr(i.chunkManager,e,c,l);a.push({id:"properties",default:!0,subsource:{segmentPropertyMap:d}})}if(s.mesh!==void 0){const l=On(t,s.mesh),{source:c,transform:d}=await QS(i.chunkManager,e,l),u=qS(s);C.pB.multiply(u,u,d),a.push({id:"mesh",default:!0,subsource:{mesh:c},subsourceToModelSubspaceTransform:u})}if(s.skeletons!==void 0){const l=On(t,s.skeletons),{source:c,transform:d}=await KS(i.chunkManager,e,l),u=qS(s);C.pB.multiply(u,u,d),a.push({id:"skeletons",default:!0,subsource:{mesh:c},subsourceToModelSubspaceTransform:u})}return{modelTransform:wt(o),subsources:a}}async function V1(i,e,t){const{source:n,transform:s,segmentPropertyMap:r}=await KS(i.chunkManager,e,t),o=[{id:"default",default:!0,subsource:{mesh:n},subsourceToModelSubspaceTransform:s}];if(r!==void 0){const a=On(t,r),l=await Qs(i.chunkManager,e,a),c=Xr(i.chunkManager,e,l,a);o.push({id:"properties",default:!0,subsource:{segmentPropertyMap:c}})}return{modelTransform:wt(YS()),subsources:o}}function Pu(i,e){return(0,f.Rf)(e),{url:On(i,(0,f.cQ)(e,"key",f.zr)),sharding:(0,f.cQ)(e,"sharding",Xa)}}class B1{constructor(e,t){this.url=e,(0,f.Rf)(t);const n=(0,f.cQ)(t,"dimensions",uo),{rank:s}=n,r=(0,f.cQ)(t,"lower_bound",a=>(0,f.Xu)(new Float64Array(s),a,f.zo)),o=(0,f.cQ)(t,"upper_bound",a=>(0,f.Xu)(new Float64Array(s),a,f.zo));this.coordinateSpace=Oe({rank:s,names:n.names,units:n.units,scales:n.scales,boundingBoxes:[En({lowerBounds:r,upperBounds:o})]}),this.parameters={type:(0,f.cQ)(t,"annotation_type",a=>(0,f.sl)(a,Re)),rank:s,relationships:(0,f.cQ)(t,"relationships",a=>(0,f.$v)(a,l=>{const c=Pu(e,l),d=(0,f.cQ)(l,"id",f.zr);return{...c,name:d}})),properties:(0,f.cQ)(t,"properties",Dh),byId:(0,f.cQ)(t,"by_id",a=>Pu(e,a))},this.spatialIndices=(0,f.cQ)(t,"spatial",a=>(0,f.$v)(a,l=>{const c=Pu(e,l),d=(0,f.cQ)(l,"grid_shape",v=>(0,f.Xu)(new Float32Array(s),v,f.We)),u=(0,f.cQ)(l,"chunk_size",v=>(0,f.Xu)(new Float32Array(s),v,f.Mo)),h=(0,f.cQ)(l,"limit",f.We),p=new Float32Array(s);for(let v=0;v{r=(0,f.si)(r);const o=r.length,a=new Uint32Array(o*2);for(let l=0;l(0,f.$v)(r,o=>{(0,f.Rf)(o);const a=(0,f.cQ)(o,"id",f.zr),l=(0,f.MM)(o,"description",f.zr),c=(0,f.cQ)(o,"type",u=>{if(u!=="label"&&u!=="description"&&u!=="string"&&u!=="tags"&&u!=="number")throw new Error(`Invalid property type: ${JSON.stringify(u)}`);return u});if(c==="tags"){const u=(0,f.cQ)(o,"tags",f.si);let h=(0,f.MM)(o,"tag_descriptions",f.si);if(h===void 0)h=new Array(u.length),h.fill("");else if(h.length!==u.length)throw new Error(`Expected tag_descriptions to have length: ${u.length}`);const p=(0,f.cQ)(o,"values",m=>{if(!Array.isArray(m)||m.length!==n)throw new Error(`Expected ${n} values, but received: ${m.length}`);return m.map(g=>String.fromCharCode(...g))});return{id:a,description:l,type:c,tags:u,tagDescriptions:h,values:p}}if(c==="number"){const u=(0,f.cQ)(o,"data_type",g=>(0,f.sl)(g,R));if(u===R.UINT64)throw new Error("uint64 properties not supported");const h=(0,f.cQ)(o,"values",g=>{if(!Array.isArray(g)||g.length!==n)throw new Error(`Expected ${n} values, but received: ${g.length}`);return J[u].from(g)});let p=1/0,m=-1/0;for(let g=h.length-1;g>=0;--g){const v=h[g];vm&&(m=v)}return{id:a,description:l,type:c,dataType:u,values:h,bounds:[p,m]}}const d=(0,f.cQ)(o,"values",u=>{if((0,f.si)(u),u.length!==n)throw new Error(`Expected ${n} values, but received: ${u.length}`);return u});return{id:a,description:l,type:c,values:d}}));return lI({ids:t,properties:s})}const u2=it(lt()(nI),Vt.vq);function Xr(i,e,t,n){try{const s=(0,f.cQ)(t,"@type",f.zr);if(s!=="neuroglancer_segment_properties")throw new Error(`Unsupported segment property map type: ${JSON.stringify(s)}`);const r=(0,f.MM)(t,"inline",U1);return new rv({inlineProperties:r})}catch(s){throw new Error(`Error parsing segment property map: ${s.message}`)}}async function $1(i,e,t,n){return{modelTransform:wt(ki),subsources:[{id:"default",default:!0,subsource:{segmentPropertyMap:Xr(i.chunkManager,e,n,t)}}]}}const G1=/^([^#]*)(?:#(.*))?$/;function ns(i){let[,e,t]=i.match(G1);e.endsWith("/")&&(e=e.substring(0,e.length-1));const n=(0,f.bL)(t||"");return{url:e,parameters:n}}function Za(i,e){const t=(0,f.uz)(e);return t&&(i+=`#${t}`),i}class ZS extends Jt{get description(){return"Precomputed file-backed data source"}normalizeUrl(e){const{url:t,parameters:n}=ns(e.providerUrl);return e.providerProtocol+"://"+Za(t,n)}convertLegacyUrl(e){const{url:t,parameters:n}=ns(e.providerUrl);return e.type==="mesh"&&(n.type="mesh"),e.providerProtocol+"://"+Za(t,n)}get(e){const{url:t,parameters:n}=ns(e.providerUrl);return e.chunkManager.memoize.getUncounted({type:"precomputed:get",providerUrl:t,parameters:n},async()=>{const{url:s,credentialsProvider:r}=wn(t,e.credentialsManager);let o;try{o=await Qs(e.chunkManager,r,s)}catch(c){if((0,ke.El)(c)&&n.type==="mesh")return await XS(e,r,s);throw c}(0,f.Rf)(o);const a=(0,f.MM)(o,"redirect",f.zr);if(a!==void 0)throw new Jc(a);const l=(0,f.MM)(o,"@type",f.zr);switch(l){case"neuroglancer_skeletons":return await V1(e,r,s);case"neuroglancer_multilod_draco":case"neuroglancer_legacy_mesh":return await XS(e,r,s);case"neuroglancer_annotations_v1":return await F1(e,r,s,o);case"neuroglancer_segment_properties":return await $1(e,r,s,o);case"neuroglancer_multiscale_volume":case void 0:return await _1(e,r,s,o);default:throw new Error(`Invalid type: ${JSON.stringify(l)}`)}})}completeUrl(e){return ts(e.credentialsManager,e.providerUrl,e.cancellationToken)}}/** + * @license + * Copyright 2016 Google Inc., 2023 Gergely Csucs + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class z1 extends it(lt()(Kn),zS.D){}function W1(i){const{width:e,height:t,tilesize:n,overlap:s,format:r}=i,o=(0,f.sl)(r,zS.j),a=new Array;let l=e,c=t;for(;l>1||c>1;)a.push({width:l,height:c}),l=Math.ceil(l/2),c=Math.ceil(c/2);a.push({width:l,height:c});const d=3,u=Float64Array.of(1/1e9,1/1e9,1),h=new Float64Array(d),p=Float64Array.of(e,t,3),y=Oe({rank:d,names:["x","y","c^"],units:["m","m",""],scales:u,boundingBoxes:[En({lowerBounds:h,upperBounds:p})]});return{levels:a,modelSpace:y,overlap:s,tilesize:n,format:r,encoding:o}}class H1 extends ln{constructor(e,t,n,s){super(e),this.credentialsProvider=t,this.info=s,this.url=n.substring(0,n.lastIndexOf("."))+"_files"}get dataType(){return R.UINT8}get volumeType(){return St.IMAGE}get rank(){return this.info.modelSpace.rank}getSources(e){const{rank:t}=this,n=[Uint32Array.of(this.info.tilesize,this.info.tilesize,3)];return(0,F.RO)(this.info.levels.map((s,r,o)=>{const a=1<({chunkSource:this.chunkManager.getChunkSource(z1,{credentialsProvider:this.credentialsProvider,spec:h,parameters:{url:On(this.url,(o.length-1-r).toString()),encoding:this.info.encoding,format:this.info.format,overlap:this.info.overlap,tilesize:this.info.tilesize}}),chunkToMultiscaleTransform:c,upperClipBound:u}))}))}}function J1(i,e,t){if(t.endsWith(".json")||t.includes(".json?"))throw new Error("DZI-JSON: OpenSeadragon hack not supported yet.");return i.memoize.getUncounted({type:"deepzoom:metadata",url:t,credentialsProvider:xt(e)},async()=>{const n=await Nt(e,t,{},qa),r=new DOMParser().parseFromString(n,"text/xml").documentElement,o=(0,f.Rf)(r.getElementsByTagName("Size").item(0));return{width:(0,f.We)(o.getAttribute("Width")),height:(0,f.We)(o.getAttribute("Height")),tilesize:(0,f.We)((0,f.zr)(r.getAttribute("TileSize"))),overlap:(0,f.bX)((0,f.zr)(r.getAttribute("Overlap"))),format:(0,f.zr)(r.getAttribute("Format"))}})}async function j1(i,e,t,n){const s=W1(n),r=new H1(i.chunkManager,e,t,s),{modelSpace:o}=s,a=[{id:"default",default:!0,subsource:{volume:r}},{id:"bounds",default:!0,subsource:{staticAnnotations:xn(o.bounds)}}];return{modelTransform:wt(o),subsources:a}}class Y1 extends Jt{get description(){return"Deep Zoom file-backed data source"}normalizeUrl(e){const{url:t,parameters:n}=ns(e.providerUrl);return e.providerProtocol+"://"+Za(t,n)}convertLegacyUrl(e){const{url:t,parameters:n}=ns(e.providerUrl);return e.providerProtocol+"://"+Za(t,n)}get(e){const{url:t,parameters:n}=ns(e.providerUrl);return e.chunkManager.memoize.getUncounted({type:"deepzoom:get",providerUrl:t,parameters:n},async()=>{const{url:s,credentialsProvider:r}=wn(t,e.credentialsManager),o=await J1(e.chunkManager,r,s);return j1(e,r,s,o)})}completeUrl(e){return ts(e.credentialsManager,e.providerUrl,e.cancellationToken)}}/** + * @license + * Copyright 2017 Google Inc., 2023 Gergely Csucs + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */Ot("deepzoom",()=>new Y1);var Yt=G(8820);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const el=new Map;el.set("uint8",R.UINT8),el.set("uint32",R.UINT32),el.set("uint64",R.UINT64);class Q1{constructor(e){this.obj=e,(0,f.Rf)(e),(0,f.cQ)(e,"TypeName",f.zr)}get typeName(){return this.obj.TypeName}get compressionName(){return this.obj.Compression}}class K1{constructor(e,t,n){this.obj=e,this.name=t,this.base=n}}class q1 extends it(lt()(Kn),Yt.jj){}class X1 extends it(lt()(Oa),Yt.NV){}class Z1 extends it(lt()(Qi),Yt.Ve){}class tl extends K1{constructor(e,t,n,s,r){super(e,t,n),this.encoding=s;const o=(0,f.cQ)(e,"Extended",f.Rf),a=(0,f.cQ)(o,"Values",c=>(0,f.$v)(c,f.Rf));if(a.length<1)throw new Error("Expected Extended.Values property to have length >= 1, but received: ${JSON.stringify(extendedValues)}.");this.numLevels=1;const l=new Set(r);if(s===Yt.r7.COMPRESSED_SEGMENTATIONARRAY){const c=(0,f.cQ)(o,"MaxDownresLevel",f.We);this.numLevels=c+1}else for(;l.has(t+"_"+this.numLevels.toString());)this.numLevels+=1;l.has(t+"_meshes")?this.meshSrc=t+"_meshes":this.meshSrc="",l.has(t+"_skeletons")?this.skeletonSrc=t+"_skeletons":this.skeletonSrc="",this.dataType=(0,f.cQ)(a[0],"DataType",c=>(0,f.j3)(c,el)),this.voxelSize=(0,f.cQ)(o,"VoxelSize",c=>(0,f.Xu)(C.eR.create(),c,f.Mo)),this.blockSize=(0,f.cQ)(o,"BlockSize",c=>(0,f.Xu)(C.eR.create(),c,f.Mo)),this.lowerVoxelBound=(0,f.cQ)(o,"MinPoint",c=>(0,f.vp)(C.eR.create(),c)),this.upperVoxelBoundInclusive=(0,f.cQ)(o,"MaxPoint",c=>(0,f.vp)(C.eR.create(),c))}get volumeType(){return this.encoding===Yt.r7.COMPRESSED_SEGMENTATION||this.encoding===Yt.r7.COMPRESSED_SEGMENTATIONARRAY?St.SEGMENTATION:St.IMAGE}getSources(e,t,n,s){const{encoding:r}=this,o=[],a=64;for(let l=0;l0&&(p+="_"+l.toString());const m={baseUrl:t.baseUrl,nodeKey:t.nodeKey,dataInstanceKey:p,dataScale:l.toString(),encoding:r},g=C.pB.create();for(let y=0;y<3;++y)g[5*y]=c,g[12+y]=u[y]*c;const v=qi({rank:3,chunkToMultiscaleTransform:g,dataType:this.dataType,baseVoxelOffset:u,upperVoxelBound:C.eR.subtract(C.eR.create(),h,u),volumeType:this.volumeType,volumeSourceOptions:n,compressedSegmentationBlockSize:r===Yt.r7.COMPRESSED_SEGMENTATION||r===Yt.r7.COMPRESSED_SEGMENTATIONARRAY?C.eR.fromValues(8,8,8):void 0}).map(y=>({chunkSource:e.getChunkSource(q1,{spec:y,parameters:m,credentialsProvider:s}),chunkToMultiscaleTransform:g}));o.push(v)}return(0,F.RO)(o)}}function eA(i,e,t){(0,f.Rf)(i);const n=(0,f.cQ)(i,"Base",s=>new Q1(s));switch(n.typeName){case"uint8blk":case"grayscale8":{const s=n.compressionName.indexOf("jpeg")!==-1;return new tl(i,e,n,s?Yt.r7.JPEG:Yt.r7.RAW,t)}case"labels64":case"labelblk":return new tl(i,e,n,Yt.r7.COMPRESSED_SEGMENTATION,t);case"labelarray":case"labelmap":return new tl(i,e,n,Yt.r7.COMPRESSED_SEGMENTATIONARRAY,t);default:throw new Error(`DVID data type ${JSON.stringify(n.typeName)} is not supported.`)}}class nl{constructor(e){if(this.errors=[],this.dataInstances=new Map,this.vnodes=new Set,e instanceof nl){this.alias=e.alias,this.description=e.description,this.errors=e.errors,this.dataInstances=e.dataInstances;return}(0,f.Rf)(e),this.alias=(0,f.cQ)(e,"Alias",f.zr),this.description=(0,f.cQ)(e,"Description",f.zr);const t=(0,f.cQ)(e,"DataInstances",f.Rf),n=Object.keys(t);for(const o of n)try{this.dataInstances.set(o,eA(t[o],o,n))}catch(a){const l=`Failed to parse data instance ${JSON.stringify(o)}: ${a.message}`;console.log(l),this.errors.push(l)}const s=(0,f.cQ)(e,"DAG",f.Rf),r=(0,f.cQ)(s,"Nodes",f.Rf);for(const o of Object.keys(r))this.vnodes.add(o)}}function tA(i){try{const e=(0,f.vS)(i,n=>new nl(n)),t=new Map;for(const[n,s]of e){t.set(n,s);for(const r of s.vnodes)if(r!==n){const o=new nl(s);t.set(r,o)}}for(const[n,s]of t)s.uuid=n;return t}catch(e){throw new Error(`Failed to parse DVID repositories info: ${e.message}`)}}class nA{constructor(e){this.repositories=tA(e)}getNode(e){const t=[];for(const n of this.repositories.keys())n.startsWith(e)&&t.push(n);if(t.length!==1)throw new Error(`Node key ${JSON.stringify(e)} matches ${JSON.stringify(t)} nodes.`);return this.repositories.get(t[0])}}function e0(i,e,t){return i.memoize.getUncounted({type:"dvid:getServerInfo",baseUrl:e},()=>{const n=m1(t,{url:`${e}/api/repos/info`,method:"GET",responseType:"json"}).then(r=>new nA(r)),s=`repository info for DVID server ${e}`;return pe.forPromise(n,{initialMessage:`Retrieving ${s}.`,delay:!0,errorPrefix:`Error retrieving ${s}: `}),n})}class iA extends ln{constructor(e,t,n,s,r,o){super(e),this.baseUrl=t,this.nodeKey=n,this.dataInstanceKey=s,this.info=r,this.credentialsProvider=o}get dataType(){return this.info.dataType}get volumeType(){return this.info.volumeType}get rank(){return 3}getSources(e){return this.info.getSources(this.chunkManager,{baseUrl:this.baseUrl,nodeKey:this.nodeKey,dataInstanceKey:this.dataInstanceKey},e,this.credentialsProvider)}}const sA=/^((?:http|https):\/\/[^/]+)\/([^/]+)\/([^/]+)(\?.*)?$/;function t0(i){if(i.startsWith("https"))return i+"/api/server/token"}function rA(i){const e=i.match(sA);if(e===null)throw new Error(`Invalid DVID URL: ${JSON.stringify(i)}.`);const t={baseUrl:e[1],nodeKey:e[2],dataInstanceKey:e[3]},n=e[4];if(n&&n.length>1){const s=(0,f.bL)(n.substring(1));s.user&&(t.user=s.user)}return t.authServer=t0(t.baseUrl),t}function oA(i,e,t,n){const s=e.baseUrl,r=e.nodeKey,o=e.dataInstanceKey,a=t,l={lowerBounds:new Float64Array(a.lowerVoxelBound),upperBounds:Float64Array.from(a.upperVoxelBoundInclusive,h=>h+1)},c=Oe({rank:3,names:["x","y","z"],units:["m","m","m"],scales:Float64Array.from(a.voxelSize,h=>h/1e9),boundingBoxes:[En(l)]}),d=new iA(i.chunkManager,s,r,o,a,n),u={modelTransform:wt(c),subsources:[{id:"default",subsource:{volume:d},default:!0}]};if(a.meshSrc){const h=C.pB.create();for(let p=0;p<3;++p)h[5*p]=1/a.voxelSize[p];u.subsources.push({id:"meshes",default:!0,subsource:{mesh:i.chunkManager.getChunkSource(Z1,{parameters:{...e,dataInstanceKey:a.meshSrc},credentialsProvider:n})},subsourceToModelSubspaceTransform:h})}return a.skeletonSrc&&u.subsources.push({id:"skeletons",default:!0,subsource:{mesh:i.chunkManager.getChunkSource(X1,{parameters:{...e,dataInstanceKey:a.skeletonSrc},credentialsProvider:n})}}),u.subsources.push({id:"bounds",subsource:{staticAnnotations:xn(l)},default:!0}),u}function aA(i){const e=rA(i.providerUrl),{baseUrl:t,nodeKey:n,dataInstanceKey:s}=e;return i.chunkManager.memoize.getUncounted({type:"dvid:MultiscaleVolumeChunkSource",baseUrl:t,nodeKey:n,dataInstanceKey:s},async()=>{const r=i.credentialsManager.getCredentialsProvider(ku,{dvidServer:e.baseUrl,authServer:e.authServer}),a=(await e0(i.chunkManager,t,r)).getNode(n);if(a===void 0)throw new Error(`Invalid node: ${JSON.stringify(n)}.`);const l=a.dataInstances.get(s);if(!(l instanceof tl))throw new Error(`Invalid data instance ${s}.`);return oA(i,e,l,r)})}function lA(i,e){return{offset:0,completions:Ht(e,i.dataInstances.values(),t=>t.name,t=>`${t.base.typeName}`)}}function cA(i,e){const t=e.match(/^(?:([^/]+)(?:\/([^/]*))?)?$/);if(t===null)throw new Error("Invalid DVID URL syntax.");if(t[2]===void 0)return{offset:0,completions:Ht(e,i.repositories.values(),r=>r.uuid+"/",r=>`${r.alias}: ${r.description}`)};const n=t[1],s=i.getNode(n);return yi(n.length+1,lA(s,t[2]))}async function dA(i){const e=/^((?:http|https):\/\/[^/]+)\/([^?]*).*$/,n=i.providerUrl.match(e);if(n===null)throw null;const s=n[1],r=n[2],o=t0(s),a=await e0(i.chunkManager,s,i.credentialsManager.getCredentialsProvider(ku,{dvidServer:s,authServer:o}));return yi(s.length+1,cA(a,r))}class uA extends Jt{constructor(e){super(),this.credentialsManager=e}get description(){return"DVID"}get(e){return aA(e)}completeUrl(e){return dA(e)}}/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */Ot("dvid",i=>new uA(i.credentialsManager));/** + * @license + * This work is a derivative of the Google Neuroglancer project, + * Copyright 2016 Google Inc. + * The Derivative Work is covered by + * Copyright 2019 Howard Hughes Medical Institute + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */async function hA(i,e=Je.fx){return{token:await(0,ke.Bk)(i,{method:"GET",credentials:"include"},qa,e)}}class pA extends Nn{constructor(e){super(),this.authServer=e,this.get=Xn(t=>{if(!this.authServer)return Promise.resolve({token:""});const n=new pe(!0);let s;return new Promise((r,o)=>{const a=()=>{s=void 0,n.dispose()};t.add(()=>{s!==void 0&&(s.cancel(),s=void 0,n.dispose(),o(Je.wS))});function l(d,u="DVID authorization required.",h="Request authorization."){n.setText(u+" ");const p=document.createElement("button");p.textContent=h,n.element.appendChild(p),p.addEventListener("click",()=>{const m=d.match(/^[^/]+\/\/[^/.]+\.([^/]+)/);if(m){const g=`https://flyemlogin.${m[1]}/login`;window.alert(`Please log into ${g} and then refresh the neurogalncer page to try again. +If you are unable to log into ${g}, please check your authorization server ${d} to make sure it is correct.`)}else window.alert(`Please check your authorization server ${d} to make sure it is correct.`)}),n.setVisible(!0)}function c(d){s!==void 0&&s.cancel(),s=new Je.Qi,l(d,"Waiting for DVID authorization...","Retry"),hA(d,s).then(u=>{s!==void 0&&(a(),r(u))},u=>{s!==void 0&&(s=void 0,l(d,`DVID authorization failed: ${u}.`,"Retry"))})}c(this.authServer)})})}}class fA extends AP{constructor(e,t){super(new pA(t),{})}}/** + * @license + * This work is a derivative of the Google Neuroglancer project, + * Copyright 2016 Google Inc. + * The Derivative Work is covered by + * Copyright 2019 Howard Hughes Medical Institute + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */Zn.register(ku,i=>new fA(i.dvidServer,i.authServer));/** + * @license + * Copyright 2019 The Neuroglancer Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const Zr=1,gA="GrapheneMeshSource:NewSegment";var mA=(i=>(i[i.RAW=0]="RAW",i[i.JPEG=1]="JPEG",i[i.COMPRESSED_SEGMENTATION=2]="COMPRESSED_SEGMENTATION",i))(mA||{});class vA{}vA.RPC_ID="graphene/VolumeChunkSource";class n0{}n0.RPC_ID="graphene/ChunkedGraphSource";class i0{}i0.RPC_ID="graphene/MeshSource";class h2{}const eo=async i=>i;function s0(i,e){const t=P.R.rshift(new P.R,i,64-e);return P.R.equal(t,P.R.ONE)}function yA(i){if(i.charAt(0)==="~"){const t=i.substring(1).split(/:(.+)/);return{key:t[0],fragmentId:t[1]}}return{key:i,fragmentId:i}}const SA="ChunkedGraphLayer",bA="ChunkedGraphLayer:updateSources",p2=5;function CA(i){const{rank:e,dataType:t}=i,{baseVoxelOffset:n=new Float32Array(e)}=i;return{...Ko(i),baseVoxelOffset:n,dataType:t}}/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function Au(i){return new Date(i.getTime()-i.getTimezoneOffset()*6e4).toISOString().slice(0,-8)}class wA extends T.O8{constructor(e,t,n){super(),this.model=e,this.element=document.createElement("input"),this.registerDisposer(e.changed.add(()=>this.updateView()));const{element:s}=this;s.type="datetime-local",t&&this.setMin(t),n&&this.setMax(n),this.registerEventListener(s,"change",()=>this.updateModel()),this.updateView()}setMin(e){const{element:t}=this;t.min=Au(e)}setMax(e){const{element:t}=this;t.max=Au(e)}disposed(){at(this.element)}updateView(){this.model.value?this.element.value=Au(new Date(this.model.value)):this.element.value=""}updateModel(){try{this.element.value?this.model.restoreState(new Date(this.element.value).valueOf()):this.model.restoreState(0)}catch{}this.updateView()}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function il(i,e=0){const t=C.ln.clone([...i]);return t[3]=e,t}const sl=C.eR.fromValues(1,0,0),Mu=C.eR.fromValues(0,0,1),xA=il(sl,.5),EA=il(Mu,.5),TA=il(sl,.25),DA=il(Mu,.25),IA=C.ln.fromValues(.5,.5,.5,.01),LA=new P.R(Ie(xA)),RA=new P.R(Ie(EA)),kA=new P.R(Ie(IA)),PA=C.ln.fromValues(0,0,0,.5),AA=C.eR.fromValues(1,1,1);class MA extends it(lt()(Qi),i0){getFragmentKey(e,t){return yA(t)}}class NA{constructor(e,t){const n=/^(https?:\/\/[.\w:\-/]+)\/segmentation\/(?:1\.0|table)\/([^/]+)\/?$/,s=e.match(n);if(s===null)throw Error(`Graph URL invalid: ${e}`);this.table=s[2];const{table:r}=this;this.segmentationUrl=`${s[1]}/segmentation/api/v${Zr}/table/${r}`,this.meshingUrl=`${s[1]}/meshing/api/v${Zr}/table/${r}`,this.l2CacheUrl=`${s[1]}/l2cache/api/v${Zr}`;try{(0,f.Rf)(t),this.supported_api_versions=(0,f.cQ)(t,"supported_api_versions",o=>(0,f.$v)(o,f.B8))}catch{this.supported_api_versions=[0]}if(!(Zr in this.supported_api_versions)){const o=`This Neuroglancer branch requires Graph Server version ${Zr}, but the server only supports version(s) ${this.supported_api_versions}.`;throw new Error(o)}}}const OA=8;class _A{constructor(e){(0,f.Rf)(e),this.chunkSize=(0,f.cQ)(e,"chunk_size",t=>(0,f.Xu)(C.eR.create(),t,f.We)),this.nBitsForLayerId=(0,f.MM)(e,"n_bits_for_layer_id",f.We,OA)}}function VA(i,e,t){const n=WS(i),s=(0,f.cQ)(i,"data_dir",a=>wn(a,t)).url,r=(0,f.cQ)(i,"app",a=>new NA(e,a)),o=(0,f.cQ)(i,"graph",a=>new _A(a));return{...n,app:r,graph:o,dataUrl:s}}class BA extends HS{constructor(e,t,n){super(e,void 0,n.dataUrl,n),this.chunkedGraphCredentialsProvider=t,this.info=n}getChunkedGraphSource(){const{rank:e}=this,t=this.info.scales[0],n=CA({rank:e,dataType:this.info.dataType,upperVoxelBound:t.size,chunkDataSize:Uint32Array.from(this.info.graph.chunkSize),baseVoxelOffset:t.voxelOffset}),s=e+1,r=new Float32Array(s*s);r[r.length-1]=1;const{lowerBounds:o,upperBounds:a}=this.info.modelSpace.boundingBoxes[0].box,l=new Float32Array(e),c=new Float32Array(e);for(let d=0;d<3;++d)r[s*d+d]=1,r[s*e+d]=t.voxelOffset[d],l[d]=o[d],c[d]=a[d];return{chunkSource:this.chunkManager.getChunkSource(tM,{spec:n,credentialsProvider:this.chunkedGraphCredentialsProvider,parameters:{url:`${this.info.app.segmentationUrl}/node`}}),chunkToMultiscaleTransform:r,lowerClipBound:l,upperClipBound:c}}}function r0(i){return(0,f.cQ)(i,"transform",e=>{const t=C.pB.create();return e!==void 0&&(0,f.Xu)(t.subarray(0,12),e,f.zo),C.pB.transpose(t,t),t})}function FA(i){(0,f.Rf)(i);const e=(0,f.cQ)(i,"@type",f.zr);let t;if(e==="neuroglancer_legacy_mesh"){const s=(0,f.cQ)(i,"sharding",a0);s===void 0?t=void 0:t={lodScaleMultiplier:0,transform:r0(i),sharding:s,vertexQuantizationBits:10}}else{if(e!=="neuroglancer_multilod_draco")throw new Error(`Unsupported mesh type: ${JSON.stringify(e)}`);{const s=(0,f.cQ)(i,"lod_scale_multiplier",f.Mo),r=(0,f.cQ)(i,"vertex_quantization_bits",f.We),o=r0(i),a=(0,f.cQ)(i,"sharding",a0);t={lodScaleMultiplier:s,transform:o,sharding:a,vertexQuantizationBits:r}}}const n=(0,f.cQ)(i,"segment_properties",f.z$);return{metadata:t,segmentPropertyMap:n}}async function UA(i,e,t){let n;try{n=await Nu(i,e,t)}catch(s){if((0,ke.El)(s))return{metadata:void 0};throw s}return FA(n)}function o0(i){return i===void 0?Vt.Y1.RAW:(0,f.sl)(i,Vt.Y1)}function $A(i){if(i===void 0)return;(0,f.Rf)(i);const e=(0,f.cQ)(i,"@type",f.zr);if(e!=="neuroglancer_uint64_sharded_v1")throw new Error(`Unsupported sharding format: ${JSON.stringify(e)}`);const t=(0,f.cQ)(i,"hash",l=>(0,f.sl)(l,Vt.TV)),n=(0,f.cQ)(i,"preshift_bits",f.bX),s=(0,f.cQ)(i,"shard_bits",f.bX),r=(0,f.cQ)(i,"minishard_bits",f.bX),o=(0,f.cQ)(i,"minishard_index_encoding",o0),a=(0,f.cQ)(i,"data_encoding",o0);return{hash:t,preshiftBits:n,shardBits:s,minishardBits:r,minishardIndexEncoding:o,dataEncoding:a}}function a0(i){if(i===void 0)return;(0,f.Rf)(i);const e=new Array;for(const t in i){const n=Number(t);e[n]=$A(i[n])}return e}function GA(i,e,t){return i.getChunkSource(MA,{parameters:e,credentialsProvider:t})}async function zA(i,e,t,n,s){const{metadata:r,segmentPropertyMap:o}=await UA(i,void 0,n),a={manifestUrl:t,fragmentUrl:n,lod:0,sharding:r?.sharding,nBitsForLayerId:s},l=r?.transform||C.pB.create();return{source:GA(i,a,e),transform:l,segmentPropertyMap:o}}function Nu(i,e,t){return i.memoize.getUncounted({type:"graphene:metadata",url:t,credentialsProvider:xt(e)},async()=>await Nt(e,`${t}/info`,{},ke.cj))}function WA(i){const e=C.pB.create(),t=i.scales[0].resolution;for(let n=0;n<3;++n)e[5*n]=1/t[n];return e}async function HA(i,e,t,n){const s=VA(n,t,i.credentialsManager),r=new BA(i.chunkManager,e,s),o=new QA;i.state&&o.restoreState(i.state);const a=new ll(s,e,r,o),{modelSpace:l}=s,c=[{id:"default",default:!0,subsource:{volume:r}},{id:"graph",default:!0,subsource:{segmentationGraph:a}},{id:"bounds",default:!0,subsource:{staticAnnotations:xn(l.bounds)}}];if(s.segmentPropertyMap!==void 0){const d=On(t,s.segmentPropertyMap),u=await Nu(i.chunkManager,e,d),h=Xr(i.chunkManager,e,u,d);c.push({id:"properties",default:!0,subsource:{segmentPropertyMap:h}})}if(s.mesh!==void 0){const{source:d,transform:u}=await zA(i.chunkManager,e,s.app.meshingUrl,On(s.dataUrl,s.mesh),s.graph.nBitsForLayerId),h=WA(s);C.pB.multiply(h,h,u),c.push({id:"mesh",default:!0,subsource:{mesh:d},subsourceToModelSubspaceTransform:h})}return{modelTransform:wt(l),subsources:c,state:o}}class JA extends ZS{get description(){return"Graphene file-backed data source"}get(e){const{url:t,parameters:n}=ns(e.providerUrl);return e.chunkManager.memoize.getUncounted({type:"graphene:get",providerUrl:t,parameters:n},async()=>{const{url:s,credentialsProvider:r}=wn(t,e.credentialsManager);let o;try{o=await Nu(e.chunkManager,r,s)}catch(c){throw(0,ke.El)(c)&&n.type==="mesh"&&console.log("does this happen?"),c}(0,f.Rf)(o);const a=(0,f.MM)(o,"redirect",f.zr);if(a!==void 0)throw new Jc(a);const l=(0,f.MM)(o,"@type",f.zr);switch(l){case"neuroglancer_multiscale_volume":case void 0:return await HA(e,r,s,o);default:throw new Error(`Invalid type: ${JSON.stringify(l)}`)}})}}function to(i){for(const e of i.dataSources){const{loadState:t}=e;if(!(t===void 0||t.error!==void 0)){for(const n of t.subsources)if(n.enabled&&n.subsourceEntry.id==="graph")return n}}}function rl(i,e,t,n){const{subsourceEntry:s}=e,r=new Ih(e.loadedDataSource.transform,new _.B0([]),["associated segments"]),o=new Yf;o.color.value.set(n),o.relationshipStates.set("associated segments",{segmentationState:new _.B0(i.displayState),showMatches:new nt(!1)});const a=new jo({localPosition:i.localPosition,transform:e.getRenderLayerTransform(),source:r,displayState:o,dataSource:e.loadedDataSource.layerDataSource,subsourceIndex:e.subsourceIndex,subsourceId:s.id,subsubsourceId:t,role:li.ANNOTATION});return i.addAnnotationLayerState(a,e),a}function jA(i,e){return(0,f.MM)(i,e,t=>P.R.parseString(String(t)))}function l0(i,e){return(0,f.cQ)(i,e,t=>P.R.parseString(String(t)))}function no(i){const e=l0(i,d0),t=l0(i,u0),n=(0,f.cQ)(i,h0,s=>(0,f.f4)(s));return{segmentId:e,rootId:t,position:n}}const Ks=i=>({[d0]:i.segmentId.toJSON(),[u0]:i.rootId.toJSON(),[h0]:[...i.position]}),c0="id",d0="segmentId",u0="rootId",h0="position",p0="sink",ol="source",f0="timestamp",g0="multicut",m0="focusSegment",v0="sinks",y0="sources",S0="merge",b0="merges",C0="autosubmit",YA="locked",w0="mergedRoot",x0="error",E0="findPath",T0="target",D0="centroids",I0="precision";class QA extends T.O8{constructor(){super(),this.changed=new j.IY,this.timestamp=new _.DN(0,e=>e),this.multicutState=new XA,this.mergeState=new KA,this.findPathState=new qA,this.registerDisposer(this.timestamp.changed.add(()=>{this.multicutState.reset(),this.changed.dispatch()})),this.registerDisposer(this.multicutState.changed.add(()=>{this.changed.dispatch()})),this.registerDisposer(this.mergeState.changed.add(()=>{this.changed.dispatch()})),this.registerDisposer(this.findPathState.changed.add(()=>{this.changed.dispatch()}))}replaceSegments(e,t){this.multicutState.replaceSegments(e,t),this.mergeState.replaceSegments(e,t),this.findPathState.replaceSegments(e,t)}reset(){this.timestamp.reset(),this.multicutState.reset(),this.mergeState.reset(),this.findPathState.reset()}toJSON(){return{[f0]:this.timestamp.toJSON(),[g0]:this.multicutState.toJSON(),[S0]:this.mergeState.toJSON(),[E0]:this.findPathState.toJSON()}}restoreState(e){(0,f.MM)(e,f0,t=>{this.timestamp.restoreState(t)}),(0,f.MM)(e,g0,t=>{this.multicutState.restoreState(t)}),(0,f.MM)(e,S0,t=>{this.mergeState.restoreState(t)}),(0,f.MM)(e,E0,t=>{this.findPathState.restoreState(t)})}}class KA extends T.O8{constructor(){super(),this.changed=new j.IY,this.merges=new _.B0([]),this.autoSubmit=new nt(!1),this.registerDisposer(this.merges.changed.add(this.changed.dispatch))}replaceSegments(e,t){const{merges:{value:n}}=this,s=t.size===1?[...t][0]:void 0;for(const r of n){if(r.source&&e.has(r.source.rootId))if(s)r.source.rootId=s;else{this.reset();return}if(r.sink&&e.has(r.sink.rootId))if(s)r.sink.rootId=s;else{this.reset();return}}}reset(){this.merges.value=[],this.autoSubmit.reset()}toJSON(){const{merges:e,autoSubmit:t}=this,n=s=>{const r={[c0]:s.id,[YA]:s.locked,[p0]:Ks(s.sink),[ol]:Ks(s.source)};return s.mergedRoot&&(r[w0]=s.mergedRoot.toJSON()),s.error&&(r[x0]=s.error),r};return{[b0]:e.value.filter(s=>s.source).map(n),[C0]:t.toJSON()}}restoreState(e){function t(s){const r=jA(s,w0),o=(0,f.cQ)(s,c0,f.zr),a=(0,f.MM)(s,x0,f.zr),l=!1,c=no(s[p0]),d=no(s[ol]);return{id:o,locked:l,sink:c,source:d,mergedRoot:r,error:a}}const n=s=>(0,f.$v)(s,r=>t(r));this.merges.value=(0,f.cQ)(e,b0,n),this.autoSubmit.restoreState((0,f.MM)(e,C0,f.aO))}}class qA extends T.O8{constructor(){super(),this.changed=new j.IY,this.triggerPathUpdate=new j.IY,this.source=new _.DN(void 0,e=>e),this.target=new _.DN(void 0,e=>e),this.centroids=new _.DN([],e=>e),this.precisionMode=new nt(!0),this.registerDisposer(this.source.changed.add(()=>{this.centroids.reset(),this.changed.dispatch()})),this.registerDisposer(this.target.changed.add(()=>{this.centroids.reset(),this.changed.dispatch()})),this.registerDisposer(this.centroids.changed.add(this.changed.dispatch))}get path(){const e=[],{source:{value:t},target:{value:n},centroids:{value:s}}=this;if(!t||!n||s.length===0)return e;for(let a=0;a{this.source.restoreState(no(t))}),(0,f.MM)(e,T0,t=>{this.target.restoreState(no(t))}),(0,f.MM)(e,D0,t=>{this.centroids.restoreState(t)}),(0,f.MM)(e,I0,t=>{this.precisionMode.restoreState(t)})}}class XA extends T.O8{constructor(e=new _.DN(void 0,n=>n),t=new _.B0(!1)){super(),this.focusSegment=e,this.blueGroup=t,this.changed=new j.IY,this.sinks=new _._Y,this.sources=new _._Y;const n=()=>{this.sinks.size===0&&this.sources.size===0&&(this.focusSegment.value=void 0)};this.registerDisposer(e.changed.add(this.changed.dispatch)),this.registerDisposer(this.sinks.changed.add(n)),this.registerDisposer(this.sources.changed.add(n)),this.registerDisposer(this.blueGroup.changed.add(this.changed.dispatch)),this.registerDisposer(this.sinks.changed.add(this.changed.dispatch)),this.registerDisposer(this.sources.changed.add(this.changed.dispatch))}replaceSegments(e,t){const n=t.size===1?[...t][0]:void 0,{focusSegment:{value:s}}=this;if(s&&e.has(s))if(n){this.focusSegment.value=n;for(const r of this.sinks)r.rootId=n;for(const r of this.sources)r.rootId=n;this.changed.dispatch()}else this.reset()}reset(){this.focusSegment.reset(),this.blueGroup.value=!1,this.sinks.clear(),this.sources.clear()}toJSON(){const{focusSegment:e,sinks:t,sources:n}=this;return{[m0]:e.toJSON(),[v0]:[...t].map(Ks),[y0]:[...n].map(Ks)}}restoreState(e){const t=r=>(0,f.$v)(r,o=>no(o));(0,f.MM)(e,m0,r=>{this.focusSegment.restoreState(P.R.parseString(String(r)))});const n=(0,f.cQ)(e,v0,t),s=(0,f.cQ)(e,y0,t);for(const r of n)this.sinks.add(r);for(const r of s)this.sources.add(r)}swapGroup(){this.blueGroup.value=!this.blueGroup.value}get activeGroup(){return this.blueGroup.value?this.sources:this.sinks}get segments(){return[...this.redSegments,...this.blueSegments]}get redSegments(){return[...this.sinks].filter(e=>!P.R.equal(e.segmentId,e.rootId)).map(e=>e.segmentId)}get blueSegments(){return[...this.sources].filter(e=>!P.R.equal(e.segmentId,e.rootId)).map(e=>e.segmentId)}}class is extends _d{constructor(e,t,n,s){super(e,t.displayState.segmentationGroupState.value),this.graph=e,this.layer=t,this.chunkSource=n,this.state=s,this.annotationLayerStates=[],this.operationIds=[],this.lastDeselectionMessageExists=!1,this.deleteMergeSubmission=m=>{const{mergeAnnotationState:g}=this;m.locked=!1,g.source.delete(g.source.getReference(m.id))},this.submitMerge=async(m,g=1)=>{const y=to(this.layer).loadedDataSource.transform.inputSpace.value.scales.map(S=>S/1e-9);m.error=void 0;for(let S=1;S<=g;S++)try{const w=await this.graph.graphServer.mergeSegments(qs(m.sink,y),qs(m.source,y)),{mergeRoot:b,operationId:x}=w;pe.showTemporaryMessage(`Operation ID ${x}`,3e3),this.operationIds.push(x);const E=new qn;E.add(m.sink.rootId),E.add(m.source.rootId);const D=new qn;return D.add(b),this.state.replaceSegments(E,D),b}catch(w){if(S===g)throw m.error=w.message||"unknown",w}return P.R.ZERO};const r=t.displayState.segmentationGroupState.value;this.previousVisibleSegmentCount=r.visibleSegments.size,this.registerDisposer(r.selectedSegments.changed.add((m,g)=>{m!==null&&(m=Array().concat(m)),this.selectedSegmentsChanged(m,g)})),this.registerDisposer(r.visibleSegments.changed.add((m,g)=>{m!==null&&(m=Array().concat(m)),this.visibleSegmentsChanged(m,g)}));const{annotationLayerStates:o,state:{multicutState:a,findPathState:l}}=this;this.registerDisposer(s.timestamp.changed.add(()=>{r.selectedSegments.clear(),r.temporaryVisibleSegments.clear()}));const c=to(t),d=rl(t,c,"sinks",sl),u=rl(t,c,"sources",Mu);R0(a.sinks,d),R0(a.sources,u),o.push(d,u),t.tool.value instanceof io&&(t.tool.value=void 0),this.mergeAnnotationState=rl(t,c,"grapheneMerge",sl);{const{mergeState:m}=s,{merges:g,autoSubmit:v}=m,{mergeAnnotationState:y}=this,{visibleSegments:S}=r;for(const w of g.value)y.source.add(dM(w));this.registerDisposer(y.source.childAdded.add(w=>{const b=w;b.relatedSegments[0].map(D=>S.has(D))[0]===!1?(setTimeout(()=>{const{tool:D}=t;D.value instanceof io&&D.value.deactivate()},0),pe.showTemporaryMessage("Cannot merge a hidden segment.")):g.value.length{const{tool:D}=t;D.value instanceof io&&D.value.deactivate()},0),pe.showTemporaryMessage(`Maximum of ${M0} simultanous merges allowed.`))})),this.registerDisposer(y.source.childCommitted.add(w=>{const b=y.source.getReference(w),x=b.value;if(x){const E=x.relatedSegments[0],D=E.map(L=>S.has(L));E.length<4&&(y.source.delete(b),pe.showTemporaryMessage("Cannot merge segment with itself.")),D[2]===!1&&(y.source.delete(b),pe.showTemporaryMessage("Cannot merge a hidden segment."));const I=g.value.find(L=>L.id===b.id);if(I&&!I?.locked){const L=A0(x,!1);I.sink=L.sink,I.source=L.source,g.changed.dispatch(),v.value&&this.bulkMerge([I])}}b.dispose()})),this.registerDisposer(y.source.childDeleted.add(w=>{let b=!1;const x=g.value.filter(E=>{const D=E.id!==w||E.locked;return D||(b=!0),D});b&&(g.value=x)}))}const h=rl(t,c,"findpath",AA);this.findPathAnnotationState=h,h.source.childDeleted.add(m=>{l.source.value?.annotationReference?.id===m&&(l.source.value=void 0),l.target.value?.annotationReference?.id===m&&(l.target.value=void 0)});const p=()=>{const{path:m,source:g,target:v}=l,y=h.source;g.value&&!g.value.annotationReference&&cl(y,g.value,"find path source"),v.value&&!v.value.annotationReference&&cl(y,v.value,"find path target");for(const S of y)S.id!==g.value?.annotationReference?.id&&S.id!==v.value?.annotationReference?.id&&y.delete(y.getReference(S.id));for(const S of m)y.add(S)};this.registerDisposer(l.changed.add(p)),this.registerDisposer(l.triggerPathUpdate.add(()=>{const g=to(this.layer).loadedDataSource.transform.inputSpace.value.scales.map(v=>v/1e-9);this.submitFindPath(l.precisionMode.value,g).then(v=>{})})),p()}createRenderLayers(e,t,n){return[new nM(e,this.chunkSource.getChunkedGraphSource(),t,n,this.graph.info.graph.nBitsForLayerId)]}visibleSegmentsChanged(e,t){const{segmentsState:n}=this,{focusSegment:{value:s}}=this.graph.state.multicutState;if(s&&!n.visibleSegments.has(s)&&(n.selectedSegments.has(s)?pe.showTemporaryMessage("Can't hide active multicut segment.",3e3):pe.showTemporaryMessage("Can't deselect active multicut segment.",3e3),n.selectedSegments.add(s),n.visibleSegments.add(s),e&&(e=e.filter(r=>!P.R.equal(r,s)))),e===null){this.segmentsState.segmentEquivalences.clear(),pe.showTemporaryMessage(`Hid all ${this.previousVisibleSegmentCount} segment(s).`,3e3);return}for(const r of e)if(!t&&!s0(r,this.graph.info.graph.nBitsForLayerId)){const o=[...n.segmentEquivalences.setElements(r)].length;n.segmentEquivalences.deleteSet(r),this.lastDeselectionMessage&&this.lastDeselectionMessageExists&&(this.lastDeselectionMessage.dispose(),this.lastDeselectionMessageExists=!1),this.lastDeselectionMessage=pe.showMessage(`Hid ${o} segment(s).`),this.lastDeselectionMessageExists=!0,setTimeout(()=>{this.lastDeselectionMessageExists&&(this.lastDeselectionMessage.dispose(),this.lastDeselectionMessageExists=!1)},2e3)}this.previousVisibleSegmentCount=n.visibleSegments.size}selectedSegmentsChanged(e,t){const{segmentsState:n}=this;if(e===null){const s=this.segmentsState.selectedSegments.size;pe.showTemporaryMessage(`Deselected all ${s} segment(s).`,3e3);return}for(const s of e){const r=s0(s,this.graph.info.graph.nBitsForLayerId),o=s.clone();t&&r&&this.graph.getRoot(o).then(a=>{n.visibleSegments.has(o)&&n.visibleSegments.add(a),n.selectedSegments.delete(o),n.selectedSegments.add(a)})}}computeSplit(e,t){}getMeshSource(){const{layer:e}=this;for(const t of e.dataSources){const{loadState:n}=t;if(n instanceof Yc){const{subsources:s}=n.dataSource,r=s.filter(a=>a.id==="graph")[0];if(r&&r.subsource.segmentationGraph&&r.subsource.segmentationGraph!==this.graph)continue;const o=s.filter(a=>a.id==="mesh")[0];if(o)return o.subsource.mesh}}}meshAddNewSegments(e){const t=this.getMeshSource();if(t)for(const n of e)t.rpc.invoke(gA,{rpcId:t.rpcId,segment:n.toString()})}async submitMulticut(e){const{state:{multicutState:t}}=this,{sinks:n,sources:s}=t;if(n.size===0||s.size===0)return pe.showTemporaryMessage("Must select both red and blue groups to perform a multi-cut.",7e3),!1;{const r=await this.graph.graphServer.splitSegments([...n].map(l=>qs(l,e)),[...s].map(l=>qs(l,e))),{splitRoots:o,operationId:a}=r;if(o.length===0)return pe.showTemporaryMessage("No split found.",3e3),!1;{console.log("Operation ID:",a),pe.showTemporaryMessage(`Operation ID ${a}`,3e3),this.operationIds.push(a);const l=t.focusSegment.value;t.reset();const{segmentsState:c}=this;c.selectedSegments.delete(l);for(const h of[...n,...s])c.selectedSegments.delete(h.rootId);this.meshAddNewSegments(o),c.selectedSegments.add(o),c.visibleSegments.add(o);const d=new qn;d.add(l);const u=new qn;return u.add(o),this.state.replaceSegments(d,u),!0}}}async bulkMerge(e){const{merges:t}=this.state.mergeState,n=d=>new Promise(u=>{if(d.length===0){u([]);return}const h=[];let p=0,m=0;const g=(v,y)=>{if(p===d.length||y.length===0)return;m++;let S=[];const w=()=>{b++,b===y.length&&(m-=1),m===0&&u(h)};let b=0;for(const x of y){x.locked=!0,x.status="trying...",t.changed.dispatch();const E=[x.source.rootId,x.sink.rootId];this.submitMerge(x,3).then(D=>{h.push(...E),x.status="done",x.mergedRoot=D,t.changed.dispatch(),p+=1,g(p,S),S=[],w(),cM(5e3).then(()=>{this.deleteMergeSubmission(x)})}).catch(()=>{t.changed.dispatch(),S.push(x),p>v&&(g(p,S),S=[]),w()})}};g(p,d)});e=e.filter(d=>!d.locked&&d.source);const s=await n(e),r=[];for(const d of e){d.error?(d.locked=!1,d.status=d.error):d.mergedRoot&&r.push(d.mergedRoot);const u=await this.graph.graphServer.filterLatestRoots(r),h=this.layer.displayState.segmentationGroupState.value,{visibleSegments:p,selectedSegments:m}=h;m.delete(s),this.meshAddNewSegments(u),m.add(u),p.add(u),t.changed.dispatch()}const o=this.layer.displayState.segmentationGroupState.value,{visibleSegments:a,selectedSegments:l}=o;l.delete(s);const c=await this.graph.graphServer.filterLatestRoots(r);l.add(c),a.add(c),t.changed.dispatch()}async submitFindPath(e,t){const{state:{findPathState:n}}=this,{source:s,target:r}=n;if(!s.value||!r.value)return!1;const o=await this.graph.findPath(s.value,r.value,e,t);return pe.showTemporaryMessage("Path found!",5e3),n.centroids.value=o,!0}}async function L0(i){if(i.response){let e;return i.response.headers.get("content-type")==="application/json"?e=(await i.response.json()).message:e=await i.response.text(),e}}async function al(i,e){let t,n=()=>{};e.initialMessage&&(t=new pe(!0),t.setText(e.initialMessage),n=t.dispose.bind(t));try{const s=await i;return n(),s}catch(s){if(s instanceof ke.j$&&s.response){const{errorPrefix:r=""}=e,o=await L0(s)||"unknown error";throw t||(t=new pe(!0)),t.setErrorMessage(r+o),t.setVisible(!0),new Error(`[${s.response.status}] ${r}${o}`)}throw s}}const qs=(i,e)=>{const{rootId:t,segmentId:n,position:s}=i;return{rootId:t,segmentId:n,position:s.map((r,o)=>r*e[o])}},Ou=Symbol("Graph Server Not Specified.");class ZA{constructor(e,t){this.url=e,this.credentialsProvider=t}async getTimestampLimit(){const e=await Nt(this.credentialsProvider,`${this.url}/oldest_timestamp`,{},ke.cj),t=(0,f.cQ)(e,"iso",f.zr);return new Date(t).valueOf()}async getRoot(e,t=0){const n=t/1e3,s=`${this.url}/node/${String(e)}/root?int64_as_str=1${t>0?`×tamp=${n}`:""}`,r=Nt(this.credentialsProvider,s,{},eo),a=await(await al(r,{initialMessage:`Retrieving root for segment ${e}`,errorPrefix:"Could not fetch root: "})).json();return P.R.parseString(a.root_id)}async mergeSegments(e,t){const{url:n}=this;if(n==="")return Promise.reject(Ou);const s=Nt(this.credentialsProvider,`${n}/merge?int64_as_str=1`,{method:"POST",body:JSON.stringify([[String(e.segmentId),...e.position],[String(t.segmentId),...t.position]])},eo);try{const o=await(await s).json(),a=P.R.parseString(o.new_root_ids[0]),l=P.R.parseString(o.operation_id);return{mergeRoot:a,operationId:l}}catch(r){if(r instanceof ke.j$){const o=await L0(r);throw new Error(o)}throw r}}async splitSegments(e,t){const{url:n}=this;if(n==="")return Promise.reject(Ou);const s=Nt(this.credentialsProvider,`${n}/split?int64_as_str=1`,{method:"POST",body:JSON.stringify({sources:e.map(c=>[String(c.segmentId),...c.position]),sinks:t.map(c=>[String(c.segmentId),...c.position])})},eo),o=await(await al(s,{initialMessage:`Splitting ${e.length} sources from ${t.length} sinks`,errorPrefix:"Split failed: "})).json(),a=new Array(o.new_root_ids.length);for(let c=0;ca.toJSON())})},eo),r=await(await al(n,{errorPrefix:"Could not check latest: "})).json(),o=[];for(const[a,l]of r.is_latest.entries())l&&o.push(e[a]);return o}async findPath(e,t,n){const{url:s}=this;if(s==="")return Promise.reject(Ou);const r=Nt(this.credentialsProvider,`${s}/graph/find_path?int64_as_str=1&precision_mode=${Number(n)}`,{method:"POST",body:JSON.stringify([[String(e.rootId),...e.position],[String(t.rootId),...t.position]])},eo),a=await(await al(r,{initialMessage:`Finding path between ${e.segmentId} and ${t.segmentId}`,errorPrefix:"Path finding failed: "})).json(),c=(0,f.cQ)(a,"centroids_list",p=>(0,f.$v)(p,f.pf)),u=a["failed_l2_ids"];u&&u.length>0&&pe.showTemporaryMessage("Some level 2 meshes are missing, so the path shown may have a poor level of detail.");const h=(0,f.MM)(a,"l2_path",f.si);return{centroids:c,l2_path:h}}}class ll extends Od{constructor(e,t,n,s){super(),this.info=e,this.credentialsProvider=t,this.chunkSource=n,this.state=s,this.connections=new Set,this.l2CacheAvailable=void 0,this.timestampLimit=new _.DN(0,r=>r),this.graphServer=new ZA(e.app.segmentationUrl,t),this.graphServer.getTimestampLimit().then(r=>{this.timestampLimit.value=r})}connect(e){const t=new is(this,e,this.chunkSource,this.state);return this.connections.add(t),t.registerDisposer(()=>{this.connections.delete(t)}),t}get visibleSegmentEquivalencePolicy(){return Rt.y6.MAX_REPRESENTATIVE|Rt.y6.NONREPRESENTATIVE_EXCLUDED}async isL2CacheUrlAvailable(){if(this.l2CacheAvailable!==void 0)return this.l2CacheAvailable;try{const{l2CacheUrl:e,table:t}=this.info.app,n=await Nt(void 0,`${e}/table_mapping`,{},ke.cj);return this.l2CacheAvailable=!!(n&&n[t]),this.l2CacheAvailable}catch(e){return console.error("e",e),!1}}getRoot(e){return this.graphServer.getRoot(e,this.state.timestamp.value)}async findPath(e,t,n,s){const{l2CacheUrl:r,table:o}=this.info.app,a=n&&await this.isL2CacheUrlAvailable();let{centroids:l,l2_path:c}=await this.graphServer.findPath(qs(e,s),qs(t,s),n&&!a);if(n&&a&&c){const u=`${r}/table/${o}/attributes`;try{const h=await Nt(this.credentialsProvider,u,{method:"POST",body:JSON.stringify({l2_ids:c})},ke.cj);l=c.map(p=>(0,f.MM)(h,p,m=>(0,f.VH)(m.rep_coord_nm))).filter(p=>p!==void 0)}catch(h){console.log("e",h)}}return l.map(u=>u.map((h,p)=>h/s[p]))}tabContents(e,t,n){const s=document.createElement("div");s.style.display="contents";const r=document.createElement("div");r.className="neuroglancer-segmentation-toolbox",s.appendChild(fa(n,e,n.visibility,k0)),r.appendChild(Wn(t,e.toolBinder,{toolJson:_u,label:"Multicut",title:"Multicut segments"})),r.appendChild(Wn(t,e.toolBinder,{toolJson:Vu,label:"Merge",title:"Merge segments"})),r.appendChild(Wn(t,e.toolBinder,{toolJson:Bu,label:"Find Path",title:"Find Path"})),s.appendChild(r),s.appendChild(t.registerDisposer(new iM(e,e.annotationDisplayState)).element);const o=n.element;return o.classList.add("neuroglancer-annotations-tab"),o.classList.add("neuroglancer-graphene-tab"),s}async merge(e,t){return new P.R}async split(e,t){return{include:e,exclude:t}}trackSegment(e,t){return()=>{console.log("trackSegment... do nothing",e,t)}}}class eM extends Lr{constructor(e,t){super(e,t)}}class tM extends it(lt()(eM),n0){}class nM extends Fi{constructor(e,t,n,s,r){super(),this.chunkManager=e,this.source=t,this.displayState=n,this.localPosition=s,this.layerChunkProgressInfo=new fo,this.leafRequestsActive=this.registerDisposer(ft.make(e.rpc,!0)),this.chunkTransform=this.registerDisposer((0,_.ol)(a=>bo(()=>po(sc(a))),this.displayState.transform));const o=this.sharedObject=this.backend=this.registerDisposer(new Ia(e,n,this.layerChunkProgressInfo));o.RPC_TYPE_ID=SA,o.initializeCounterpartWithChunkManager({source:t.chunkSource.addCounterpartRef(),localPosition:this.registerDisposer(ft.makeFromExisting(e.rpc,this.localPosition)).rpcId,leafRequestsActive:this.leafRequestsActive.rpcId,nBitsForLayerId:this.registerDisposer(ft.make(e.rpc,r)).rpcId}),this.registerDisposer(o.visibility.add(this.visibility)),this.registerDisposer(this.leafRequestsActive.changed.add(()=>{this.showOrHideMessage(this.leafRequestsActive.value)}))}attach(e){super.attach(e);const t=this.chunkTransform.value,n=e.view.displayDimensionRenderInfo.value;e.state={chunkTransform:t,displayDimensionRenderInfo:n},e.state.source=e.registerDisposer((0,_.no)((s,r,o)=>{const a=sa(o,r,l=>[[this.source]],e.messages,this);return e.view.flushBackendProjectionParameters(),this.sharedObject.rpc.invoke(bA,{layer:this.sharedObject.rpcId,view:e.view.rpcId,displayDimensionRenderInfo:o,sources:ta(a)}),a[0][0]},this.displayState.transform,e.view.displayDimensionRenderInfo))}isReady(){return!0}showOrHideMessage(e){this.leafRequestsStatusMessage&&e?(this.leafRequestsStatusMessage.dispose(),this.leafRequestsStatusMessage=void 0,pe.showTemporaryMessage("Loading chunked graph segmentation...",3e3)):!this.leafRequestsStatusMessage&&!e&&(this.leafRequestsStatusMessage=pe.showMessage("At this zoom level, chunked graph segmentation will not be loaded. Please zoom in if you wish to load it."))}}const _u="grapheneMulticutSegments",Vu="grapheneMergeSegments",Bu="grapheneFindPath";class iM extends hy{constructor(e,t){super(e,t),this.layer=e,this.displayState=t;const{graphConnection:{value:n}}=e;if(n instanceof is)for(const s of n.annotationLayerStates)this.annotationStates.add(s)}get annotationStates(){return this._annotationStates===void 0&&(this._annotationStates=this.registerDisposer(new ly)),this._annotationStates}}const cl=(i,e,t)=>{const n={id:"",point:e.position,type:Re.POINT,properties:[],relatedSegments:[[e.segmentId,e.rootId]],description:t},s=i.add(n);e.annotationReference=s},R0=(i,e)=>{const t=e.source;t.childDeleted.add(n=>{const s=[...i].find(r=>r.annotationReference?.id===n);s&&i.delete(s)}),i.changed.add((n,s)=>{if(n===null){for(const r of t)t.delete(t.getReference(r.id));return}s?cl(t,n):n.annotationReference&&t.delete(n.annotationReference)});for(const n of i)cl(t,n)};function sM(i,e){const n=to(e).getRenderLayerTransform(),s=bo(()=>po(sc(n.value)));if(s.error!==void 0)return;const r=new Float32Array(s.modelTransform.unpaddedRank);if(gs(r,i,e.localPosition.value,s.layerRank,s.combinedGlobalLocalToChunkTransform))return r}const rM=(i,e)=>{if(e.updateUnconditionally())return sM(e.unsnappedPosition,i)},k0={label:"Time",title:"View segmentation at earlier point of time",toolJson:"grapheneTime",...oM()};gd(Ct,k0);function oM(){return{makeControl:(i,e)=>{const t=i.displayState.segmentationGroupState.value,{graph:{value:n}}=t,s=n instanceof ll?n.state.timestamp:new _.DN(0,c=>c),r=n instanceof ll?n.timestampLimit:new _.DN(0,c=>c),o=document.createElement("div");o.classList.add("neuroglancer-time-control");const a=new _.DN(s.value,c=>c);a.changed.add(()=>{a.value!==s.value&&n instanceof ll&&(!(t.selectedSegments.size+t.temporaryVisibleSegments.size>0)||confirm("Changing graphene time will clear all selected segments.")?s.value=a.value:a.value=s.value)});const l=e.registerDisposer(new wA(a,new Date(r.value),new Date));return r.changed.add(()=>{l.setMin(new Date(r.value))}),s.changed.add(()=>{s.value!==a.value&&(a.value=s.value)}),o.appendChild(l.element),{controlElement:o,control:l}},activateTool:i=>{}}}const P0=(i,e)=>i.value!==0?(pe.showTemporaryMessage("Editing can not be performed with a segmentation at an older state."),e.cancel(),!0):!1,aM=Ae.fromObject({"at:shift?+control+mousedown0":{action:"set-anchor"},"at:shift?+keyg":{action:"swap-group"},"at:shift?+enter":{action:"submit"}});class lM extends gi{toJSON(){return _u}activate(e){const{layer:t}=this,{graphConnection:{value:n}}=t;if(!n||!(n instanceof is)){e.cancel();return}const{state:{multicutState:s,timestamp:r},segmentsState:o}=n;if(P0(r,e)||(e.registerDisposer(r.changed.add(()=>{e.cancel()})),s===void 0))return;const{body:a,header:l}=Vi(e);l.textContent="Multicut segments",a.classList.add("graphene-tool-status","graphene-multicut"),a.appendChild(Ne({text:"Swap",title:"Swap group",onClick:()=>{s.swapGroup()}})),a.appendChild(Ne({text:"Clear",title:"Clear multicut",onClick:()=>{s.reset()}}));const c=async()=>{d.classList.toggle("disabled",!0);const w=to(this.layer).loadedDataSource.transform.inputSpace.value.scales.map(b=>b/1e-9);n.submitMulticut(w).then(b=>{d.classList.toggle("disabled",!1),b&&e.cancel()})},d=Ne({text:"Submit",title:"Submit multicut",onClick:()=>{c()}});a.appendChild(d);const u=document.createElement("div");u.className="activeGroupIndicator",u.innerHTML="Active Group: ",a.appendChild(u);const{displayState:h}=this.layer,p=h.segmentationGroupState.value,m=h.baseSegmentHighlighting.value,g=h.highlightColor.value;e.bindInputEventMap(aM),e.registerDisposer(()=>{v(),h.baseSegmentHighlighting.value=m,h.highlightColor.value=g});const v=()=>{Ur(p),h.useTempSegmentStatedColors2d.value=!1,h.tempSegmentStatedColors2d.value.clear(),h.tempSegmentDefaultColor2d.value=void 0,h.highlightColor.value=void 0},y=()=>{v(),u.classList.toggle("blueGroup",s.blueGroup.value);const S=s.focusSegment.value;if(S!==void 0){h.baseSegmentHighlighting.value=!0,h.highlightColor.value=s.blueGroup.value?DA:TA,o.useTemporaryVisibleSegments.value=!0,o.useTemporarySegmentEquivalences.value=!0,o.temporaryVisibleSegments.add(S);for(const w of s.segments)o.temporaryVisibleSegments.add(w);for(const w of o.segmentEquivalences.setElements(S))o.temporaryVisibleSegments.has(w)||o.temporarySegmentEquivalences.link(S,w);h.tempSegmentDefaultColor2d.value=PA,h.tempSegmentStatedColors2d.value.set(S,kA);for(const w of s.redSegments)h.tempSegmentStatedColors2d.value.set(w,LA);for(const w of s.blueSegments)h.tempSegmentStatedColors2d.value.set(w,RA);h.useTempSegmentStatedColors2d.value=!0}};y(),e.registerDisposer(s.changed.add(y)),e.registerDisposer(p.segmentEquivalences.changed.add((0,Fe.A)(()=>y(),0))),e.bindAction("swap-group",S=>{S.stopPropagation(),s.swapGroup()}),e.bindAction("set-anchor",S=>{S.stopPropagation();const w=Fu(this,p.visibleSegments);if(!w)return;const{rootId:b,segmentId:x}=w,{focusSegment:E,segments:D}=s;if(E.value===void 0&&(E.value=b.clone()),!P.R.equal(E.value,b)){pe.showTemporaryMessage(`The selected supervoxel has root segment ${b.toString()}, but the supervoxels already selected have root ${E.value.toString()}`,12e3);return}if(!P.R.equal(b,x)){for(const L of D)if(P.R.equal(L,x)){pe.showTemporaryMessage(`Supervoxel ${x.toString()} has already been selected`,7e3);return}}s.activeGroup.add(w)}),e.bindAction("submit",S=>{S.stopPropagation(),c()})}get description(){return"multicut"}}const Fu=(i,e)=>{const{layer:t,mouseState:n}=i,{segmentSelectionState:{value:s,baseValue:r}}=t.displayState;if(!r||!s)return;if(!e.has(s)){pe.showTemporaryMessage("The selected supervoxel is of an unselected segment",7e3);return}const o=rM(t,n);if(o!==void 0)return{rootId:s.clone(),segmentId:r.clone(),position:o}},cM=i=>new Promise((e,t)=>{setTimeout(e,i)});class io extends Ga{constructor(e,t){super(e,{}),this.annotationState=t,this.getBaseSegment=!0;const{inProgressAnnotation:n}=this,{displayState:s}=t;if(!s)return;const{disablePicking:r}=s;this.registerDisposer(n.changed.add(()=>{r.value=n.value!==void 0}))}get annotationLayer(){return this.annotationState}get description(){return"merge line"}toJSON(){return N0}}function A0(i,e){const t=i.relatedSegments[0],n={id:i.id,locked:!1,sink:{position:i.pointA.slice(),rootId:t[0].clone(),segmentId:t[1].clone()}};return e||(n.source={position:i.pointB.slice(),rootId:t[2].clone(),segmentId:t[3].clone()}),n}function dM(i){const{sink:e,source:t}=i;return{id:i.id,type:Re.LINE,pointA:e.position.slice(),pointB:t.position.slice(),relatedSegments:[[e.rootId.clone(),e.segmentId.clone(),t.rootId.clone(),t.segmentId.clone()]],properties:[]}}const M0=20,uM=Ae.fromObject({"at:shift?+enter":{action:"submit"}});class hM extends gi{activate(e){const{graphConnection:{value:t},tool:n}=this.layer;if(!t||!(t instanceof is)){e.cancel();return}const{state:{mergeState:s,timestamp:r}}=t;if(P0(r,e))return;const{merges:o,autoSubmit:a}=s,l=new io(this.layer,t.mergeAnnotationState);n.value=l,e.registerDisposer(()=>{n.value=void 0});const{body:c,header:d}=Vi(e);d.textContent="Merge segments",c.classList.add("graphene-tool-status","graphene-merge-segments"),e.bindInputEventMap(uM);const u=async()=>{o.value.filter(x=>x.locked).length||(h.classList.toggle("disabled",!0),await t.bulkMerge(o.value),h.classList.toggle("disabled",!1))},h=Ne({text:"Submit",title:"Submit merge",onClick:async()=>{u()}});c.appendChild(h),e.bindAction("submit",async x=>{x.stopPropagation(),u()}),c.appendChild(Ne({text:"Clear",title:"Clear pending merges",onClick:()=>{l.deactivate();for(const x of o.value)x.locked||t.deleteMergeSubmission(x)}}));const p=e.registerDisposer(new pn(a)),m=document.createElement("label");m.appendChild(document.createTextNode("auto-submit")),m.title="auto-submit merges",m.appendChild(p.element),c.appendChild(m);const g=document.createElement("div");g.classList.add("graphene-merge-segments-merges"),c.appendChild(g);const v=Vs.make(this.layer.displayState,!0),y=x=>{const E=v.getWithNormalizedId(x);return E.classList.add("neuroglancer-segment-list-entry-double-line"),E},S=x=>{const E=document.createElement("div");E.classList.add("graphene-merge-segments-point");const D=y(Yi(this.layer.displayState,x));return E.appendChild(D),E},w=x=>{const E=document.createElement("div");if(E.classList.add("graphene-merge-segments-submission"),E.appendChild(S(x.sink.rootId)),x.source&&(E.appendChild(document.createElement("div")).textContent="\uA579",E.appendChild(S(x.source.rootId))),x.locked||E.appendChild(Mn({title:"Delete merge",onClick:D=>{D.stopPropagation(),D.preventDefault(),t.deleteMergeSubmission(x)}})),x.status){const D=document.createElement("div");D.classList.add("graphene-merge-segments-submission-status"),D.textContent=x.status,E.appendChild(D)}return E},b=()=>{for(;g.firstChild;)g.removeChild(g.firstChild);for(const x of o.value)g.appendChild(w(x))};e.registerDisposer(o.changed.add(b)),b()}toJSON(){return Vu}get description(){return"merge segments"}}const pM=Ae.fromObject({"at:shift?+enter":{action:"submit"},"at:shift?+control+mousedown0":{action:"add-point"}});class fM extends gi{activate(e){const{layer:t}=this,{graphConnection:{value:n}}=t;if(!n||!(n instanceof is))return;const{state:{findPathState:s},findPathAnnotationState:r}=n,{source:o,target:a,precisionMode:l}=s,c=this.layer.displayState.segmentationGroupState.value,{body:d,header:u}=Vi(e);u.textContent="Find Path",d.classList.add("graphene-tool-status","graphene-find-path");const h=()=>{s.triggerPathUpdate.dispatch()};d.appendChild(Ne({text:"Submit",title:"Submit Find Path",onClick:()=>{h()}})),d.appendChild(Ne({text:"Clear",title:"Clear Find Path",onClick:()=>{s.source.reset(),s.target.reset(),s.centroids.reset()}}));const p=e.registerDisposer(new pn(l)),m=document.createElement("label"),g=document.createElement("span");g.textContent="Precision mode: ",m.appendChild(g),m.title="Precision mode returns a more accurate path, but takes longer.",m.appendChild(p.element),d.appendChild(m);const v=document.createElement("div");v.classList.add("find-path-annotations"),d.appendChild(v);const y=Im();this.registerDisposer(new tn(v,y));const S=()=>{Me(v);const w=[0,0,0],b=[0,1,2],x=[],E="[symbol] 2ch [dim] var(--neuroglancer-column-0-width) [dim] var(--neuroglancer-column-1-width) [dim] var(--neuroglancer-column-2-width) [delete] min-content",I=[o,a].map(L=>L.value?.annotationReference?.value).filter(L=>L);for(const L of I){const[N,k]=xy(this.layer,L,r,E,b,x);for(const[O,V]of k.entries())w[O]=V;v.appendChild(N)}for(const[L,N]of w.entries())v.style.setProperty(`--neuroglancer-column-${L}-width`,`${N+2}ch`)};s.changed.add(S),S(),e.bindInputEventMap(pM),e.bindAction("submit",w=>{w.stopPropagation(),h()}),e.bindAction("add-point",w=>{w.stopPropagation(),(async()=>{if(o.value){if(!a.value){const b=Fu(this,c.visibleSegments);b&&(a.value=b)}}else{const b=Fu(this,c.visibleSegments);b&&(o.value=b)}})()})}toJSON(){return Bu}get description(){return"find path"}}sn(Ct,_u,i=>new lM(i,!0)),sn(Ct,Vu,i=>new hM(i,!0)),sn(Ct,Bu,i=>new fM(i,!0));const N0="annotateMergeLine";Cr(N0,(i,e)=>new io(i,e));/** + * @license + * Copyright 2018 The Neuroglancer Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */Ot("graphene",()=>new JA);/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function gM(i,e,t){const n=window.outerHeight-window.innerHeight+window.innerHeight/2-t/2,s=window.innerWidth/2-e/2;return window.open(i,void 0,`toolbar=no, menubar=no, width=${e}, height=${t}, top=${n}, left=${s}`)}async function O0(i,e,t,n,s){const r=new pe(!1,!0),o=new Promise(a=>{function l(c,d){r.element.textContent=c+" ";const u=document.createElement("button");u.textContent=d,r.element.appendChild(u),u.addEventListener("click",()=>{l(n,"Retry");const h=gM(i,400,650),p=()=>{h?.close()};window.addEventListener("beforeunload",p);const m=setInterval(()=>{h?.closed&&(clearInterval(m),l(s,"Retry"))},1e3),g=async v=>{v.source===h&&(clearInterval(m),window.removeEventListener("message",g),window.removeEventListener("beforeunload",p),p(),a(v.data))};window.addEventListener("message",g)})}l(e,t)});try{return await o}finally{r.dispose()}}async function mM(i){const e=await O0(`${i}/api/v1/authorize`,`middleauth server ${i} login required.`,"Login",`Waiting for login to middleauth server ${i}...`,`Login window closed for middleauth server ${i}.`);(0,f.Rf)(e);const t=(0,f.cQ)(e,"token",f.zr),n=(0,f.cQ)(e,"app_urls",f.si);return{tokenType:"Bearer",accessToken:t,url:i,appUrls:n}}async function vM(i,e){return await O0(i,`Before you can access ${e}, you need to accept its Terms of Service.`,"Open","Waiting for Terms of Service agreement...",`Terms of Service closed for ${e}.`)==="success"}const _0="auth_token_v2";function yM(i){const e=localStorage.getItem(`${_0}_${i}`);return e?JSON.parse(e):null}function SM(i,e){localStorage.setItem(`${_0}_${i}`,JSON.stringify(e))}class bM extends Nn{constructor(e){super(),this.serverUrl=e,this.alreadyTriedLocalStorage=!1,this.get=Xn(async()=>{let t;return this.alreadyTriedLocalStorage||(this.alreadyTriedLocalStorage=!0,t=yM(this.serverUrl)),t||(t=await mM(this.serverUrl),SM(this.serverUrl,t)),t})}}class CM extends Error{constructor(e){super(),this.url=e}}class wM extends Nn{constructor(e,t){super(),this.serverUrl=e,this.credentialsManager=t,this.credentials=void 0,this.agreedToTos=!1,this.get=Xn(async()=>{if(this.credentials&&this.agreedToTos)return this.credentials.credentials;this.agreedToTos=!1;const n=await fetch(`${this.serverUrl}/auth_info`).then(o=>o.json()),s=this.credentialsManager.getCredentialsProvider("middleauth",n.login_url);if(this.credentials=await s.get(this.credentials),this.credentials.credentials.appUrls.includes(this.serverUrl))return this.credentials.credentials;throw new pe(!1).setText(`middleauth: unverified app ${this.serverUrl}`),new CM(this.serverUrl)}),this.errorHandler=async(n,s)=>{const{status:r}=n;if(r===401)return"refresh";if(r===403){const{response:o}=n;if(o){const{headers:a}=o;if(a.get("content-type")==="application/json"){const c=await o.json();if(c.error&&c.error==="missing_tos"){const d=new URL(c.data.tos_form_url);if(d.searchParams.set("client","ng"),await vM(d.toString(),c.data.tos_name))return this.agreedToTos=!0,"refresh"}}}if(!s.accessToken)return"refresh"}throw n}}}/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */Zn.register("middleauth",i=>new bM(i)),Zn.register("middleauthapp",(i,e)=>new wM(i,e));var Uu=G(5926);/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class xM extends it(lt()(Kn),Uu.j){}class EM extends ln{constructor(e,t,n,s){super(e),this.credentialsProvider=t,this.multiscaleMetadata=n,this.scales=s;let r,o;if(s.forEach((u,h)=>{if(u!==void 0){if(o===void 0&&(o=h),r!==void 0&&u.dataType!==r)throw new Error(`Scale s${h} has data type ${R[u.dataType]} but expected ${R[r]}.`);r=u.dataType}}),r===void 0)throw new Error("At least one scale must be specified.");const a=n.scales[o],l=s[o];this.dataType=r,this.volumeType=St.IMAGE,this.baseScaleIndex=o;const c=n.modelSpace,{rank:d}=c;this.modelSpace=Oe({names:c.names,scales:c.scales,units:c.units,boundingBoxes:[{transform:(0,De.nx)(Float64Array,a.downsamplingFactor,!1),box:{lowerBounds:new Float64Array(d),upperBounds:new Float64Array(l.size)}}],coordinateArrays:c.coordinateArrays})}get rank(){return this.modelSpace.rank}getSources(e){const{scales:t,rank:n}=this,s=this.multiscaleMetadata.scales;return(0,F.RO)(t.filter(r=>r!==void 0).map((r,o)=>{const a=s[o],l=(0,De.nx)(Float32Array,a.downsamplingFactor);return qi({rank:n,chunkToMultiscaleTransform:l,dataType:r.dataType,upperVoxelBound:r.size,volumeType:this.volumeType,chunkDataSizes:[r.chunkSize],volumeSourceOptions:e}).map(c=>({chunkSource:this.chunkManager.getChunkSource(xM,{credentialsProvider:this.credentialsProvider,spec:c,parameters:{url:a.url,encoding:r.encoding}}),chunkToMultiscaleTransform:l}))}))}}class TM{constructor(e){(0,f.Rf)(e),this.dataType=(0,f.cQ)(e,"dataType",n=>(0,f.sl)(n,R)),this.size=Float32Array.from((0,f.cQ)(e,"dimensions",n=>(0,f.$v)(n,f.We))),this.chunkSize=(0,f.cQ)(e,"blockSize",n=>(0,f.Xu)(new Uint32Array(this.size.length),n,f.We));let t;(0,f.MM)(e,"compression",n=>{t=(0,f.cQ)(n,"type",s=>(0,f.sl)(s,Uu.r))}),t===void 0&&(t=(0,f.cQ)(e,"compressionType",n=>(0,f.sl)(n,Uu.r))),this.encoding=t}}function DM(i,e,t){return Promise.all(t.scales.map(async n=>{const s=await V0(i,e,n.url,!0);if(s!==void 0)return new TM(s)}))}function IM(i){let{protocol:e,host:t,path:n}=(0,ke.Dl)(i);n.endsWith("/")&&(n=n.substring(0,n.length-1));const s=[];for(;;){s.push(`${e}://${t}${n}/attributes.json`);const r=n.lastIndexOf("/");if(r===-1)break;n=n.substring(0,r)}return s}function LM(i,e,t,n){return i.memoize.getUncounted({type:"n5:attributes.json",url:t,credentialsProvider:xt(e)},()=>Nt(e,t,{},ke.cj).then(s=>{try{return(0,f.Rf)(s)}catch(r){throw new Error(`Error reading attributes from ${t}: ${r.message}`)}}).catch(s=>{if((0,ke.El)(s))return n?void 0:{};throw s}))}async function V0(i,e,t,n){const s=IM(t),r=await Promise.all(s.map((o,a)=>LM(i,e,o,n&&a===s.length-1)));if(r.indexOf(void 0)===-1)return r.reverse(),Object.assign({},...r)}function Di(i,e){if(i!==-1&&e!==i)throw new Error(`Rank mismatch, received ${e} but expected ${i}`);return e}function B0(i){return Float64Array.from((0,f.$v)(i,f.Mo))}function F0(i){const e=(0,f.J6)(i);if(e.length===0)throw new Error("Expected non-empty array");let t=-1;return{all:(0,f.$v)(e,s=>{const r=B0(s);return t=Di(t,r.length),r}),single:void 0,rank:t}}function RM(i){const e=(0,f.J6)(i);if(e.length===0)throw new Error("Expected non-empty array");if(Array.isArray(e[0]))return F0(e);const t=B0(i);return{all:void 0,single:t,rank:t.length}}const kM=["x","y","z","t","c"];function PM(i){const e=kM.slice(0,i);for(;e.length{const p=Float64Array.from((0,f.$v)(h,f.Mo));return t=Di(t,p.length),p}),s=(0,f.MM)(e,"axes",h=>{const p=(0,f.$v)(h,f.zr);return t=Di(t,p.length),p}),r=(0,f.MM)(e,"units",h=>{const p=(0,f.$v)(h,Ph);return t=Di(t,p.length),p}),o={unit:"m",exponent:-9},a,l;(0,f.MM)(e,"downsamplingFactors",h=>{const{single:p,all:m,rank:g}=RM(h);t=Di(t,g),p!==void 0&&(a=p),m!==void 0&&(l=m)}),(0,f.MM)(e,"pixelResolution",h=>{o=(0,f.cQ)(h,"unit",Ph),(0,f.MM)(h,"dimensions",p=>{n=Float64Array.from((0,f.$v)(p,f.Mo)),t=Di(t,n.length)})}),(0,f.MM)(e,"scales",h=>{const{all:p,rank:m}=F0(h);t=Di(t,m),l=p});const c=(0,f.MM)(e,"dimensions",h=>{const p=(0,f.$v)(h,f.We);return t=Di(t,p.length),p});if(t===-1)throw new Error("Unable to determine rank of dataset");r===void 0&&(r=new Array(t),r.fill(o)),n===void 0&&(n=new Float64Array(t),n.fill(1));for(let h=0;h{(0,f.Rf)(h);for(let p=0;py)},r[p]={unit:"",exponent:0},n[p]=1}}}),s===void 0&&(s=PM(t));const u=Oe({rank:t,valid:!0,names:s,scales:n,units:r.map(h=>h.unit),coordinateArrays:d});if(c===void 0){if(l===void 0)throw new Error("Not valid single-resolution or multi-resolution dataset");return{modelSpace:u,url:i,attributes:e,scales:l.map((h,p)=>({url:`${i}/s${p}`,downsamplingFactor:h}))}}return a===void 0&&(a=new Float64Array(t),a.fill(1)),{modelSpace:u,url:i,attributes:e,scales:[{url:i,downsamplingFactor:a}]}}class MM extends Jt{get description(){return"N5 data source"}get(e){let{providerUrl:t}=e;return t.endsWith("/")&&(t=t.substring(0,t.length-1)),e.chunkManager.memoize.getUncounted({type:"n5:MultiscaleVolumeChunkSource",providerUrl:t},async()=>{const{url:n,credentialsProvider:s}=wn(t,e.credentialsManager),r=await V0(e.chunkManager,s,n,!1),o=AM(n,r),a=await DM(e.chunkManager,s,o),l=new EM(e.chunkManager,s,o,a);return{modelTransform:wt(l.modelSpace),subsources:[{id:"default",default:!0,url:void 0,subsource:{volume:l}},{id:"bounds",default:!0,url:void 0,subsource:{staticAnnotations:xn(l.modelSpace.bounds)}}]}})}completeUrl(e){return ts(e.credentialsManager,e.providerUrl,e.cancellationToken)}}/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */Ot("n5",()=>new MM);/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function U0(i){return new Error(`ngauth server ${i} does not allow requests from Neuroglancer instance ${self.origin}`)}async function NM(i){const e=new pe(!1);function t(s,r){e.element.textContent=s+" ";const o=document.createElement("button");o.textContent=r,e.element.appendChild(o),o.addEventListener("click",()=>{window.open(`${i}/login?origin=${encodeURIComponent(self.origin)}`),t(`Waiting for login to ngauth server ${i}...`,"Retry")})}const n=new Promise((s,r)=>{function o(a){if((a.origin||a.originalEvent.origin)!==i)return;const c=()=>{window.removeEventListener("message",o,!1)},{data:d}=a;a.data==="badorigin"&&(c(),r(U0(i)));try{(0,f.Rf)(d);const u=(0,f.cQ)(d,"token",f.zr);c(),s(u)}catch{console.log("ngauth: Received unexpected message from ${serverUrl}",a)}}window.addEventListener("message",o,!1)});t(`ngauth server ${i} login required.`,"Login");try{return{token:await n}}finally{e.dispose()}}class OM extends Nn{constructor(e){super(),this.serverUrl=e,this.get=Xn(async()=>{const t=await fetch(`${this.serverUrl}/token`,{method:"POST",credentials:"include"});switch(t.status){case 200:return{token:await t.text()};case 401:return await NM(this.serverUrl);case 403:throw U0(this.serverUrl);default:throw ke.j$.fromResponse(t)}})}}class _M extends Nn{constructor(e,t,n){super(),this.ngauthCredentialsProvider=e,this.serverUrl=t,this.bucket=n,this.get=Xn(async()=>({tokenType:"Bearer",accessToken:(await(0,Ka.R)(this.ngauthCredentialsProvider,`${this.serverUrl}/gcs_token`,{method:"POST"},ke.cj,(r,o)=>({...o,body:JSON.stringify({token:r.token,bucket:this.bucket})}),r=>{const{status:o}=r;if(o===401)return"refresh";throw r})).token}))}}/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */Zn.register("ngauth",i=>new OM(i)),Zn.register("ngauth_gcs",(i,e)=>new _M(e.getCredentialsProvider("ngauth",i.authServer),i.authServer,i.bucket));/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function $0(i){return new Error(`Nggraph server ${i} does not allow requests from Neuroglancer instance ${self.origin}`)}async function VM(i){const e=new pe(!1);function t(s,r){e.element.textContent=s+" ";const o=document.createElement("button");o.textContent=r,e.element.appendChild(o),o.addEventListener("click",()=>{window.open(`${i}/login?origin=${encodeURIComponent(self.origin)}`),t(`Waiting for login to nggraph server ${i}...`,"Retry")})}const n=new Promise((s,r)=>{function o(a){if((a.origin||a.originalEvent.origin)!==i||typeof a.data!="string")return;const c=()=>{window.removeEventListener("message",o,!1)};a.data==="badorigin"?(c(),r($0(i))):(c(),s(a.data))}window.addEventListener("message",o,!1)});t(`Nggraph server ${i} login required.`,"Login");try{return{token:await n}}finally{e.dispose()}}class BM extends Nn{constructor(e){super(),this.serverUrl=e,this.get=Xn(async()=>{const t=await fetch(`${this.serverUrl}/token`,{method:"POST",credentials:"include"});switch(t.status){case 200:return{token:await t.text()};case 401:return await VM(this.serverUrl);case 403:throw $0(this.serverUrl);default:throw ke.j$.fromResponse(t)}})}}/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const FM="^(https?://[^/]+)/(.*)$";function UM(i){return(0,f.Rf)(i),{id:(0,f.cQ)(i,"id",e=>P.R.parseString((0,f.zr)(e))),baseSegments:(0,f.cQ)(i,"base_segment_ids",e=>(0,f.$v)(e,t=>P.R.parseString((0,f.zr)(t)))),baseSegmentParents:(0,f.cQ)(i,"base_segment_parent_ids",e=>(0,f.$v)(e,t=>P.R.parseString((0,f.zr)(t)))),name:(0,f.cQ)(i,"name",f.zr),tags:(0,f.cQ)(i,"tags",f.si),numVoxels:(0,f.cQ)(i,"num_voxels",f.bX),bounds:(0,f.cQ)(i,"bounds",e=>(0,f.$v)(e,t=>(0,f.zo)(t))),lastLogId:(0,f.cQ)(i,"last_log_id",e=>e==null?null:P.R.parseString((0,f.zr)(e)))}}let G0=0;class $M extends _d{constructor(e,t){super(e,t),this.debouncedVisibleSegmentsChanged=this.registerCancellable((0,Fe.A)(()=>this.visibleSegmentsChanged(),0)),this.segmentQueries=new Map,this.ignoreVisibleSegmentsChanged=!1,this.segmentEquivalencesChanged=this.registerCancellable((0,Fe.A)(()=>{this.debouncedVisibleSegmentsChanged.flush(),this.segmentEquivalencesChanged.cancel();const{segmentQueries:s}=this,{segmentEquivalences:r}=this.segmentsState;r.clear();for(const[o,a]of s){if(a.current===void 0||(0,Rt.YR)(a.id))continue;const{id:l,baseSegments:c}=a.current;if(c.length>0){for(const d of c)r.link(d,l);a.addedEquivalences=!0}else a.addedEquivalences=!1}},0));const n=()=>{this.ignoreVisibleSegmentsChanged||this.debouncedVisibleSegmentsChanged()};this.registerDisposer(t.visibleSegments.changed.add(n)),this.registerDisposer(t.temporaryVisibleSegments.changed.add(n)),this.visibleSegmentsChanged()}computeSplit(e,t){const{segmentEquivalences:n}=this.segmentsState,s=n.get(e);if((0,Rt.YR)(s)||!P.R.equal(n.get(t),s))return;const r=this.segmentQueries.get(s.toString());if(r===void 0)return;const{current:o}=r;if(o===void 0)return;const{baseSegments:a,baseSegmentParents:l}=o,c=l.length,d=new Vd.I;for(let m=0;mthis.handleSegmentUpdate(t.id.toString(),s))},n=e.toString();this.segmentQueries.set(n,t),console.log(`adding to segmentQueries: ${n}`)}handleSegmentUpdate(e,t){console.log(`handleSegmentUpdate: ${e}`);const n=this.segmentQueries.get(e);if(t==="invalid"){n.disposer(),console.log(`removing from segmentQueries: ${e} due to invalid`),this.segmentQueries.delete(e);try{this.ignoreVisibleSegmentsChanged=!0,this.segmentsState.visibleSegments.delete(n.id),this.segmentsState.temporaryVisibleSegments.delete(n.id)}finally{this.ignoreVisibleSegmentsChanged=!1}n.addedEquivalences&&this.segmentEquivalencesChanged();return}if(t==="error"){n.current=void 0,n.addedEquivalences&&this.segmentEquivalencesChanged(),console.log(`Error from ${this.graph.serverUrl}/${this.graph.entityName} watching segment ${e}`);return}n.current=t;const s=n.id,r=t.id;if(P.R.equal(r,s))n.current=t,(0,Rt.YR)(n.id)||this.segmentEquivalencesChanged();else{n.id=r;const o=r.toString(),a=this.segmentQueries.get(o);console.log(`removing from segmentQueries: ${e} due to rename -> ${r}`),this.segmentQueries.delete(e);try{this.ignoreVisibleSegmentsChanged=!0,this.segmentsState.visibleSegments.has(s)&&this.segmentsState.visibleSegments.add(r),this.segmentsState.selectedSegments.has(s)&&(this.segmentsState.selectedSegments.delete(s),this.segmentsState.selectedSegments.add(r)),this.segmentsState.temporaryVisibleSegments.has(s)&&(this.segmentsState.temporaryVisibleSegments.delete(s),this.segmentsState.temporaryVisibleSegments.add(r))}finally{this.ignoreVisibleSegmentsChanged=!1}a===void 0?(console.log(`adding to segmentQueries due to rename -> ${r}`),this.segmentQueries.set(o,n),this.segmentEquivalencesChanged()):(t.lastLogId!==null&&(typeof a.current!="object"||a.current.lastLogId===null||P.R.less(a.current.lastLogId,t.lastLogId))&&(a.current=t,this.segmentEquivalencesChanged()),n.disposer())}}visibleSegmentsChanged(){const{segmentsState:e}=this,{segmentQueries:t}=this,n=++G0,s=r=>{for(const o of r.unsafeKeys()){if(P.R.equal(o,Rt.G1))continue;const a=o.toString(),l=t.get(a);if(l!==void 0){l.seenGeneration=n;continue}this.registerVisibleSegment(o.clone())}};s(e.visibleSegments),s(e.temporaryVisibleSegments);for(const[r,o]of t)o.seenGeneration!==n&&(console.log(`removing from segmentQueries due to seenGeneration: ${r}`),t.delete(r),o.disposer(),o.addedEquivalences&&this.segmentEquivalencesChanged())}}class GM extends Od{constructor(e,t,n){super(),this.chunkManager=e,this.serverUrl=t,this.entityName=n,this.startingWebsocket=!1,this.websocket=void 0,this.watchesById=new Map,this.watches=new Set,this.nextWatchId=0,this.numOpenFailures=0}get visibleSegmentEquivalencePolicy(){return Rt.y6.MAX_REPRESENTATIVE|Rt.y6.REPRESENTATIVE_EXCLUDED}startWebsocket(){if(this.startingWebsocket||this.watches.size===0)return;this.startingWebsocket=!0;let e=new pe(!this.numOpenFailures);e.setText(`Opening websocket connection for nggraph://${this.serverUrl}/${this.entityName}`),(async()=>{const{numOpenFailures:t}=this;if(t>1){const o=1e3*Math.min(16,2**t);await new Promise(a=>setTimeout(a,o))}const n=(await Gu(this.chunkManager,this.serverUrl,this.entityName).get()).credentials,s=new URL("/graph/watch/"+encodeURIComponent(n.token),this.serverUrl);s.protocol=s.protocol.replace("http","ws");const r=new WebSocket(s.href);r.onclose=()=>{e!==void 0&&(e.dispose(),e=void 0),++this.numOpenFailures,this.websocket=void 0,this.startingWebsocket=!1,this.watchesById.clear(),this.startWebsocket()},r.onopen=()=>{e!==void 0&&(e.dispose(),e=void 0),this.numOpenFailures=0,this.websocket=r,this.nextWatchId=0;try{for(const o of this.watches){r.send(JSON.stringify({watch:{segment_id:o.segment.toString()}}));const a=this.nextWatchId++;o.watchId=a,this.watchesById.set(a,o)}}catch{}},r.onmessage=o=>{let a,l;try{const c=JSON.parse(o.data);(0,f.Rf)(c);const d=(0,f.cQ)(c,"watch_id",f.bX),u=this.watchesById.get(d);if(u===void 0)return;l=u;const h=(0,f.cQ)(c,"state",f.zr);h==="invalid"||h==="error"?a=h:a=(0,f.cQ)(c,"info",UM)}catch(c){console.log(`Received unexpected websocket message from ${this.serverUrl}:`,o.data,c);return}console.log("got update",a),l.callback(a)}})()}connect(e){const t=e.displayState.segmentationGroupState.value;return new $M(this,t)}trackSegment(e,t){return this.watchSegment(e,n=>{if(n==="invalid")t(null);else{if(n==="error")return;t(n.id)}})}watchSegment(e,t){const n={callback:t,segment:e,watchId:-1};this.watches.add(n);const{websocket:s}=this;if(s!==void 0)try{s.send(JSON.stringify({watch:{segment_id:e.toString()}}));const o=this.nextWatchId++;n.watchId=o,this.watchesById.set(o,n)}catch{}else this.startWebsocket();return()=>{const{websocket:o}=this;if(o!==void 0&&o.readyState===WebSocket.OPEN){const a=n.watchId;this.watchesById.delete(a);try{o.send(JSON.stringify({unwatch:{watch_id:a}}))}catch{}}this.watches.delete(n)}}async merge(e,t){const n=await zu(this.chunkManager,this.serverUrl,this.entityName,"/graph/mutate",{body:JSON.stringify({merge:{anchor:e.toString(),other:t.toString()}}),headers:{"Content-Type":"application/json"},method:"POST"});return(0,f.Rf)(n),(0,f.cQ)(n,"merged",s=>P.R.parseString(s))}async split(e,t){const n=await zu(this.chunkManager,this.serverUrl,this.entityName,"/graph/mutate",{body:JSON.stringify({split:{include:e.toString(),exclude:t.toString()}}),headers:{"Content-Type":"application/json"},method:"POST"});return(0,f.Rf)(n),{include:(0,f.cQ)(n,"include",s=>P.R.parseString(s)),exclude:(0,f.cQ)(n,"exclude",s=>P.R.parseString(s))}}}function z0(i){const e=i.match(FM);if(e===null)throw new Error(`Invalid nggraph url: ${JSON.stringify(i)}`);return{serverUrl:e[1],id:e[2]}}function $u(i,e,t,n,s=Je.fx){return(0,Ka.R)(i,`${e}${t}`,n,ke.cj,(r,o)=>{const a=new Headers(o.headers);return a.set("Authorization",r.token),{...o,headers:a}},r=>{const{status:o}=r;if(o===401)return"refresh";throw r},s)}function zM(i,e,t,n,s=Je.fx){return $u(W0(i,e),e,t,n,s)}class WM extends Nn{constructor(e,t,n){super(),this.parentCredentialsProvider=e,this.serverUrl=t,this.entityName=n,this.get=Xn(async()=>{const s=await $u(this.parentCredentialsProvider,this.serverUrl,"/entity_token",{body:JSON.stringify({entity:this.entityName}),headers:{"Content-Type":"application/json"},method:"POST"});return{token:s.token,entityType:s.entity_type,role:s.role}})}}function W0(i,e){return i.memoize.getUncounted({type:"nggraph:credentialsProvider",serverUrl:e},()=>new BM(e))}function Gu(i,e,t){return i.memoize.getUncounted({type:"nggraph:entityCredentialsProvider",serverUrl:e,entityName:t},()=>new WM(W0(i,e),e,t))}function zu(i,e,t,n,s,r=Je.fx){return $u(Gu(i,e,t),e,n,s,r)}function HM(i){return(0,f.Rf)(i),(0,f.cQ)(i,"entities",e=>(0,f.$v)(e,t=>{(0,f.Rf)(t);const n=(0,f.cQ)(t,"entity",f.zr),s=(0,f.cQ)(t,"entity_type",f.zr),r=(0,f.cQ)(t,"access_role",f.zr);return{id:n,entityType:s,accessRole:r}}))}class JM extends Jt{get description(){return"nggraph data source"}get(e){const{serverUrl:t,id:n}=z0(e.providerUrl);return e.chunkManager.memoize.getUncounted({type:"nggraph:get",serverUrl:t,id:n},async()=>{const s=Gu(e.chunkManager,t,n),{entityType:r}=(await s.get()).credentials;if(r!=="graph")throw new Error(`Unsupported entity type: ${JSON.stringify(r)}`);const{datasource_url:o}=await zu(e.chunkManager,t,n,"/graph/config",{method:"POST"}),a=await e.registry.get({...e,url:o}),l=new GM(e.chunkManager,t,n),c=[...a.subsources,{id:"graph",default:!0,subsource:{segmentationGraph:l}}];return{modelTransform:a.modelTransform,subsources:c}})}async completeUrl(e){const{serverUrl:t,id:n}=z0(e.providerUrl),s=await e.chunkManager.memoize.getUncounted({type:"nggraph:list",serverUrl:t},async()=>HM(await zM(e.chunkManager,t,"/list",{method:"POST"})));return{offset:t.length+1,completions:Ht(n,s,r=>r.id,r=>`${r.entityType} (${r.accessRole})`)}}}/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */Ot("nggraph",()=>new JM);var H0=G(6435);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class jM extends it(lt()(Kn),H0.C){}class YM extends ln{constructor(e,t,n,s){super(e),this.credentialsProvider=t,this.url=n,this.info=s}get dataType(){return this.info.dataType}get volumeType(){return St.UNKNOWN}get rank(){return this.info.rank}getSources(e){const{info:t}=this,n=De.DA(Float32Array,t.rank+1),s=xv({rank:t.rank,volumeType:St.UNKNOWN,chunkDataSize:t.volumeSize,dataType:t.dataType,upperVoxelBound:Float32Array.from(t.volumeSize),chunkToMultiscaleTransform:n,volumeSourceOptions:e});return[[{chunkSource:this.chunkManager.getChunkSource(jM,{credentialsProvider:this.credentialsProvider,spec:s,parameters:{url:this.url}}),chunkToMultiscaleTransform:n}]]}}function QM(i,e,t,n){return i.rpc.promiseInvoke(H0.Y,{chunkManager:i.addCounterpartRef(),credentialsProvider:Eu(i,e),url:t},n)}function KM(i,e,t){return i.memoize.getUncounted({type:"nifti/getVolume",url:t},async()=>{const{url:n,credentialsProvider:s}=wn(t,e),r=await QM(i,s,n,Je.fx),o=new YM(i,s,n,r),a={lowerBounds:new Float64Array(r.rank),upperBounds:Float64Array.from(r.volumeSize)},l=Oe({rank:r.rank,names:r.sourceNames,scales:r.sourceScales,units:r.units,boundingBoxes:[En(a)]}),c=Oe({rank:r.rank,names:r.viewNames,scales:r.viewScales,units:r.units});return{subsources:[{id:"default",default:!0,subsource:{volume:o}},{id:"bounds",default:!0,subsource:{staticAnnotations:xn(a)}}],modelTransform:{sourceRank:r.rank,rank:r.rank,inputSpace:l,outputSpace:c,transform:r.transform}}})}class qM extends Jt{get description(){return"Single NIfTI file"}get(e){return KM(e.chunkManager,e.credentialsManager,e.providerUrl)}completeUrl(e){return ts(e.credentialsManager,e.providerUrl,e.cancellationToken)}}/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */Ot("nifti",()=>new qM);/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class XM extends Jt{get description(){return"Wavefront OBJ mesh file"}async get(e){const t=await IS(e.chunkManager,e.credentialsManager,e.url),n=Oe({rank:3,names:["x","y","z"],units:["m","m","m"],scales:Float64Array.of(1e-9,1e-9,1e-9)});return{modelTransform:wt(n),subsources:[{id:"default",default:!0,subsource:{singleMesh:t}}]}}completeUrl(e){return ts(e.credentialsManager,e.providerUrl,e.cancellationToken)}}/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */Ot("obj",()=>new XM);/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */Ot("precomputed",()=>new ZS);var ZM=G(8997);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const eN=new Set(["jpg","raw16"]),tN=it(Kn,ZM.vc);class nN extends tN{}const iN=new Set(["COMPLETE","READ_ONLY"]),sN=new Set(["LOADING"]);function rN(i){const e=(0,f.$v)(i,f.Rf);if(e.length<1)throw new Error("No stacks found for owner object.");const t=new Map,n=(0,f.cQ)(e[0],"stackId",aN);for(const s of e){const r=(0,f.cQ)(s,"stackId",oN),o=lN(s);if(o!==void 0){const a=o.project;let l=t.get(a);if(l===void 0){const c=new Map;t.set(a,{stacks:c}),l=t.get(a)}l.stacks.set(r,o)}}return{owner:n,projects:t}}function oN(i){return(0,f.Rf)(i),(0,f.cQ)(i,"stack",f.zr)}function aN(i){return(0,f.Rf)(i),(0,f.cQ)(i,"owner",f.zr)}function lN(i){(0,f.Rf)(i);const e=(0,f.cQ)(i,"state",f.zr);let t=[],n=C.eR.create(),s=C.eR.create();if(iN.has(e)){const a=(0,f.cQ)(i,"stats",f.Rf);n=dN(a),s=cN(a),Object.prototype.hasOwnProperty.call(a,"channelNames")&&(t=uN(a))}else if(!sN.has(e))return;const r=(0,f.cQ)(i,"currentVersion",hN),o=(0,f.cQ)(i,"stackId",pN);return{lowerVoxelBound:n,upperVoxelBound:s,voxelResolution:r,project:o,channels:t}}function cN(i){(0,f.Rf)(i);const e=(0,f.cQ)(i,"stackBounds",f.Rf),t=C.eR.create();return t[0]=(0,f.cQ)(e,"maxX",f._D)+1,t[1]=(0,f.cQ)(e,"maxY",f._D)+1,t[2]=(0,f.cQ)(e,"maxZ",f._D)+1,t}function dN(i){(0,f.Rf)(i);const e=(0,f.cQ)(i,"stackBounds",f.Rf),t=C.eR.create();return t[0]=(0,f.cQ)(e,"minX",f._D),t[1]=(0,f.cQ)(e,"minY",f._D),t[2]=(0,f.cQ)(e,"minZ",f._D),t}function uN(i){return(0,f.Rf)(i),(0,f.cQ)(i,"channelNames",e=>(0,f.$v)(e,f.zr))}function hN(i){(0,f.Rf)(i);const e=C.eR.create();try{e[0]=(0,f.cQ)(i,"stackResolutionX",f._D),e[1]=(0,f.cQ)(i,"stackResolutionY",f._D),e[2]=(0,f.cQ)(i,"stackResolutionZ",f._D)}catch{e[0]=1,e[1]=1,e[2]=1}return e}function pN(i){return(0,f.Rf)(i),(0,f.cQ)(i,"project",f.zr)}class fN extends ln{constructor(e,t,n,s,r,o,a){super(e),this.baseUrl=t,this.ownerInfo=n,this.project=r,this.parameters=a;const l=n.projects.get(r);if(l===void 0)throw new Error(`Specified project ${JSON.stringify(r)} does not exist for specified owner ${JSON.stringify(n.owner)}`);if(s===void 0){const h=Array.from(l.stacks.keys());if(h.length!==1)throw new Error(`Dataset contains multiple stacks: ${JSON.stringify(h)}`);s=h[0]}const c=l.stacks.get(s);if(c===void 0)throw new Error(`Specified stack ${JSON.stringify(s)} is not one of the supported stacks: `+JSON.stringify(Array.from(l.stacks.keys())));this.stack=s,this.stackInfo=c,o!==void 0&&o.length>0&&(this.channel=o),this.minIntensity=(0,f.zB)(a.minIntensity),this.maxIntensity=(0,f.zB)(a.maxIntensity),this.maxTileSpecsToRender=(0,f.zB)(a.maxTileSpecsToRender),this.filter=(0,f.uS)(a.filter),this.minX=(0,f.zB)(a.minX),this.minY=(0,f.zB)(a.minY),this.minZ=(0,f.zB)(a.minZ),this.maxX=(0,f.zB)(a.maxX),this.maxY=(0,f.zB)(a.maxY),this.maxZ=(0,f.zB)(a.maxZ),this.minX!==void 0&&(c.lowerVoxelBound[0]=this.minX),this.minY!==void 0&&(c.lowerVoxelBound[1]=this.minY),this.minZ!==void 0&&(c.lowerVoxelBound[2]=this.minZ),this.maxX!==void 0&&(c.upperVoxelBound[0]=this.maxX),this.maxY!==void 0&&(c.upperVoxelBound[1]=this.maxY),this.maxZ!==void 0&&(c.upperVoxelBound[2]=this.maxZ);let d=(0,f.z$)(a.encoding);if(d===void 0)d="jpg";else if(!eN.has(d))throw new Error(`Invalid encoding: ${JSON.stringify(d)}.`);this.encoding=d,this.numLevels=(0,f.zB)(a.numlevels),this.dims=C.eR.create();let u=(0,f.zB)(a.tilesize);u===void 0&&(u=1024),this.dims[0]=u,this.dims[1]=u,this.dims[2]=1}get dataType(){return this.parameters.encoding==="raw16"?R.UINT16:R.UINT8}get volumeType(){return St.IMAGE}get rank(){return 3}getSources(e){const t=[];let n=this.numLevels;n===void 0&&(n=gN(this.stackInfo,this.dims[0]));const{lowerVoxelBound:s,upperVoxelBound:r}=this.stackInfo;for(let o=0;o=t)return 1;let n=0;for(;t>e;)t=t/2,n++;return n}function dl(i,e,t){return i.memoize.getUncounted({type:"render:getOwnerInfo",hostname:e,owner:t},()=>(0,ke.vd)(`${e}/render-ws/v1/owner/${t}/stacks`).then(n=>n.json()).then(rN))}const mN=/^([^/?]+)(?:\/([^/?]+))?(?:\/([^/?]+))(?:\/([^/?]*))?(?:\?(.*))?$/,J0=/^((?:(?:(?:http|https):\/\/[^,/]+)[^/?]))\/(.*)$/;function vN(i,e){let t,n;{const d=e.match(J0);if(d===null)throw new Error(`Invalid render volume path: ${JSON.stringify(e)}`);t=d[1],n=d[2]}const s=n.match(mN);if(s===null)throw new Error(`Invalid volume path ${JSON.stringify(n)}`);const r=s[1],o=s[2],a=s[3],l=s[4],c=(0,f.bL)(s[5]||"");return i.memoize.getUncounted({type:"render:MultiscaleVolumeChunkSource",hostname:t,path:n},async()=>{const d=await dl(i,t,r),u=new fN(i,t,d,a,o,l,c),h=Oe({rank:3,names:["x","y","z"],units:["m","m","m"],scales:Float64Array.from(u.stackInfo.voxelResolution,m=>m/1e9),boundingBoxes:[En({lowerBounds:new Float64Array(u.stackInfo.lowerVoxelBound),upperBounds:new Float64Array(u.stackInfo.upperVoxelBound)})]});return{modelTransform:wt(h),subsources:[{id:"default",default:!0,subsource:{volume:u}},{id:"bounds",default:!0,subsource:{staticAnnotations:xn(h.bounds)}}]}})}async function yN(i,e,t){const n=t.match(/^(?:([^/]+)(?:\/([^/]*))?(?:\/([^/]*))?(\/.*?)?)?$/);if(n===null||n[2]===void 0)throw null;if(n[3]===void 0){const d=n[2]||"",u=await dl(i,e,n[1]),h=Ht(d,u.projects,p=>p[0]+"/",()=>{});return{offset:n[1].length+1,completions:h}}if(n[4]===void 0){const d=n[3]||"",h=(await dl(i,e,n[1])).projects.get(n[2]);if(h===void 0)throw null;const p=Ht(d,h.stacks,m=>m[0]+"/",m=>m[1].project);return{offset:n[1].length+n[2].length+2,completions:p}}const s=n[4].substr(1)||"",o=(await dl(i,e,n[1])).projects.get(n[2]);if(o===void 0)throw null;const a=o.stacks.get(n[3]);if(a===void 0)throw null;const l=a.channels;if(l.length===0)throw null;const c=Ht(s,l,d=>d,()=>{});return{offset:n[1].length+n[2].length+n[3].length+3,completions:c}}async function SN(i,e){const t=i.match(J0);if(t===null)throw null;const n=t[1],s=t[2],r=await yN(e,n,s);return yi(t[1].length+1,r)}class bN extends Jt{get description(){return"Render"}get(e){return vN(e.chunkManager,e.providerUrl)}completeUrl(e){return SN(e.providerUrl,e.chunkManager)}}/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */Ot("render",()=>new bN);/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class CN extends Jt{get description(){return"VTK mesh file"}async get(e){const t=await IS(e.chunkManager,e.credentialsManager,e.url),n=Oe({rank:3,names:["x","y","z"],units:["m","m","m"],scales:Float64Array.of(1e-9,1e-9,1e-9)});return{modelTransform:wt(n),subsources:[{id:"default",default:!0,subsource:{singleMesh:t}}]}}completeUrl(e){return ts(e.credentialsManager,e.providerUrl,e.cancellationToken)}}/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */Ot("vtk",()=>new CN);var _t=G(2334);/** + * @license + * Copyright 2023 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function Wu(i,e,t){(0,f.Rf)(i);const n=(0,f.cQ)(i,"name",r=>e((0,f.zr)(r))),s=(0,f.cQ)(i,"configuration",r=>(r===void 0?r={}:(0,f.Rf)(r),t(r,n)));return{name:n,configuration:s}}/** + * @license + * Copyright 2023 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function wN(i){const{name:e,configuration:t}=Wu(i,n=>{const s=j0.get(n);if(s===void 0)throw new Error(`Unknown codec: ${JSON.stringify(n)}`);return s},n=>n);return{resolver:e,configuration:t}}const j0=new Map;function ss(i){j0.set(i.name,i)}function ul(i,e){const t=[],n=[],s=[],r=[];n.push(e);const o=(0,f.$v)(i,wN),a=o.length;let l=0;for(;l bytes codec");const{codecSpec:c,layoutInfo:d,encodedSize:u,shardingInfo:h}=(()=>{const{resolver:g,configuration:v}=o[l],y=g,{configuration:S,shardingInfo:w,encodedSize:b}=y.resolve(v,e);if(w!==void 0&&l+1!==a)throw new Error("bytes -> bytes codecs not supported following sharding codec");const x=y.getDecodedArrayLayoutInfo(S,e);return{codecSpec:{name:g.name,kind:_t.L.arrayToBytes,configuration:S},layoutInfo:x,encodedSize:b,shardingInfo:w}})();s[l]=d,r.push(u);const p=u,m=[];for(++l;l bytes codec, but received ${JSON.stringify(g.name)} of kind ${_t.L[g.kind]}`);const y=g,{configuration:S,encodedSize:w}=y.resolve(v,p);m.push({name:g.name,kind:g.kind,configuration:S}),r.push(w),++l}for(let g=t.length-1;g>=0;--g)s[g]=o[g].resolver.getDecodedArrayLayoutInfo(t[g].configuration,n[g],s[g+1]);return{[_t.L.arrayToArray]:t,[_t.L.arrayToBytes]:c,[_t.L.bytesToBytes]:m,arrayInfo:n,layoutInfo:s,shardingInfo:h,encodedSize:r}}/** + * @license + * Copyright 2023 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ss({name:"blosc",kind:_t.L.bytesToBytes,resolve(i){return(0,f.Rf)(i),{configuration:{}}}});/** + * @license + * Copyright 2023 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ss({name:"zstd",kind:_t.L.bytesToBytes,resolve(i){return(0,f.Rf)(i),{configuration:{}}}});var xN=G(6742);/** + * @license + * Copyright 2023 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ss({name:"bytes",kind:_t.L.arrayToBytes,resolve(i,e){(0,f.Rf)(i);const t=(0,f.cQ)(i,"endian",s=>{switch(s){case"little":return U.LITTLE;case"big":return U.BIG;case void 0:if(B[e.dataType]===1)return te}throw new Error(`Invalid endian value: ${JSON.stringify(s)}`)}),n=e.chunkShape.reduce((s,r)=>s*r,1);return{configuration:{endian:t},encodedSize:B[e.dataType]*n}},getDecodedArrayLayoutInfo(i,e){return{physicalToLogicalDimension:Array.from(e.chunkShape,(t,n)=>n),readChunkShape:e.chunkShape}}});/** + * @license + * Copyright 2023 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ss({name:"crc32c",kind:_t.L.bytesToBytes,resolve(i,e){let t;return e!==void 0&&(t=e+4),{configuration:{},encodedSize:t}}});/** + * @license + * Copyright 2023 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ss({name:"gzip",kind:_t.L.bytesToBytes,resolve(i){return(0,f.Rf)(i),{configuration:{level:(0,f.cQ)(i,"level",f.bX)}}}});/** + * @license + * Copyright 2023 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */var hl=(i=>(i[i.DEFAULT=0]="DEFAULT",i[i.V2=1]="V2",i))(hl||{});/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const ei=new Map;ei.set("|u1",{endianness:U.LITTLE,dataType:R.UINT8}),ei.set("|i1",{endianness:U.LITTLE,dataType:R.INT8});for(const[i,e]of[["<",U.LITTLE],[">",U.BIG]]){for(const t of["u","i"])ei.set(`${i}${t}8`,{endianness:e,dataType:R.UINT64});ei.set(`${i}u2`,{endianness:e,dataType:R.UINT16}),ei.set(`${i}i2`,{endianness:e,dataType:R.INT16}),ei.set(`${i}u4`,{endianness:e,dataType:R.UINT32}),ei.set(`${i}i4`,{endianness:e,dataType:R.INT32}),ei.set(`${i}f4`,{endianness:e,dataType:R.FLOAT32})}function EN(i){const e=ei.get(i);if(e===void 0)throw new Error(`Unsupported numpy data type: ${JSON.stringify(i)}`);return e}/** + * @license + * Copyright 2023 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function Y0(i){return(0,f.$v)(i,e=>{if(typeof e!="number"||!Number.isInteger(e)||e<0)throw new Error(`Expected non-negative integer, but received: ${JSON.stringify(e)}`);return e})}function Hu(i,e){return(0,f.Xu)(new Array(e),i,t=>{if(typeof t!="number"||!Number.isInteger(t)||t<=0)throw new Error(`Expected positive integer, but received: ${JSON.stringify(t)}`);return t})}function Ju(i){if(i!=="."&&i!=="/")throw new Error(`Expected "." or "/", but received: ${JSON.stringify(i)}`);return i}const ju=new Map([["",{unit:"",scale:1}],["angstrom",{unit:"m",scale:1e-10}],["foot",{unit:"m",scale:.3048}],["inch",{unit:"m",scale:.0254}],["mile",{unit:"m",scale:1609.34}],["parsec",{unit:"m",scale:0x6da012f95c9e88}],["yard",{unit:"m",scale:.9144}],["minute",{unit:"s",scale:60}],["hour",{unit:"s",scale:60*60}],["day",{unit:"s",scale:60*60*24}]]);for(const i of["meter","second"])for(const e of Bl){const{longPrefix:t,prefix:n}=e;if(t===void 0)continue;const s={unit:i[0],scale:10**e.exponent};ju.set(`${t}${i}`,s),ju.set(`${n}${i[0]}`,s)}function TN(i){if(i===null)return{scale:1,unit:""};if(typeof i!="string")throw new Error(`Expected string but received: ${JSON.stringify(i)}`);const e=i.trim(),t=/^([-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)(?:[eE][-+]?\d+)?)\s*(.*)/,n=e.match(t);let s,r;n===null?(s=1,r=e):(s=Number(n[1]),r=n[2]);const o=ju.get(r);if(o===void 0)throw new Error(`Unsupported unit: ${JSON.stringify(r)}`);return{unit:o.unit,scale:s*o.scale}}function Q0(i,e){switch(i){case R.UINT8:case R.INT8:case R.UINT16:case R.INT16:case R.UINT32:case R.INT32:case R.UINT64:if(typeof e!="number"||!Number.isInteger(e))throw new Error(`Expected integer but received: ${JSON.stringify(e)}`);return e;case R.FLOAT32:if(typeof e=="number")return e;if(typeof e=="string"){if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e==="NaN")return new Float32Array(Uint32Array.of(2143289344).buffer)[0];if(e.match(/^0x[a-fA-F0-9]+$/))return new Float32Array(Uint32Array.of(Number(e)).buffer)[0]}throw new Error(`Expected number, "Infinity", "-Infinity", "NaN", or hex string but received: ${JSON.stringify(e)}`)}}function DN(i,e){try{(0,f.Rf)(i),(0,f.cQ)(i,"zarr_format",m=>{(0,f.qi)(m,3)});const t=(0,f.cQ)(i,"node_type",m=>{if(e!==void 0&&(0,f.qi)(m,e),m!=="array"&&m!=="group")throw new Error(`Expected "array" or "group" but received: ${JSON.stringify(m)}`);return m});if(e=t,t==="group")return{zarrVersion:3,nodeType:"group",userAttributes:(0,f.MM)(i,"attributes",f.Rf,{})};const n=(0,f.cQ)(i,"shape",Y0),s=n.length,r=(0,f.cQ)(i,"dimension_names",m=>(0,f.ZD)(m??void 0,s)),o=(0,f.cQ)(i,"data_type",m=>(0,f.sl)(m,R,/^[a-z0-9]+$/)),{configuration:a}=(0,f.cQ)(i,"chunk_grid",m=>Wu(m,g=>(0,f.qi)(g,"regular"),g=>(0,f.cQ)(g,"chunk_shape",v=>Hu(v,s)))),{userAttributes:l,dimensionUnits:c}=(0,f.cQ)(i,"attributes",m=>{m===void 0&&(m={}),(0,f.Rf)(m);const g=(0,f.cQ)(m,"dimension_units",v=>(0,f.ZD)(v,s));return{userAttributes:m,dimensionUnits:g}}),{configuration:d,name:u}=(0,f.cQ)(i,"chunk_key_encoding",m=>Wu(m,g=>(0,f.sl)(g,hl,/^(v2|default)$/),(g,v)=>(0,f.MM)(g,"separator",Ju,v===hl.DEFAULT?"/":"."))),h=(0,f.cQ)(i,"fill_value",m=>Q0(o,m)),p=(0,f.cQ)(i,"codecs",m=>ul(m,{dataType:o,chunkShape:a}));return{zarrVersion:3,nodeType:t,rank:s,shape:n,chunkShape:a,dataType:o,fillValue:h,dimensionNames:r,dimensionUnits:c,chunkKeyEncoding:u,dimensionSeparator:d,userAttributes:l,codecs:p}}catch(t){const n=e===void 0?"":`${e} `;throw new Error(`Error parsing zarr v3 ${n}metadata: ${t.message}`)}}function IN(i,e,t){try{(0,f.Rf)(i),(0,f.cQ)(i,"zarr_format",p=>{(0,f.qi)(p,2)});const n=(0,f.cQ)(i,"shape",Y0),s=n.length,r=(0,f.cQ)(i,"chunks",p=>Hu(p,s)),o=(0,f.cQ)(i,"order",p=>{if(p!=="C"&&p!=="F")throw new Error(`Expected "C" or "F", but received: ${JSON.stringify(p)}`);return p}),a=(0,f.MM)(i,"dimension_separator",t===void 0?Ju:p=>(0,f.qi)(p,t),t??"."),l=(0,f.cQ)(i,"dtype",p=>EN((0,f.zr)(p))),c=l.dataType,d=(0,f.cQ)(i,"fill_value",p=>p===null?0:Q0(c,p)),u=[];o==="F"&&u.push({name:"transpose",configuration:{order:Array.from(n,(p,m)=>s-m-1)}}),u.push({name:"bytes",configuration:{endian:l.endianness===U.LITTLE?"little":"big"}}),(0,f.cQ)(i,"compressor",p=>{if(p===null)return;(0,f.Rf)(p);const m=(0,f.cQ)(p,"id",f.zr);switch(m){case"blosc":u.push({name:"blosc",configuration:{cname:(0,f.cQ)(p,"cname",f.zr),clevel:(0,f.cQ)(p,"clevel",f.bX),typesize:B[c],shuffle:(0,f.cQ)(p,"shuffle",g=>{switch(g){case-1:return B[c]===1?"bitshuffle":"shuffle";case 0:return"noshuffle";case 1:return"shuffle";case 2:return"bitshuffle"}throw new Error(`Invalid value: ${JSON.stringify(g)}`)}),blocksize:(0,f.MM)(p,"blocksize",f.bX,0)}});break;case"zlib":case"gzip":u.push({name:"gzip",configuration:{level:(0,f.cQ)(p,"level",f.bX)}});break;case"zstd":u.push({name:"zstd",configuration:{level:(0,f.cQ)(p,"level",f.bX)}});break;default:throw new Error(`Unsupported compressor: ${JSON.stringify(m)}`)}});const h=ul(u,{dataType:c,chunkShape:r});return{zarrVersion:2,nodeType:"array",rank:s,shape:n,chunkShape:r,dataType:c,fillValue:d,dimensionNames:(0,f.cQ)(e,"_ARRAY_DIMENSIONS",p=>(0,f.ZD)(p,s)),dimensionUnits:(0,f.cQ)(e,"dimension_units",p=>(0,f.ZD)(p,s)),userAttributes:e,dimensionSeparator:a,chunkKeyEncoding:hl.V2,codecs:h}}catch(n){throw new Error(`Error parsing zarr v2 metadata: ${n.message}`)}}/** + * @license + * Copyright 2023 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */var K0=(i=>(i[i.START=0]="START",i[i.END=1]="END",i))(K0||{});ss({name:"sharding_indexed",kind:_t.L.arrayToBytes,resolve(i,e){(0,f.Rf)(i);const t=(0,f.cQ)(i,"chunk_shape",l=>Hu(l,e.chunkShape.length)),n=(0,f.MM)(i,"index_location",l=>(0,f.sl)(l,K0,/^[a-z]+$/),1),s=Array.from(e.chunkShape,(l,c)=>{const d=t[c];if(l%d!==0)throw new Error(`sub-chunk shape of ${JSON.stringify(d)} does not evenly divide outer chunk shape of ${JSON.stringify(e.chunkShape)}`);return l/d}),r=Array.from(s);r.push(2);const o=(0,f.cQ)(i,"index_codecs",l=>ul(l,{dataType:R.UINT64,chunkShape:r}));if(o.encodedSize[o.encodedSize.length-1]===void 0)throw new Error("index_codecs must specify fixed-size encoding");const a=(0,f.cQ)(i,"codecs",l=>ul(l,{dataType:e.dataType,chunkShape:t}));return{configuration:{indexCodecs:o,subChunkCodecs:a,subChunkShape:t,subChunkGridShape:s,indexLocation:n},shardingInfo:{subChunkShape:t,subChunkGridShape:s,subChunkCodecs:a}}},getDecodedArrayLayoutInfo(i,e){return i.subChunkCodecs.layoutInfo[0]}});/** + * @license + * Copyright 2023 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ss({name:"transpose",kind:_t.L.arrayToArray,resolve(i,e){(0,f.Rf)(i);const{order:t,inverseOrder:n}=(0,f.cQ)(i,"order",r=>{const o=e.chunkShape.length,a=new Array(o),l=new Array(o);if(r==="C")for(let c=0;c{if(typeof c!="number"||!Number.isInteger(c)||c<0||c>=o)throw new Error(`Expected integer in range [0, ${o}) but received: ${JSON.stringify(c)}`);if(l[c]!==void 0)throw new Error(`Invalid permutation: ${JSON.stringify(r)}`);return l[c]=d,c});return{order:a,inverseOrder:l}}),s={dataType:e.dataType,chunkShape:Array.from(t,r=>e.chunkShape[r])};return{configuration:{encodedToDecoded:t,decodedToEncoded:n},encodedArrayInfo:s}},getDecodedArrayLayoutInfo(i,e,t){return{physicalToLogicalDimension:Array.from(t.physicalToLogicalDimension,s=>i.encodedToDecoded[s]),readChunkShape:Array.from(i.decodedToEncoded,s=>t.readChunkShape[s])}}});/** + * @license + * Copyright 2022 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const LN=new Set(["0.4","0.5-dev"]),q0=new Map([["angstrom",{unit:"m",scale:1e-10}],["foot",{unit:"m",scale:.3048}],["inch",{unit:"m",scale:.0254}],["mile",{unit:"m",scale:1609.34}],["parsec",{unit:"m",scale:0x6da012f95c9e88}],["yard",{unit:"m",scale:.9144}],["minute",{unit:"s",scale:60}],["hour",{unit:"s",scale:60*60}],["day",{unit:"s",scale:60*60*24}]]);for(const i of["meter","second"])for(const e of Bl){const{longPrefix:t}=e;t!==void 0&&q0.set(`${t}${i}`,{unit:i[0],scale:10**e.exponent})}function RN(i){(0,f.Rf)(i);const e=(0,f.cQ)(i,"name",f.zr),t=(0,f.MM)(i,"type",f.zr),n=(0,f.MM)(i,"unit",s=>{const r=q0.get(s);if(r===void 0)throw new Error(`Unsupported unit: ${JSON.stringify(s)}`);return r},{unit:"",scale:1});return{name:e,unit:n.unit,scale:n.scale,type:t}}function kN(i){const e=(0,f.$v)(i,RN);return Oe({names:e.map(t=>{const{name:n,type:s}=t;return s==="channel"?`${n}'`:n}),scales:Float64Array.from(e,t=>t.scale),units:e.map(t=>t.unit)})}function PN(i,e){const t=(0,f.cQ)(e,"scale",n=>(0,f.Xu)(new Float64Array(i),n,f.Mo));return De.nx(Float64Array,t)}function AN(i,e){return De.DA(Float64Array,i+1)}function MN(i,e){const t=(0,f.cQ)(e,"translation",n=>(0,f.Xu)(new Float64Array(i),n,f.zo));return De.u6(Float64Array,t)}const NN=new Map([["scale",PN],["identity",AN],["translation",MN]]);function ON(i,e){(0,f.Rf)(e);const t=(0,f.cQ)(e,"type",f.zr),n=NN.get(t);if(n===void 0)throw new Error(`Unsupported coordinate transform type: ${JSON.stringify(t)}`);return n(i,e)}function X0(i,e){let t=De.DA(Float64Array,i+1);return e===void 0||(0,f.$v)(e,n=>{const s=ON(i,n);t=De.lw(new Float64Array(t.length),i+1,s,i+1,t,i+1,i+1,i+1,i+1)}),t}function _N(i,e,t){const n=(0,f.cQ)(t,"path",f.zr),s=(0,f.cQ)(t,"coordinateTransformations",o=>X0(i,o));return{url:`${e}/${n}`,transform:s}}function VN(i,e){const t=(0,f.cQ)(e,"axes",kN),n=t.rank,s=(0,f.cQ)(e,"coordinateTransformations",l=>X0(n,l)),r=(0,f.cQ)(e,"datasets",l=>(0,f.$v)(l,c=>{const d=_N(n,i,c);return d.transform=De.lw(new Float64Array((n+1)**2),n+1,s,n+1,d.transform,n+1,n+1,n+1,n+1),d}));if(r.length===0)throw new Error("At least one scale must be specified");const o=r[0].transform,a=new Float64Array(n);for(let l=0;l{const{metadata:n}=t,{rank:s,codecs:r,shape:o}=n,a=r.layoutInfo[0].readChunkShape,{physicalToLogicalDimension:l}=n.codecs.layoutInfo[0],c=new Uint32Array(s),d=new Float32Array(s),u=new Float32Array((s+1)**2);u[(s+1)**2-1]=1;for(let p=0;p({chunkSource:this.chunkManager.getChunkSource(FN,{credentialsProvider:this.credentialsProvider,spec:p,parameters:{url:t.url,metadata:n}}),chunkToMultiscaleTransform:h}))}))}}function Yu(i,e,t){return i.memoize.getUncounted({type:"zarr:json",url:t,credentialsProvider:xt(e)},async()=>{try{return await Nt(e,t,{},ke.cj)}catch(n){if((0,ke.El)(n))return;throw n}})}const $N=[{key:{value:"dimension_separator",description:"Dimension separator in chunk keys"},values:[{value:".",description:"(default)"},{value:"/",description:""}]}];function GN(i,e){const t=new Set,n=e===2?"d":"dim_";return i.map((s,r)=>{if(s===null){let a=r;for(;;){if(s=`${n}${a}`,!t.has(s))return t.add(s),s;++a}}if(!t.has(s))return t.add(s),s;let o=1;for(;;){const a=`${s}${o}`;if(!t.has(a))return t.add(a),a;++o}})}function zN(i,e){const t=GN(e.dimensionNames,e.zarrVersion),n=e.dimensionUnits.map(TN),s=Oe({names:t,scales:Float64Array.from(Array.from(n,o=>o.scale)),units:Array.from(n,o=>o.unit),boundingBoxes:[En({lowerBounds:new Float64Array(e.rank),upperBounds:Float64Array.from(e.shape)})]}),r=De.DA(Float64Array,e.rank+1);return{coordinateSpace:s,dataType:e.dataType,scales:[{url:i,transform:r,metadata:e}]}}async function WN(i,e,t,n){const s=await Promise.all(t.scales.map(async g=>{const v=await pl(i,e,g.url,{zarrVersion:n.zarrVersion,expectedNodeType:"array",explicitDimensionSeparator:n.explicitDimensionSeparator});if(v===void 0)throw new Error(`zarr v{zarrVersion} array metadata not found at ${g.url}`);return v})),r=s[0].dataType,o=s.length,a=t.coordinateSpace.rank;for(let g=0;g{const y=s[v];return{url:g.url,transform:g.transform,metadata:y}})}}async function pl(i,e,t,n){if(n.zarrVersion===2){const[o,a]=await Promise.all([Yu(i,e,`${t}/.zarray`),Yu(i,e,`${t}/.zattrs`)]);return o===void 0?a===void 0||n.expectedNodeType==="array"?void 0:{zarrVersion:2,nodeType:"group",userAttributes:(0,f.Rf)(a)}:n.expectedNodeType==="group"?void 0:IN(o,a??{},n.explicitDimensionSeparator)}if(n.zarrVersion===3){const o=await Yu(i,e,`${t}/zarr.json`);if(o===void 0)return;if(n.explicitDimensionSeparator!==void 0)throw new Error("dimension_separator query parameter not supported for zarr v3");return DN(o,n.expectedNodeType)}const[s,r]=await Promise.all([pl(i,e,t,{...n,zarrVersion:2}),pl(i,e,t,{...n,zarrVersion:3})]);if(s!==void 0&&r!==void 0)throw new Error("Both zarr v2 and v3 metadata found");return s??r}class Qu extends Jt{constructor(e=void 0){super(),this.zarrVersion=e}get description(){return`Zarr${this.zarrVersion===void 0?"":` v${this.zarrVersion}`} data source`}get(e){let[,t,n]=e.providerUrl.match(/([^?]*)(?:\?(.*))?$/);const s=(0,f.bL)(n||"");(0,f.Rf)(s);const r=(0,f.MM)(s,"dimension_separator",Ju);return t.endsWith("/")&&(t=t.substring(0,t.length-1)),e.chunkManager.memoize.getUncounted({type:"zarr:MultiscaleVolumeChunkSource",providerUrl:t,dimensionSeparator:r},async()=>{const{url:o,credentialsProvider:a}=wn(t,e.credentialsManager),l=await pl(e.chunkManager,a,o,{zarrVersion:this.zarrVersion,explicitDimensionSeparator:r});if(l===void 0)throw new Error("No zarr metadata found");let c;if(l.nodeType==="group"){const u=BN(o,l.userAttributes);if(u===void 0)throw new Error("Neithre array nor OME multiscale metadata found");c=await WN(e.chunkManager,a,u,{zarrVersion:l.zarrVersion,explicitDimensionSeparator:r})}else c=zN(o,l);const d=new UN(e.chunkManager,a,c);return{modelTransform:wt(d.modelSpace),subsources:[{id:"default",default:!0,url:void 0,subsource:{volume:d}},{id:"bounds",default:!0,url:void 0,subsource:{staticAnnotations:xn(d.modelSpace.bounds)}}]}})}async completeUrl(e){const[,,t]=e.providerUrl.match(/([^?]*)(?:\?(.*))?$/);return t!==void 0?yi(e.providerUrl.length-t.length,await vg(t,$N)):await ts(e.credentialsManager,e.providerUrl,e.cancellationToken)}}/** + * @license + * Copyright 2020 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */Ot("zarr",()=>new Qu),Ot("zarr2",()=>new Qu(2)),Ot("zarr3",()=>new Qu(3));/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function HN(i){i.registerEventListener(document,"copy",e=>{if(xc(e.target))return;const t=document.getSelection();if(t!==null&&t.type==="Range")return;const n=Lo(i.state).value,{clipboardData:s}=e;s!==null&&s.setData("text/plain",JSON.stringify(n,void 0," ")),e.preventDefault()})}function JN(i,e){let t=String.raw`^[\[\]{}()\s,]*`;for(let r=0;r{if(xc(e.target))return;const{clipboardData:t}=e;if(t!==null){const n=t.getData("text/plain"),s=JN(n,i.coordinateSpace.value.rank);s!==void 0&&(i.navigationState.position.value=s)}e.preventDefault()})}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function YN(){return(0,T.K6)(document,"contextmenu",i=>{i.preventDefault()})}function QN(){return(0,T.K6)(document,"wheel",i=>{i.ctrlKey&&i.preventDefault()},{passive:!1})}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const Z0=Symbol("SingleTextureVolumeChunk.textureUnit"),fl=Symbol("SingleTextureVolumeChunk.textureLayout");class eb extends T.O8{constructor(e,t){super(),this.shaderKey=e,this.dataType=t}defineShader(e,t){e.addTextureSampler(this.shaderSamplerType,"uVolumeChunkSampler",Z0)}beginDrawing(e,t){const n=t.textureUnit(Z0);e.activeTexture(WebGL2RenderingContext.TEXTURE0+n),t[fl]=null}endDrawing(e,t){e.bindTexture(cr[this.shaderSamplerType],null),t[fl]=null}bindChunk(e,t,n,s,r,o,a){const l=n.textureLayout;(t[fl]!==l||a)&&(t[fl]=l,this.setupTextureLayout(e,t,l,s,r,o)),e.bindTexture(cr[this.shaderSamplerType],n.texture)}beginSource(e,t){}}class tb extends zI{constructor(e,t){super(e,t),this.texture=null,this.data=t.data}copyToGPU(e){if(super.copyToGPU(e),this.data===null)return;const t=this.texture=e.createTexture(),n=cr[this.chunkFormat.shaderSamplerType];e.bindTexture(n,t),this.setTextureData(e),e.bindTexture(n,null)}freeGPUMemory(e){super.freeGPUMemory(e),this.data!==null&&(e.deleteTexture(this.texture),this.texture=null,this.textureLayout.dispose(),this.textureLayout=null)}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class gl extends T.O8{constructor(e,t,n){super(),this.chunkDataSize=t,this.textureDims=n,this.textureShape=new Uint32Array(this.textureDims);const s=t.length;let r=0;for(const u of t)u!==1&&++r;const o=this.strides=new Uint32Array(s*n),a=n===3?e.max3dTextureSize:e.maxTextureSize;let l=0,c=1;const{textureShape:d}=this;d.fill(1);for(let u=0;ua||c!==1&&l+rnew gl(e,t,n))}}let Ku=new Uint32Array(3*5);class qu extends eb{constructor(e,t,n,s){super(n,t),this.textureDims=s,Wi(this,t),this.shaderSamplerType=`${this.samplerPrefix}sampler${s}D`,this.textureAccessHelper=new wD("chunkData",s)}static get(e,t,n){const s=`sliceview.UncompressedChunkFormat:${t}:${n}`;return e.memoize.get(s,()=>new qu(e,t,s,n))}defineShader(e,t,n=!1){super.defineShader(e,t);const{textureDims:s}=this,r=`ivec${this.textureDims}`,{textureAccessHelper:o}=this,a=(4+t)*s;Ku.length=d))for(let g=0;g1&&++n;const s=n>=3?3:2;this.chunkFormat=this.registerDisposer(qu.get(e,t.dataType,s)),this.textureLayout=this.registerDisposer(this.chunkFormat.getTextureLayout(e,t.chunkDataSize)),this.fillValueChunk=this.registerDisposer(e.memoize.get(`sliceview.UncompressedChunkFormat.fillValue:${t.chunkDataSize.length}:${t.dataType}:${t.fillValue}:${s}`,()=>ZN(e,this.chunkFormat,t.fillValue,t.chunkDataSize.length,s)))}getChunk(e,t){const n=new KN(e,t);return n.data===null&&(n.texture=this.fillValueChunk.texture,n.textureLayout=this.fillValueChunk.textureLayout),n}}Dv((i,e)=>e.compressedSegmentationBlockSize==null?new eO(i,e):null);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function nb(i,e,t,n,s,r){let o=0,a=0,l=1,c=1;for(let g=0;g<3;++g){const v=s[g],y=n[g],S=Math.floor(v/y),w=v%y;o+=S*l,l*=Math.ceil(t[g]/y),a+=w*c,c*=y}const d=e+o*2,u=i[d],h=i[d+1];let p=u&16777215;const m=u>>24&255;if(m>0){const v=(e+h&16777215)+Math.floor(a*m/32),y=i[v],S=a*m%32,w=y>>S&(1<new ml(t,n))}}const iO=Wi(new Ns,R.UINT32);let Xu=new Uint32Array(4*4);class Zu extends eb{constructor(e,t,n,s){super(s,e),this.subchunkSize=t,this.numChannels=n,this.textureAccessHelper=new xa("chunkData")}static get(e,t,n,s){const r=`sliceview.CompressedSegmentationChunkFormat:${t}:${s}`,o=`${r}:${(0,C.nL)(n)}`;return e.memoize.get(o,()=>new Zu(t,n,s,r))}get shaderSamplerType(){return"usampler2D"}defineShader(e,t){super.defineShader(e,t);const n=4*(4+t);Xu.length"compressedSegmentationChunkFormat_"+c;e.addUniform("highp ivec3","uSubchunkGridSize"),e.addUniform("highp ivec3","uSubchunkSize"),e.addUniform("highp ivec4","uVolumeChunkStrides",4+t),e.addFragmentCode(kw);const{dataType:o}=this,a=yt(o);o===R.UINT64?e.addFragmentCode(gt):e.addFragmentCode(To),e.addFragmentCode(s.getAccessor(r("readTextureValue"),"uVolumeChunkSampler",R.UINT32,1));let l=` +uint ${r("getChannelOffset")}(int channelIndex) { + if (channelIndex == 0) { + return ${this.numChannels}u; + } + return ${r("readTextureValue")}(uint(channelIndex)).value; +} +${a} getDataValueAt(highp ivec3 p`;for(let c=0;c> 24u; + if (encodingBits > 0u) { + ivec3 subchunkPosition = chunkPosition - subchunkGridPosition * uSubchunkSize; + int subchunkOffset = getFortranOrderIndex(subchunkPosition, uSubchunkSize); + uint encodedValueBaseOffset = subchunkHeader1 + uint(channelOffset); + uint encodedValueOffset = encodedValueBaseOffset + uint(subchunkOffset) * encodingBits / 32u; + uint encodedValue = ${r("readTextureValue")}(encodedValueOffset).value; + uint wordOffset = uint(subchunkOffset) * encodingBits % 32u; + uint encodedValueShifted = encodedValue >> wordOffset; + uint decodedValue = encodedValueShifted - (encodedValueShifted >> encodingBits << encodingBits); + outputValueOffset += decodedValue * ${this.dataType===R.UINT64?"2u":"1u"}; + } + ${a} result; +`,o===R.UINT64?l+=` + result.value[0] = ${r("readTextureValue")}(outputValueOffset).value; + result.value[1] = ${r("readTextureValue")}(outputValueOffset+1u).value; +`:l+=` + result.value = ${r("readTextureValue")}(outputValueOffset).value; +`,l+=` + return result; +} +`,e.addFragmentCode(l)}setupTextureLayout(e,t,n,s,r,o){const{subchunkGridSize:a}=n;e.uniform3i(t.uniform("uSubchunkGridSize"),a[0],a[1],a[2]);const l=Xu,c=o.length;if(l.fill(0),!n.singleton){for(let d=0;d<3;++d){l[d]=s[d];const u=r[d];u!==-1&&(l[4*(d+1)+u]=1)}for(let d=0;doO(e,this.chunkFormat,t.fillValue)))}getChunk(e,t){const n=new sO(e,t);return n.data===null&&(n.texture=this.fillValueChunk.texture,n.textureLayout=this.fillValueChunk.textureLayout),n}}Dv((i,e)=>e.compressedSegmentationBlockSize!=null?new aO(i,e):null);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */var rb=G(9783),lO=G(8085),cO=G(2027),dO=G(6984);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function dn(i,e){return t=>{t.style.flex=i,e(t)}}function S2(i,e){return t=>{Object.assign(t.style,i),e(t)}}function b2(i,e){return t=>{Object.assign(t,i),e(t)}}function rs(i,e){return t=>{t.style.display="flex",t.style.flexDirection=i;for(const n of e){const s=t.ownerDocument.createElement("div");t.appendChild(s),n(s)}}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const uO=C.pB.create();function ob(i,e){const t=C.pB.identity(uO),{globalPosition:n,displayDimensionRenderInfo:{canonicalVoxelFactors:s,displayDimensionIndices:r}}=i;for(let o=0;o<3;++o){const a=r[o];t[12+o]=a===-1?0:n[a],t[5*o]=e/s[o]}return C.pB.multiply(t,i.viewProjectionMat,t),t}class vl extends T.O8{constructor(e){super(),this.gl=e,this.vertexBuffer=this.registerDisposer(At.fromData(e,new Float32Array([0,0,0,1,1,0,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,1,1]),e.ARRAY_BUFFER,e.STATIC_DRAW));const t=.5;this.colorBuffer=this.registerDisposer(At.fromData(e,new Float32Array([1,0,0,t,1,0,0,t,0,1,0,t,0,1,0,t,0,0,1,t,0,0,1,t]),e.ARRAY_BUFFER,e.STATIC_DRAW)),this.trivialColorShader=this.registerDisposer(Sw(e))}static get(e){return e.memoize.get("SliceViewPanel:AxesLineHelper",()=>new vl(e))}draw(e,t=!0){const n=this.trivialColorShader,s=this.gl;n.bind(),s.uniformMatrix4fv(n.uniform("uProjectionMatrix"),!1,e);const r=n.attribute("aVertexPosition");this.vertexBuffer.bindToVertexAttrib(r,4);const o=n.attribute("aColor");this.colorBuffer.bindToVertexAttrib(o,4),t&&(s.colorMask(!1,!1,!1,!0),s.clearColor(0,0,0,0),s.clear(s.COLOR_BUFFER_BIT),s.colorMask(!0,!0,!0,!0),s.enable(s.BLEND),s.blendFunc(s.ONE_MINUS_DST_ALPHA,s.DST_ALPHA)),s.lineWidth(1),s.drawArrays(s.LINES,0,6),t&&s.disable(s.BLEND),s.disableVertexAttribArray(r),s.disableVertexAttribArray(o)}}var hO=G(4373);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const ab=!1;class lb{constructor(){this.renderLayers=[null],this.pickData=[null],this.values=[0,0,0],this.nextPickID=1}clear(){this.renderLayers.length=1,this.pickData.length=1,this.values.length=3,this.nextPickID=1}registerUint64(e,t,n=1,s=null){return this.register(e,n,t.low,t.high,s)}register(e,t=1,n=0,s=0,r=null){const{renderLayers:o,values:a}=this,l=this.nextPickID;this.nextPickID+=t;const c=o.length;o[c]=e;const d=c*3;return a[d]=l,a[d+1]=n,a[d+2]=s,this.pickData[c]=r,l}setMouseState(e,t){const{renderLayers:n,values:s}=this;let r=0,o=n.length-1;for(;rt?o=h-1:r=h}const a=e.pickedRenderLayer=n[r],l=r*3,c=e.pickedOffset=t-s[l];ab&&console.log(`Looking up pick ID ${t}: renderLayer`,a,`offset=${c}`);const{pickedValue:d}=e;d.low=s[l+1],d.high=s[l+2],e.pickedAnnotationId=void 0,e.pickedAnnotationLayer=void 0,e.pickedAnnotationBuffer=void 0,e.pickedAnnotationBufferBaseOffset=void 0,e.pickedAnnotationIndex=void 0,e.pickedAnnotationCount=void 0,e.pickedAnnotationType=void 0;const u=this.pickData[r];a!==null&&(ab&&console.log(`Picked value=${d}, offset=${c}, data=${this.pickData[r]}`),a.updateMouseState(e,d,c,u))}}/** + * @license + * Copyright 2018 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const cb=10,pO=1e3,fO=400,gO=500,mO=Math.PI/20,vO=20,yO=10;function db(i,e){return Math.sqrt(i*i+e*e)}function ub(i){let[e,t]=i;e.identifier>t.identifier&&([t,e]=[e,t]);const n=e.clientX-t.clientX,s=e.clientY-t.clientY,r=db(n,s),o=Math.atan2(n,s);return{distance:r,angle:o}}function SO(i,e){const t=Math.PI*2,n=Math.abs(i-e)%t;return Math.min(n,t-n)}class bO extends T.O8{constructor(e,t){super(),this.target=e,this.eventMap=t,this.prevTouches=new Map,this.moved=!1,this.prevAngle=0,this.rotated=!1,this.prevDistance=0,this.pinched=!1,this.prevCenterX=0,this.prevCenterY=0,this.translated=!1,this.startHold=this.registerCancellable((0,la.A)((n,s,r,o)=>{const a={event:n,centerX:r,centerY:o};this.dispatch(`touchhold${n.targetTouches.length}`,n,a,s)},pO,{leading:!1,trailing:!0})),this.numPriorTaps=0,this.priorTapNumTouches=0,this.tapStartTime=0,this.tapEndTime=0,this.curTapNumTouches=0,this.registerEventListener(e,"touchstart",n=>{this.handleTouchEvent(n)}),this.registerEventListener(e,"touchmove",n=>{this.handleTouchEvent(n)}),this.registerEventListener(e,"touchend",n=>{this.handleTouchEvent(n)})}dispatch(e,t,n,s=t.eventPhase){lf(e,t,s,n,this.eventMap)}handleTouchEvent(e){if(e.target===this.target)e.preventDefault();else return;const t=new Map,{prevTouches:n,prevEvent:s}=this;let r=0,o=0;for(const h of e.targetTouches)t.set(h.identifier,h),r+=h.clientX,o+=h.clientY;r/=t.size,o/=t.size;for(const[h,p]of n.entries()){const m=t.get(h);if(m===void 0)n.delete(h);else{const g=m.clientX-p.clientX,v=m.clientY-p.clientY;(Math.abs(g)>=cb||Math.abs(v)>=cb)&&(this.moved=!0)}}if(s===void 0||s.targetTouches.length!==t.size||t.size===0){if(this.moved=!1,e.type==="touchstart")this.startHold(e,e.eventPhase,r,o),(s===void 0||s.targetTouches.length===0)&&(this.tapStartTime=Date.now(),this.curTapNumTouches=0),this.curTapNumTouches=Math.max(this.curTapNumTouches,e.targetTouches.length);else{if(e.type==="touchend"){const h=Date.now();if(e.targetTouches.length===0&&h-this.tapStartTime=gO)&&(this.numPriorTaps=0),++this.numPriorTaps,this.tapEndTime=h,this.priorTapNumTouches=this.curTapNumTouches;const p={event:e,centerX:r,centerY:o};this.dispatch(`touchtap${this.curTapNumTouches}x${this.numPriorTaps}`,e,p)}}this.startHold.cancel()}if(this.prevTouches=t,this.prevEvent=e,this.prevCenterX=r,this.prevCenterY=o,this.translated=!1,t.size===2){const{distance:h,angle:p}=ub(t.values());this.prevDistance=h,this.prevAngle=p,this.rotated=!1,this.pinched=!1}return}if(!this.moved)return;this.tapStartTime=0,this.startHold.cancel(),this.prevTouches=t,this.prevEvent=e;let{prevCenterX:a,prevCenterY:l,translated:c}=this;const d=r-a,u=o-l;if(c===!1&&db(d,u)>=yO&&(c=this.translated=!0),c===!0&&(d!==0||u!==0)){this.prevCenterX=r,this.prevCenterY=o;const h={event:e,deltaX:d,deltaY:u,centerX:r,centerY:o};this.dispatch(`touchtranslate${t.size}`,e,h)}if(t.size===2){const{distance:h,angle:p}=ub(t.values());let{pinched:m,rotated:g,prevDistance:v,prevAngle:y}=this;m===!1&&Math.abs(h-v)>=vO&&(this.pinched=m=!0);const S=SO(p,y);if(g===!1&&S>=mO&&(this.rotated=g=!0),m===!0&&h!==v){this.prevDistance=h;const w={event:e,distance:h,prevDistance:v,centerX:r,centerY:o};this.dispatch("touchpinch",e,w)}g===!0&&p!==y&&(this.prevAngle=p,this.dispatch("touchrotate",e,{event:e,centerX:r,centerY:o,angle:p,prevAngle:y}))}}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const eh=C.eR.create();class hb{constructor(){this.pickIDs=new lb,this.viewportWidth=0,this.viewportHeight=0,this.invTransform=C.pB.create(),this.frameNumber=-1}}class pb{constructor(){this.buffer=null,this.glWindowX=0,this.glWindowY=0}}const CO=30,Et=5,je=1+Et*2,yl=(()=>{const i=Et**2,e=(s,r)=>(s-Et)**2+(r-Et)**2;let t=new Uint32Array(je*je),n=0;for(let s=0;si||(t[n++]=r*je+s);return t=t.subarray(0,n),t.sort((s,r)=>{const o=s%je,a=(s-o)/je,l=r%je,c=(r-l)/je;return e(o,a)-e(l,c)}),t})();function fb(i,e,t,n,s,r,o){const a=n-Et,l=s-Et;if(!(a>=0&&l>=0&&a+je<=r&&l+je<=o))for(let c=0;c=r||h>=o)&&(i[e+(h*je+u)*t]=0)}}class gb extends rp{constructor(e,t,n){super(e,t,n.visibility),this.viewer=n,this.mouseX=-1,this.mouseY=-1,this.pickRequestPending=!1,this.mouseStateForcer=()=>this.blockOnPickRequest(),this.isMovingToMousePosition=!1,this.pickingData=[new hb,new hb],this.pickRequests=[new pb,new pb],this.pickBufferContents=new Float32Array(8*je*je),this.pickTimerId=-1,this.nextPickRequestTime=0,this.pendingPickRequestTimerId=-1,this.pendingPickRequestTimerExpired=()=>{this.pendingPickRequestTimerId=-1,this.pickRequestPending&&this.attemptToIssuePickRequest()},this.isMovingToMousePositionOnPick=!1,this.inputEventMap=n.inputEventMap,t.classList.add("neuroglancer-rendered-data-panel"),t.classList.add("neuroglancer-panel"),t.classList.add("neuroglancer-noselect"),typeof NEUROGLANCER_SHOW_OBJECT_SELECTION_TOOLTIP<"u"&&NEUROGLANCER_SHOW_OBJECT_SELECTION_TOOLTIP===!0&&(t.title="Double click to toggle display of object under mouse pointer. Control+rightclick to pin/unpin selection."),this.registerDisposer(new za(t)),this.registerDisposer(new yn(t,this.inputEventMap)),this.registerDisposer(new tn(t,this.inputEventMap,s=>{this.onMousemove(s)})),this.registerDisposer(new bO(t,this.inputEventMap)),this.registerEventListener(t,"mousemove",this.onMousemove.bind(this)),this.registerEventListener(t,"touchstart",this.onTouchstart.bind(this)),this.registerEventListener(t,"mouseleave",()=>this.onMouseout()),this.registerEventListener(t,"mouseover",s=>{s.target!==t&&this.onMouseout()},!0),Z(t,"select-position",()=>{this.viewer.selectionDetailsState.select()}),Z(t,"snap",()=>{this.navigationState.pose.snap()}),Z(t,"zoom-in",()=>{this.context.flagContinuousCameraMotion(),this.navigationState.zoomBy(.5)}),Z(t,"zoom-out",()=>{this.context.flagContinuousCameraMotion(),this.navigationState.zoomBy(2)}),Z(t,"depth-range-decrease",()=>{this.context.flagContinuousCameraMotion(),this.navigationState.depthRange.value*=.5}),Z(t,"depth-range-increase",()=>{this.context.flagContinuousCameraMotion(),this.navigationState.depthRange.value*=2});for(let s=0;s<3;++s){const r=C.p9[s];for(const o of[-1,1]){const a=o<0?"-":"+";Z(t,`rotate-relative-${r}${a}`,()=>{this.context.flagContinuousCameraMotion(),this.navigationState.pose.rotateRelative(C.T2[s],o*.1)});const l=C.eR.create();Z(t,`${r}${a}`,()=>{this.context.flagContinuousCameraMotion();const{navigationState:c}=this,d=l;d[0]=0,d[1]=0,d[2]=0,d[s]=o,c.pose.translateVoxelsRelative(d)})}}Z(t,"zoom-via-wheel",s=>{this.context.flagContinuousCameraMotion();const r=s.detail;this.onMousemove(r,!1),this.zoomByMouse(_i(r))}),Z(t,"adjust-depth-range-via-wheel",s=>{this.context.flagContinuousCameraMotion();const r=s.detail;this.navigationState.depthRange.value*=_i(r)}),Z(t,"translate-via-mouse-drag",s=>{zt(s.detail,(r,o,a)=>{this.context.flagContinuousCameraMotion(),this.translateByViewportPixels(o,a)})}),Z(t,"translate-in-plane-via-touchtranslate",s=>{this.context.flagContinuousCameraMotion();const{detail:r}=s;this.translateByViewportPixels(r.deltaX,r.deltaY)}),Z(t,"translate-z-via-touchtranslate",s=>{this.context.flagContinuousCameraMotion();const{detail:r}=s,{navigationState:o}=this,a=eh;a[0]=0,a[1]=0,a[2]=r.deltaY+r.deltaX,o.pose.translateVoxelsRelative(a)});for(const s of[1,10])Z(t,`z+${s}-via-wheel`,r=>{this.context.flagContinuousCameraMotion();const o=r.detail,{navigationState:a}=this,l=eh,c=o.deltaY!==0?o.deltaY:o.deltaX;l[0]=0,l[1]=0,l[2]=(c>0?-1:1)*s,a.pose.translateVoxelsRelative(l)});Z(t,"move-to-mouse-position",()=>{const{mouseState:s}=this.viewer;s.updateUnconditionally()&&(this.navigationState.position.value=s.position)}),Z(t,"snap",()=>this.navigationState.pose.snap()),Z(t,"move-annotation",s=>{const{mouseState:r}=this.viewer,o=r.pickedAnnotationId,a=r.pickedAnnotationLayer;if(a!==void 0&&o!==void 0){s.stopPropagation();const l=a.source.getReference(o),c=l.value,d=Tr(c.type),u=r.pickedOffset,{chunkTransform:{value:h}}=a;if(h.error!==void 0)return;const{layerRank:p}=h,m=new Float32Array(p);d.getRepresentativePoint(m,c,r.pickedOffset);const g=C.Zc.set(C.Zc.create(),0,0);r.updateUnconditionally()&&zt(s.detail,(v,y,S)=>{C.Zc.add(g,g,[y,S]);const w=new Float32Array(p);De.vo(w,h.chunkToLayerTransform,p+1,m,p);const b=eh,{displayDimensionIndices:x}=this.navigationState.pose.displayDimensions.value;_C(b,w,h.modelTransform,x),this.translateDataPointByViewportPixels(b,b,g[0],g[1]),VC(w,b,h.modelTransform,x);const E=new Float32Array(p);De.vo(E,h.layerToChunkTransform,p+1,w,p);const D=d.updateViaRepresentativePoint(c,E,u);a.source.update(l,D)},v=>{a.source.commit(l),l.dispose()})}}),Z(t,"delete-annotation",()=>{const{mouseState:s}=this.viewer,r=s.pickedAnnotationId,o=s.pickedAnnotationLayer;if(o!==void 0&&!o.source.readonly&&r!==void 0){const a=o.source.getReference(r);try{o.source.delete(a)}finally{a.dispose()}}}),Z(t,"zoom-via-touchpinch",s=>{this.context.flagContinuousCameraMotion();const{detail:r}=s;this.handleMouseMove(r.centerX,r.centerY);const o=r.prevDistance/r.distance;o>.1&&o<10&&this.zoomByMouse(o)})}cancelPickRequests(){const{gl:e}=this;for(const t of this.pickRequests){const{sync:n}=t;n!==null&&e.deleteSync(n),t.sync=null}clearTimeout(this.pickTimerId),this.pickTimerId=-1}issuePickRequestInternal(e){const{gl:t}=this;let{buffer:n}=e;n===null?(n=e.buffer=t.createBuffer(),t.bindBuffer(WebGL2RenderingContext.PIXEL_PACK_BUFFER,n),t.bufferData(WebGL2RenderingContext.PIXEL_PACK_BUFFER,32*je*je,WebGL2RenderingContext.STREAM_READ)):t.bindBuffer(WebGL2RenderingContext.PIXEL_PACK_BUFFER,n);const{renderViewport:s}=this,r=this.mouseX-s.visibleLeftFraction*s.logicalWidth,o=s.height-(this.mouseY-s.visibleTopFraction*s.logicalHeight);this.issuePickRequest(r,o),e.sync=t.fenceSync(WebGL2RenderingContext.SYNC_GPU_COMMANDS_COMPLETE,0),e.frameNumber=this.context.frameNumber,e.glWindowX=r,e.glWindowY=o,t.flush(),t.bindBuffer(WebGL2RenderingContext.PIXEL_PACK_BUFFER,null),this.pickTimerId===-1&&this.scheduleCheckForPickRequestCompletion(),this.pickRequestPending=!1;const{pickRequests:a}=this;e!==a[0]&&(a[1]=a[0],a[0]=e),this.nextPickRequestTime=Date.now()+CO}completePickInternal(e){const{gl:t}=this,{pickBufferContents:n}=this;t.bindBuffer(WebGL2RenderingContext.PIXEL_PACK_BUFFER,e.buffer),t.getBufferSubData(WebGL2RenderingContext.PIXEL_PACK_BUFFER,0,n),t.bindBuffer(WebGL2RenderingContext.PIXEL_PACK_BUFFER,null);const{pickingData:s}=this,{frameNumber:r}=e;this.completePickRequest(e.glWindowX,e.glWindowY,n,s[0].frameNumber===r?s[0]:s[1])}scheduleCheckForPickRequestCompletion(){this.pickTimerId=window.setTimeout(()=>{this.pickTimerId=-1,this.checkForPickRequestCompletion()},0)}checkForPickRequestCompletion(e=!1,t=!1){let n=this.context.frameNumber,s=-1;e&&(--n,s=n-1);const{pickRequests:r}=this,{gl:o}=this;let a=!1,l=!1,c;for(const u of r){const{sync:h}=u;if(h===null)continue;const{frameNumber:p}=u;if(!l&&p>=n-1){if(t||o.getSyncParameter(h,WebGL2RenderingContext.SYNC_STATUS)===WebGL2RenderingContext.SIGNALED)this.completePickInternal(u),l=!0;else if(p!==s){a=!0;continue}}o.deleteSync(h),u.sync=null,c=u}const{pickTimerId:d}=this;a&&d===-1?this.scheduleCheckForPickRequestCompletion():!a&&d!==-1&&(window.clearTimeout(d),this.pickTimerId=-1),!e&&c!==void 0&&this.pickRequestPending&&this.canIssuePickRequest()&&this.issuePickRequestInternal(c)}blockOnPickRequest(){this.pickRequestPending&&(this.cancelPickRequests(),this.nextPickRequestTime=0,this.attemptToIssuePickRequest()),this.checkForPickRequestCompletion(!1,!0)}draw(){const{width:e,height:t}=this.renderViewport;this.checkForPickRequestCompletion(!0);const{pickingData:n}=this;n[0]=n[1];const s=this.context.frameNumber,r=n[1];if(r.frameNumber=s,r.viewportWidth=e,r.viewportHeight=t,r.pickIDs.clear(),!this.drawWithPicking(r)){r.frameNumber=-1;return}this.nextPickRequestTime=0,this.mouseX>=0&&this.attemptToIssuePickRequest()}canIssuePickRequest(){const e=Date.now(),{nextPickRequestTime:t,pendingPickRequestTimerId:n}=this;return e=s.lengthInNanometers){t=s;break}}return t}function w2(i){const e=Xs.length;let t=Xs[e-1];for(let n=0;n=s.lengthInNanometers**3){t=s;break}}return t}class xO{constructor(){this.allowedSignificands=wO,this.targetLengthInPixels=0,this.physicalSizePerPixel=0,this.prevPhysicalSizePerPixel=0,this.prevTargetLengthInPixels=0,this.prevPhysicalUnit="\0"}update(){const{physicalSizePerPixel:e,targetLengthInPixels:t}=this;if(this.prevPhysicalSizePerPixel===e&&this.prevTargetLengthInPixels===t&&this.prevPhysicalUnit===this.physicalUnit)return!1;this.prevPhysicalSizePerPixel=e,this.prevTargetLengthInPixels=t,this.prevPhysicalUnit=this.physicalUnit;const n=t*e,s=Math.floor(Math.log10(n)),r=10**s,o=n/r;let a=1;for(const d of this.allowedSignificands)if(Math.abs(d-o)=0;--w){const b=o[w];g===1?b.label="":b.label+=": ",b.update(r),v.viewport(r.leftPixelOffset*r.scaleFactor-e.visibleLeftFraction*e.logicalWidth,S-(1-(e.visibleTopFraction+e.visibleHeightFraction))*e.logicalHeight,b.width,b.height),y.draw(b.texture),S+=b.height+r.marginPixelsBetweenScaleBars*r.scaleFactor}}}const vb={...{scaleFactor:1,textHeightInPixels:15,barHeightInPixels:8,barTopMarginInPixels:5,fontName:"sans-serif",paddingInPixels:2},maxWidthInPixels:100,maxWidthFraction:.25,leftPixelOffset:10,bottomPixelOffset:10,marginPixelsBetweenScaleBars:5};function DO(i){const e={...vb};for(const t of["textHeightInPixels","barTopMarginInPixels","barHeightInPixels","paddingInPixels","scaleFactor","maxWidthInPixels","maxWidthFraction","leftPixelOffset","bottomPixelOffset"])(0,f.cQ)(i,t,n=>{n!==void 0&&(e[t]=(0,f._D)(n))});return(0,f.cQ)(i,"fontName",t=>{t!==void 0&&(e.fontName=(0,f.zr)(t))}),e}class IO extends _.DN{constructor(){super(vb,DO)}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */var LO=(i=>(i[i.COLOR=0]="COLOR",i[i.Z=1]="Z",i[i.PICK=2]="PICK",i[i.NUM_TEXTURES=3]="NUM_TEXTURES",i))(LO||{}),RO=(i=>(i[i.TRANSPARENT=0]="TRANSPARENT",i[i.VOLUME_RENDERING=1]="VOLUME_RENDERING",i[i.MAX_PROJECTION=2]="MAX_PROJECTION",i))(RO||{});const kO=` +void emit(vec4 color, highp uint pickId) { + out_color = color; + float zValue = 1.0 - gl_FragCoord.z; + out_z = vec4(zValue, zValue, zValue, 1.0); + float pickIdFloat = float(pickId); + out_pickId = vec4(pickIdFloat, pickIdFloat, pickIdFloat, 1.0); +} +`,th=[` +float computeOITWeight(float alpha, float depth) { + float a = min(1.0, alpha) * 8.0 + 0.01; + float b = -depth * 0.95 + 1.0; + return a * a * a * b * b * b; +} +`,` +void emitAccumAndRevealage(vec4 accum, float revealage, highp uint pickId) { + v4f_fragData0 = vec4(accum.rgb, revealage); + v4f_fragData1 = vec4(accum.a, 0.0, 0.0, 0.0); +} +void emit(vec4 color, highp uint pickId) { + float weight = computeOITWeight(color.a, gl_FragCoord.z); + vec4 accum = color * weight; + emitAccumAndRevealage(accum, color.a, pickId); +} +`];function nh(i){i.addOutputBuffer("vec4","out_color",0),i.addOutputBuffer("highp vec4","out_z",1),i.addOutputBuffer("highp vec4","out_pickId",2),i.addFragmentCode(kO)}function ih(i){i.addOutputBuffer("vec4","v4f_fragData0",0),i.addOutputBuffer("vec4","v4f_fragData1",1),i.addFragmentCode(th)}function sh(i){i.addOutputBuffer("vec4","out_color",0),i.addOutputBuffer("highp vec4","out_z",1),i.addOutputBuffer("highp vec4","out_intensity",2),i.addOutputBuffer("highp vec4","out_pickId",3),i.addFragmentCode(` +void emit(vec4 color, float depth, float intensity, highp uint pickId) { + float pickIdFloat = float(pickId); + float bufferDepth = 1.0 - depth; + out_color = color; + out_z = vec4(bufferDepth, bufferDepth, bufferDepth, 1.0); + out_intensity = vec4(intensity, intensity, intensity, 1.0); + out_pickId = vec4(pickIdFloat, pickIdFloat, pickIdFloat, 1.0); +}`)}const ti=C.eR.create(),yb=C.ln.create(),PO=C.pB.create();function AO(i){i.addOutputBuffer("vec4","v4f_fragColor",null),i.setFragmentMain(` +vec4 v0 = getValue0(); +vec4 v1 = getValue1(); +vec4 accum = vec4(v0.rgb, v1.r); +float revealage = v0.a; + +v4f_fragColor = vec4(accum.rgb / accum.a, revealage); +`)}function MO(i){i.addOutputBuffer("vec4","v4f_fragData0",0),i.addOutputBuffer("vec4","v4f_fragData1",1),i.addFragmentCode(th),i.setFragmentMain(` +vec4 v0 = getValue0(); +vec4 v1 = getValue1(); +vec4 accum = vec4(v0.rgb, v1.r); +float revealage = v0.a; + +emitAccumAndRevealage(accum, 1.0 - revealage, 0u); +`)}function NO(i){i.addOutputBuffer("vec4","v4f_fragData0",0),i.addOutputBuffer("vec4","v4f_fragData1",1),i.addFragmentCode(th),i.setFragmentMain(` +vec4 color = getValue0(); +float bufferDepth = getValue1().r; +float weight = computeOITWeight(color.a, 1.0 - bufferDepth); +vec4 accum = color * weight; +float revealage = color.a; + +emitAccumAndRevealage(accum, revealage, 0u); +`)}function OO(i){i.addOutputBuffer("vec4","out_color",0),i.addOutputBuffer("highp vec4","out_z",1),i.addOutputBuffer("highp vec4","out_pickId",2),i.setFragmentMain(` +out_color = vec4(0.0); +out_z = getValue0(); +out_pickId = getValue1(); +`)}function _O(i){i.addOutputBuffer("highp vec4","out_z",0),i.addOutputBuffer("highp vec4","out_pickId",1),i.setFragmentMain(` +out_z = getValue0(); +out_pickId = getValue2(); +gl_FragDepth = getValue1().r; +`)}const VO=ar(hn);class BO extends VO{constructor(e){super(),this.panel=e}initializeCounterpart(e,t){this.sharedProjectionParameters=this.registerDisposer(new So(e,this.panel.projectionParameters)),t.projectionParameters=this.sharedProjectionParameters.rpcId,super.initializeCounterpart(e,t)}}class rh extends gb{constructor(e,t,n){super(e,t,n),this.hasVolumeRendering=!1,this.frameRateCalculator=new HC(6,8,8,60),this.isContinuousCameraMotionInProgress=!1,this.sliceViews=this.registerDisposer(new rc((r,o,a)=>{r.registerDisposer(a),r.registerDisposer(a.visibility.add(this.visibility))})),this.axesLineHelper=this.registerDisposer(vl.get(this.gl)),this.sliceViewRenderHelper=this.registerDisposer(ia.get(this.gl,nh)),this.offscreenFramebuffer=this.registerDisposer(new $n(this.gl,{colorBuffers:[new gn(this.gl,WebGL2RenderingContext.RGBA8,WebGL2RenderingContext.RGBA,WebGL2RenderingContext.UNSIGNED_BYTE),new gn(this.gl,WebGL2RenderingContext.R32F,WebGL2RenderingContext.RED,WebGL2RenderingContext.FLOAT),new gn(this.gl,WebGL2RenderingContext.R32F,WebGL2RenderingContext.RED,WebGL2RenderingContext.FLOAT)],depthBuffer:new xo(this.gl)})),this.offscreenCopyHelper=this.registerDisposer(Dn.get(this.gl)),this.transparencyCopyHelper=this.registerDisposer(Dn.get(this.gl,AO,2)),this.transparentToTransparentCopyHelper=this.registerDisposer(Dn.get(this.gl,MO,2)),this.maxProjectionColorCopyHelper=this.registerDisposer(Dn.get(this.gl,NO,2)),this.maxProjectionPickCopyHelper=this.registerDisposer(Dn.get(this.gl,OO,2)),this.maxProjectionToPickCopyHelper=this.registerDisposer(Dn.get(this.gl,_O,3)),this.scaleBars=this.registerDisposer(new mb(this.gl)),this.projectionParameters=this.registerDisposer(new yp({navigationState:this.navigationState,update:(r,o)=>{const{invViewMatrix:a,projectionMat:l,logicalWidth:c,logicalHeight:d}=r,u=c/d,h=Math.PI/4;let{relativeDepthRange:p}=o,g=o.zoomFactor.value/2;if(this.viewer.orthographicProjection.value){const v=Math.max(.1,1-p),y=1+p;C.pB.ortho(l,-u,u,-1,1,v,y)}else{const v=1/Math.tan(h/2);p/=v;const y=Math.max(.1,1-p),S=1+p;g*=v,C.pB.perspective(l,h,u,y,S)}ip(r,l),o.pose.toMat4(a,g),C.pB.scale(a,a,C.eR.set(ti,1,-1,-1)),C.pB.translate(a,a,C.T2[2]),ap(r)}})),this.projectionParameters.changed.add(()=>this.context.scheduleRedraw());const s=this.sharedObject=this.registerDisposer(new BO(this));if(s.RPC_TYPE_ID=hO.l,s.initializeCounterpart(n.rpc,{}),s.visibility.add(this.visibility),this.visibleLayerTracker=_g(this.viewer.layerManager,Gi,this.viewer.visibleLayerRoles,this),this.registerDisposer(this.context.continuousCameraMotionFinished.add(()=>{this.isContinuousCameraMotionInProgress=!1,this.hasVolumeRendering&&(this.scheduleRedraw(),this.frameRateCalculator.resetForNewFrameSet())})),this.registerDisposer(this.context.continuousCameraMotionStarted.add(()=>{this.isContinuousCameraMotionInProgress=!0})),Z(t,"rotate-via-mouse-drag",r=>{zt(r.detail,(o,a,l)=>{this.context.flagContinuousCameraMotion(),this.navigationState.pose.rotateRelative(C.T2[1],a/4*Math.PI/180),this.navigationState.pose.rotateRelative(C.T2[0],-l/4*Math.PI/180)})}),Z(t,"rotate-in-plane-via-touchrotate",r=>{this.context.flagContinuousCameraMotion();const{detail:o}=r;this.navigationState.pose.rotateRelative(C.T2[2],o.angle-o.prevAngle)}),Z(t,"rotate-out-of-plane-via-touchtranslate",r=>{this.context.flagContinuousCameraMotion();const{detail:o}=r;this.navigationState.pose.rotateRelative(C.T2[1],o.deltaX/4*Math.PI/180),this.navigationState.pose.rotateRelative(C.T2[0],-o.deltaY/4*Math.PI/180)}),n.showSliceViewsCheckbox){const r=this.registerDisposer(new pn(n.showSliceViews));r.element.className="perspective-panel-show-slice-views neuroglancer-noselect";const o=document.createElement("label");o.className="perspective-panel-show-slice-views neuroglancer-noselect",o.appendChild(document.createTextNode("Sections")),o.appendChild(r.element),this.element.appendChild(o)}this.registerDisposer(n.orthographicProjection.changed.add(()=>{this.projectionParameters.update(),this.scheduleRedraw()})),this.registerDisposer(n.showScaleBar.changed.add(()=>this.scheduleRedraw())),this.registerDisposer(n.scaleBarOptions.changed.add(()=>this.scheduleRedraw())),this.registerDisposer(n.showSliceViews.changed.add(()=>this.scheduleRedraw())),this.registerDisposer(n.showAxisLines.changed.add(()=>this.scheduleRedraw())),this.registerDisposer(n.crossSectionBackgroundColor.changed.add(()=>this.scheduleRedraw())),this.registerDisposer(n.perspectiveViewBackgroundColor.changed.add(()=>this.scheduleRedraw())),this.registerDisposer(n.wireFrame.changed.add(()=>this.scheduleRedraw())),this.sliceViews.changed.add(()=>this.scheduleRedraw())}get rpc(){return this.sharedObject.rpc}get rpcId(){return this.sharedObject.rpcId}get displayDimensionRenderInfo(){return this.navigationState.displayDimensionRenderInfo}get shouldDownsample(){return this.viewer.enableAdaptiveDownsampling.value&&this.isContinuousCameraMotionInProgress&&this.hasVolumeRendering}flushBackendProjectionParameters(){this.sharedObject.sharedProjectionParameters.flush()}translateByViewportPixels(e,t){const n=ti,{viewProjectionMat:s,invViewProjectionMat:r,logicalWidth:o,logicalHeight:a}=this.projectionParameters.value,{pose:l}=this.viewer.navigationState;l.updateDisplayPosition(c=>{C.eR.transformMat4(n,c,s),n[0]+=-2*e/o,n[1]+=2*t/a,C.eR.transformMat4(c,n,r)})}get navigationState(){return this.viewer.navigationState}ensureBoundsUpdated(){super.ensureBoundsUpdated(),this.projectionParameters.setViewport(this.renderViewport)}isReady(){if(!this.visible)return!0;for(const[o,a]of this.sliceViews)if((a||this.viewer.showSliceViews.value)&&!o.isReady())return!1;this.ensureBoundsUpdated();const{width:e,height:t}=this.renderViewport;if(e===0||t===0)return!0;const s={projectionParameters:this.projectionParameters.value},{visibleLayers:r}=this.visibleLayerTracker;for(const[o,a]of r)if(!o.isReady(s,a))return!1;return!0}disposed(){this.sliceViews.clear(),super.disposed()}getDepthArray(){if(!this.navigationState.valid)return;const{offscreenFramebuffer:e,renderViewport:{width:t,height:n}}=this,s=t*n,r=new Float32Array(s*4);try{e.bindSingle(1),this.gl.readPixels(0,0,t,n,WebGL2RenderingContext.RGBA,WebGL2RenderingContext.FLOAT,r)}finally{e.framebuffer.unbind()}const o=new Float32Array(s);for(let a=0;a{r.drawBuffers(this.offscreenFramebuffer.singleAttachmentList)},a=()=>{this.offscreenFramebuffer.bind(t,n)};a(),r.disable(r.SCISSOR_TEST),r.enable(WebGL2RenderingContext.STENCIL_TEST),r.stencilMask(4294967295),r.clearStencil(0),r.clear(WebGL2RenderingContext.STENCIL_BUFFER_BIT),r.stencilOp(WebGL2RenderingContext.KEEP,WebGL2RenderingContext.KEEP,WebGL2RenderingContext.REPLACE),r.stencilFunc(WebGL2RenderingContext.ALWAYS,1,1);const l=this.viewer.perspectiveViewBackgroundColor.value;this.gl.clearColor(l[0],l[1],l[2],0),r.clear(r.DEPTH_BUFFER_BIT),r.clearBufferfv(WebGL2RenderingContext.COLOR,0,[l[0],l[1],l[2],0]),r.clearBufferfv(WebGL2RenderingContext.COLOR,1,C.yb),r.clearBufferfv(WebGL2RenderingContext.COLOR,2,C.yb),r.enable(r.DEPTH_TEST);const c=this.projectionParameters.value,d=C.eR.create();C.eR.transformQuat(d,C.T2[2],this.navigationState.pose.orientation.orientation),C.eR.scale(d,d,-1);const u=.2,h=1-u,p={wireFrame:this.viewer.wireFrame.value,projectionParameters:c,lightDirection:d,ambientLighting:u,directionalLighting:h,pickIDs:e.pickIDs,emitter:nh,emitColor:!0,emitPickID:!0,alreadyEmittedPickID:!1,bindFramebuffer:a,frameNumber:this.context.frameNumber,sliceViewsPresent:this.sliceViews.size>0,isContinuousCameraMotionInProgress:this.isContinuousCameraMotionInProgress};C.pB.copy(e.invTransform,c.invViewProjectionMat);const{visibleLayers:m}=this.visibleLayerTracker;let g=!1,v=!1,y=!1,S=!1;for(const[w,b]of m)w.isTransparent?(g=!0,w.isVolumeRendering&&(S=!0,v=v||!this.isContinuousCameraMotionInProgress||dS(w))):w.isAnnotation?y=!0:w.draw(p,b);if(this.hasVolumeRendering=S,this.drawSliceViews(p),y){r.enable(WebGL2RenderingContext.BLEND),r.depthFunc(WebGL2RenderingContext.LEQUAL),r.blendFunc(WebGL2RenderingContext.SRC_ALPHA,WebGL2RenderingContext.ONE_MINUS_SRC_ALPHA);for(const[w,b]of m)if(w.isAnnotation){const x=w;x.base.state.displayState.disablePicking.value?(o(),x.draw(p,b),p.bindFramebuffer()):x.draw(p,b)}r.depthFunc(WebGL2RenderingContext.LESS),r.disable(WebGL2RenderingContext.BLEND)}if(this.viewer.showAxisLines.value&&this.drawAxisLines(),r.stencilOp(WebGL2RenderingContext.KEEP,WebGL2RenderingContext.KEEP,WebGL2RenderingContext.KEEP),g){let w=t,b=n;if(this.shouldDownsample){this.frameRateCalculator.setFrameDeltas(this.context.getLastFrameTimesInMs(this.frameRateCalculator.numberOfStoredFrameDeltas));const N=this.frameRateCalculator.calculateDownsamplingRate(np.MEAN);if(N>1){const k=t/n;w=Math.round(t/N),b=Math.round(w/k)}}let x=()=>{},E=()=>{},D=()=>{};if(this.hasVolumeRendering){p.maxProjectionEmit=sh;const{maxProjectionConfiguration:N}=this;x=()=>{N.bind(w,b)},r.depthMask(!0),x(),p.bindMaxProjectionBuffer=x,r.clearColor(0,0,0,0),r.clearDepth(0),r.clear(WebGL2RenderingContext.COLOR_BUFFER_BIT|WebGL2RenderingContext.DEPTH_BUFFER_BIT);const{maxProjectionPickConfiguration:k}=this;E=()=>{k.bind(w,b)},E(),r.clear(WebGL2RenderingContext.COLOR_BUFFER_BIT|WebGL2RenderingContext.DEPTH_BUFFER_BIT),D=()=>{this.volumeRenderingConfiguration.bind(w,b)},D(),p.bindVolumeRenderingBuffer=D,r.clearDepth(1),r.clearColor(0,0,0,1),r.clear(WebGL2RenderingContext.COLOR_BUFFER_BIT|WebGL2RenderingContext.DEPTH_BUFFER_BIT)}const{transparentConfiguration:I}=this;p.bindFramebuffer=()=>{I.bind(t,n)},p.bindFramebuffer(),r.depthMask(!1),r.enable(WebGL2RenderingContext.BLEND),r.clearColor(0,0,0,1),r.clear(WebGL2RenderingContext.COLOR_BUFFER_BIT),p.emitter=ih,r.blendFuncSeparate(WebGL2RenderingContext.ONE,WebGL2RenderingContext.ONE,WebGL2RenderingContext.ZERO,WebGL2RenderingContext.ONE_MINUS_SRC_ALPHA),p.emitPickID=!1;let L=0;for(const[N,k]of m)if(N.isVolumeRendering){p.depthBufferTexture=this.offscreenFramebuffer.colorBuffers[1].texture;const O=dS(N),V=!O&&!this.isContinuousCameraMotionInProgress&&!p.wireFrame;if(O?(r.depthMask(!0),r.disable(WebGL2RenderingContext.BLEND),r.depthFunc(WebGL2RenderingContext.GREATER),L!==2&&(p.emitter=sh,x())):(L!==1&&(p.emitter=ih,D()),r.disable(WebGL2RenderingContext.DEPTH_TEST),L=1),N.draw(p,k),r.enable(WebGL2RenderingContext.DEPTH_TEST),!V&&!O)continue;E(),this.maxProjectionToPickCopyHelper.draw(this.maxProjectionConfiguration.colorBuffers[1].texture,this.maxProjectionConfiguration.colorBuffers[2].texture,this.maxProjectionConfiguration.colorBuffers[3].texture),r.enable(WebGL2RenderingContext.BLEND),r.blendFuncSeparate(WebGL2RenderingContext.ONE,WebGL2RenderingContext.ONE,WebGL2RenderingContext.ZERO,WebGL2RenderingContext.ONE_MINUS_SRC_ALPHA),O&&(D(),r.depthMask(!1),r.disable(WebGL2RenderingContext.DEPTH_TEST),this.maxProjectionColorCopyHelper.draw(this.maxProjectionConfiguration.colorBuffers[0].texture,this.maxProjectionConfiguration.colorBuffers[1].texture)),x(),p.emitter=sh,r.depthMask(!0),r.clearColor(0,0,0,0),r.clearDepth(0),r.clear(WebGL2RenderingContext.COLOR_BUFFER_BIT|WebGL2RenderingContext.DEPTH_BUFFER_BIT),r.clearDepth(1),r.clearColor(0,0,0,1),r.depthMask(!1),r.enable(WebGL2RenderingContext.DEPTH_TEST),r.depthFunc(WebGL2RenderingContext.LESS),L=2}else N.isTransparent&&(L!==0&&(p.emitter=ih,p.bindFramebuffer()),L=0,N.draw(p,k));r.disable(WebGL2RenderingContext.DEPTH_TEST),S&&(p.bindFramebuffer(),this.transparentToTransparentCopyHelper.draw(this.volumeRenderingConfiguration.colorBuffers[0].texture,this.volumeRenderingConfiguration.colorBuffers[1].texture)),r.blendFunc(WebGL2RenderingContext.ONE_MINUS_SRC_ALPHA,WebGL2RenderingContext.SRC_ALPHA),this.offscreenFramebuffer.bindSingle(0),this.transparencyCopyHelper.draw(I.colorBuffers[0].texture,I.colorBuffers[1].texture),r.depthMask(!0),r.disable(WebGL2RenderingContext.BLEND),r.enable(WebGL2RenderingContext.DEPTH_TEST),p.bindFramebuffer=a,a(),r.enable(WebGL2RenderingContext.STENCIL_TEST),r.drawBuffers([r.NONE,r.COLOR_ATTACHMENT1,r.COLOR_ATTACHMENT2]),p.emitter=nh,p.emitPickID=!0,p.emitColor=!1,r.stencilFunc(WebGL2RenderingContext.NOTEQUAL,3,1),r.stencilOp(WebGL2RenderingContext.KEEP,WebGL2RenderingContext.KEEP,WebGL2RenderingContext.REPLACE),r.stencilMask(2),v&&this.maxProjectionPickCopyHelper.draw(this.maxProjectionPickConfiguration.colorBuffers[0].texture,this.maxProjectionPickConfiguration.colorBuffers[1].texture);for(const[N,k]of m)!N.isTransparent||!N.transparentPickEnabled||N.isVolumeRendering||N.draw(p,k);r.stencilFunc(WebGL2RenderingContext.EQUAL,0,3),r.stencilOp(WebGL2RenderingContext.KEEP,WebGL2RenderingContext.KEEP,WebGL2RenderingContext.KEEP),r.stencilMask(0);for(const[N,k]of m)!N.isTransparent||N.transparentPickEnabled||N.draw(p,k)}if(r.stencilMask(4294967295),r.disable(WebGL2RenderingContext.STENCIL_TEST),this.viewer.showScaleBar.value&&this.viewer.orthographicProjection.value){r.drawBuffers([r.COLOR_ATTACHMENT0]),r.disable(WebGL2RenderingContext.DEPTH_TEST),r.enable(WebGL2RenderingContext.BLEND),r.blendFunc(WebGL2RenderingContext.SRC_ALPHA,WebGL2RenderingContext.ONE_MINUS_SRC_ALPHA);const{scaleBars:w}=this,b=this.viewer.scaleBarOptions.value;w.draw(this.renderViewport,this.navigationState.displayDimensionRenderInfo.value,this.navigationState.relativeDisplayScales.value,this.navigationState.zoomFactor.value/this.renderViewport.logicalHeight,b),r.disable(WebGL2RenderingContext.BLEND)}return this.offscreenFramebuffer.unbind(),this.setGLClippedViewport(),this.offscreenCopyHelper.draw(this.offscreenFramebuffer.colorBuffers[0].texture),!0}drawSliceViews(e){const{sliceViewRenderHelper:t}=this,{lightDirection:n,ambientLighting:s,directionalLighting:r,projectionParameters:{viewProjectionMat:o}}=e,a=this.viewer.showSliceViews.value;for(const[l,c]of this.sliceViews){if(!c&&!a)continue;const{width:d,height:u,invViewMatrix:h,viewportNormalInCanonicalCoordinates:p}=l.projectionParameters.value;if(d===0||u===0||!l.valid)continue;const m=Math.abs(C.eR.dot(n,p)),g=s+m*r,v=PO;C.pB.identity(v),v[0]=d/2,v[5]=-u/2,C.pB.multiply(v,h,v),C.pB.multiply(v,o,v);const y=yb,S=this.viewer.crossSectionBackgroundColor.value;y[0]=S[0],y[1]=S[1],y[2]=S[2],y[3]=1,t.draw(l.offscreenFramebuffer.colorBuffers[0].texture,v,C.ln.fromValues(g,g,g,1),yb,0,0,1,1)}}drawAxisLines(){const{zoomFactor:{value:e}}=this.viewer.navigationState,t=this.projectionParameters.value,n=Math.min(t.logicalWidth,t.logicalHeight)/this.renderViewport.logicalHeight/4,s=e*n,{gl:r}=this;r.drawBuffers([r.COLOR_ATTACHMENT0]),this.axesLineHelper.draw(ob(t,s),!1)}zoomByMouse(e){this.navigationState.zoomBy(e)}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */var FO=(i=>(i[i.COLOR=0]="COLOR",i[i.PICK=1]="PICK",i[i.NUM_TEXTURES=2]="NUM_TEXTURES",i))(FO||{});function UO(i){i.addOutputBuffer("vec4","out_fragColor",0),i.addOutputBuffer("highp vec4","out_pickId",1),i.addFragmentCode(` +void emit(vec4 color, highp uint pickId) { + out_fragColor = color; + float pickIdFloat = float(pickId); + out_pickId = vec4(pickIdFloat, pickIdFloat, pickIdFloat, 1.0); +} +`)}function $O(i){i.addOutputBuffer("vec4","out_fragColor",null),i.addFragmentCode(` +void emit(vec4 color, highp uint pickId) { + out_fragColor = color; +} +`)}const os=C.eR.create(),GO=C.eR.create(),zO=C.ln.create();class Sl extends gb{constructor(e,t,n,s){super(e,t,s),this.sliceView=n,this.axesLineHelper=this.registerDisposer(vl.get(this.gl)),this.sliceViewRenderHelper=this.registerDisposer(ia.get(this.gl,$O)),this.colorFactor=C.ln.fromValues(1,1,1,1),this.pickIDs=new lb,this.offscreenFramebuffer=this.registerDisposer(new $n(this.gl,{colorBuffers:[new gn(this.gl,WebGL2RenderingContext.RGBA8,WebGL2RenderingContext.RGBA,WebGL2RenderingContext.UNSIGNED_BYTE),new gn(this.gl,WebGL2RenderingContext.R32F,WebGL2RenderingContext.RED,WebGL2RenderingContext.FLOAT)]})),this.offscreenCopyHelper=this.registerDisposer(Dn.get(this.gl)),this.scaleBars=this.registerDisposer(new mb(this.gl)),s.wireFrame.changed.add(()=>this.scheduleRedraw()),Z(t,"rotate-via-mouse-drag",r=>{const{mouseState:o}=this.viewer;if(o.updateUnconditionally()){const a=Float32Array.from(o.position);zt(r.detail,(l,c,d)=>{this.context.flagContinuousCameraMotion();const{pose:u}=this.navigationState,h=C.eR.transformQuat(os,C.T2[0],u.orientation.orientation),p=C.eR.transformQuat(GO,C.T2[1],u.orientation.orientation);this.viewer.navigationState.pose.rotateAbsolute(p,-c/4*Math.PI/180,a),this.viewer.navigationState.pose.rotateAbsolute(h,-d/4*Math.PI/180,a)})}}),Z(t,"rotate-in-plane-via-touchrotate",r=>{const{detail:o}=r,{mouseState:a}=this.viewer;this.handleMouseMove(o.centerX,o.centerY),a.updateUnconditionally()&&(this.context.flagContinuousCameraMotion(),this.navigationState.pose.rotateAbsolute(this.sliceView.projectionParameters.value.viewportNormalInCanonicalCoordinates,o.angle-o.prevAngle,a.position))}),this.registerDisposer(n),this.visibleLayerTracker=_g(this.viewer.layerManager,Fi,this.viewer.visibleLayerRoles,this),this.registerDisposer(s.crossSectionBackgroundColor.changed.add(()=>this.scheduleRedraw())),this.registerDisposer(n.visibility.add(this.visibility)),this.registerDisposer(n.viewChanged.add(()=>{this.visible&&e.scheduleRedraw()})),this.registerDisposer(s.showAxisLines.changed.add(()=>{this.visible&&this.scheduleRedraw()})),this.registerDisposer(s.showScaleBar.changed.add(()=>{this.visible&&this.context.scheduleRedraw()})),this.registerDisposer(s.scaleBarOptions.changed.add(()=>{this.visible&&this.context.scheduleRedraw()}))}flushBackendProjectionParameters(){this.sliceView.flushBackendProjectionParameters()}get displayDimensionRenderInfo(){return this.navigationState.displayDimensionRenderInfo}get rpc(){return this.sliceView.rpc}get rpcId(){return this.sliceView.rpcId}get navigationState(){return this.sliceView.navigationState}translateByViewportPixels(e,t){const{pose:n}=this.viewer.navigationState;n.updateDisplayPosition(s=>{C.eR.set(s,-e,-t,0),C.eR.transformMat4(s,s,this.sliceView.projectionParameters.value.invViewMatrix)})}translateDataPointByViewportPixels(e,t,n,s){const r=this.sliceView.projectionParameters.value;return C.eR.transformMat4(e,t,r.viewMatrix),C.eR.set(e,e[0]+n,e[1]+s,e[2]),C.eR.transformMat4(e,e,r.invViewMatrix),e}isReady(){if(!this.visible)return!1;const{sliceView:e}=this;if(this.ensureBoundsUpdated(),!e.isReady())return!1;const t={projectionParameters:e.projectionParameters.value,sliceView:e};for(const[n,s]of this.visibleLayerTracker.visibleLayers)if(!n.isReady(t,s))return!1;return!0}drawWithPicking(e){const{sliceView:t}=this;if(!t.valid)return!1;t.updateRendering();const n=t.projectionParameters.value,{width:s,height:r,invViewProjectionMat:o}=n;C.pB.copy(e.invTransform,o);const{gl:a}=this;this.offscreenFramebuffer.bind(s,r),a.disable(WebGL2RenderingContext.SCISSOR_TEST),this.gl.clearColor(0,0,0,0),a.clear(WebGL2RenderingContext.COLOR_BUFFER_BIT);const l=zO,c=this.viewer.crossSectionBackgroundColor.value;l[0]=c[0],l[1]=c[1],l[2]=c[2],l[3]=1,this.offscreenFramebuffer.bindSingle(0),this.sliceViewRenderHelper.draw(t.offscreenFramebuffer.colorBuffers[0].texture,C.r3,this.colorFactor,l,0,0,1,1);const{visibleLayers:d}=this.visibleLayerTracker,{pickIDs:u}=this;u.clear();const h=()=>{a.disable(WebGL2RenderingContext.SCISSOR_TEST),a.enable(WebGL2RenderingContext.BLEND),a.blendFunc(WebGL2RenderingContext.SRC_ALPHA,WebGL2RenderingContext.ONE_MINUS_SRC_ALPHA),this.offscreenFramebuffer.bind(s,r)};h();const p={wireFrame:this.viewer.wireFrame.value,projectionParameters:n,pickIDs:u,emitter:UO,emitColor:!0,emitPickID:!0,sliceView:t,bindFramebuffer:h,frameNumber:this.context.frameNumber};for(const[m,g]of d)m.draw(p,g);if(a.disable(WebGL2RenderingContext.BLEND),this.viewer.showAxisLines.value||this.viewer.showScaleBar.value){if(this.offscreenFramebuffer.bindSingle(0),this.viewer.showAxisLines.value){const m=Math.min(n.logicalWidth,n.logicalHeight)/4*1.5,{zoomFactor:{value:g}}=this.viewer.navigationState;this.axesLineHelper.draw((0,C.Qi)(ob(n,m*g)))}this.viewer.showScaleBar.value&&(a.enable(WebGL2RenderingContext.BLEND),a.blendFunc(WebGL2RenderingContext.SRC_ALPHA,WebGL2RenderingContext.ONE_MINUS_SRC_ALPHA),this.scaleBars.draw(n,this.navigationState.displayDimensionRenderInfo.value,this.navigationState.relativeDisplayScales.value,this.navigationState.zoomFactor.value,this.viewer.scaleBarOptions.value),a.disable(WebGL2RenderingContext.BLEND))}return this.offscreenFramebuffer.unbind(),this.setGLClippedViewport(),this.offscreenCopyHelper.draw(this.offscreenFramebuffer.colorBuffers[0].texture),!0}ensureBoundsUpdated(){super.ensureBoundsUpdated(),this.sliceView.projectionParameters.setViewport(this.renderViewport)}issuePickRequest(e,t){const{offscreenFramebuffer:n}=this;n.readPixelFloat32IntoBuffer(1,e-Et,t-Et,0,je,je)}completePickRequest(e,t,n,s){const{mouseState:r}=this.viewer;r.pickedRenderLayer=null,fb(n,0,4,e,t,s.viewportWidth,s.viewportHeight);const{viewportWidth:o,viewportHeight:a}=s,l=yl.length,{value:c}=this.navigationState.position,d=c.length,u=this.navigationState.pose.displayDimensions.value,{displayRank:h,displayDimensionIndices:p}=u,m=(y,S,w)=>{const b=e+y,x=t+S;os[0]=2*b/o-1,os[1]=2*x/a-1,os[2]=0,C.eR.transformMat4(os,os,s.invTransform),w.set(c);for(let E=0;E{let{position:b}=r;b.length!==d&&(b=r.position=new Float32Array(d)),m(y-Et,S-Et,b),this.pickIDs.setMouseState(r,w),r.setActive(!0)};for(let y=0;y1024){const e=Math.log2(i)|0,t=i/2**e;return`${rm(t,1)}p${e}`}return i.toString()}const JO=[i=>i.name,i=>i.scaleFactor],jO=2e3;class YO extends T.O8{constructor(e,t,n,s="px"){super(),this.displayDimensionRenderInfo=e,this.zoom=t,this.depthRange=n,this.displayUnit=s,this.element=document.createElement("div"),this.dimensionGridContainer=document.createElement("div"),this.depthGridContainer=document.createElement("div"),this.defaultCheckbox=document.createElement("input"),this.dimensionElements=Array.from(Array(3),(g,v)=>{const y=document.createElement("div");y.classList.add("neuroglancer-display-dimensions-widget-dimension"),y.style.display="contents",Z(y,"adjust-via-wheel",D=>{const I=D.detail,{deltaY:L}=I;L!==0&&this.zoomDimension(v,Math.sign(L))});const S=document.createElement("input");S.classList.add("neuroglancer-display-dimensions-widget-name"),S.title="Change display dimensions",S.spellcheck=!1,S.autocomplete="off",S.style.color=WO[v],S.style.gridColumn="1",S.style.gridRow=`${v+1}`,S.addEventListener("focus",()=>{S.select()}),y.appendChild(S);const w=document.createElement("span");w.classList.add("neuroglancer-display-dimensions-widget-scale-factor");const b=document.createElement("input");b.spellcheck=!1,b.title="Change relative scale at which dimension is displayed",b.autocomplete="off",w.style.gridColumn="2",w.style.gridRow=`${v+1}`,b.addEventListener("focus",()=>{b.select()}),w.appendChild(b),y.appendChild(w);const x=document.createElement("span");x.classList.add("neuroglancer-display-dimensions-widget-scale"),x.style.gridColumn="3",x.style.gridRow=`${v+1}`,y.appendChild(x),this.dimensionGridContainer.appendChild(y);const E={name:S,container:y,scaleFactor:b,scale:x,scaleFactorModified:!1};S.addEventListener("input",()=>{$t(S),this.updateNameValidity()}),Z(S,"commit",()=>{this.updateNames()}),S.addEventListener("blur",D=>{const{relatedTarget:I}=D;this.dimensionElements.some(L=>L.name===I)||this.updateNames()||this.updateView()}),w.addEventListener("click",D=>{const{target:I}=D;I!==b&&(b.focus(),D.preventDefault())}),b.addEventListener("input",()=>{$t(b),E.scaleFactorModified=!0}),Z(b,"commit",()=>{this.updateScaleFactors()}),b.addEventListener("blur",()=>{this.updateScaleFactors()||this.updateView()});for(const D of JO)Z(D(E),"move-up",()=>{v!==0&&D(this.dimensionElements[v-1]).focus()}),Z(D(E),"move-down",()=>{v!==2&&D(this.dimensionElements[v+1]).focus()});return E}),this.scheduleUpdateView=(0,Qe.t)(()=>this.updateView());const{element:r,dimensionGridContainer:o,defaultCheckbox:a}=this,l=document.createElement("label"),c=this.registerCancellable((0,Fe.A)(()=>{r.dataset.active="false"},jO)),d=()=>{r.dataset.active="true",c()};this.registerDisposer(t.changed.add(d)),this.registerDisposer(e.relativeDisplayScales.changed.add(d)),this.registerDisposer(n.changed.add(d)),r.classList.add("neuroglancer-display-dimensions-widget"),r.appendChild(o),o.classList.add("neuroglancer-display-dimensions-widget-dimension-grid"),r.addEventListener("pointerleave",()=>{const g=document.activeElement;g instanceof HTMLElement&&r.contains(g)&&g.blur()}),a.type="checkbox",l.appendChild(a),l.appendChild(document.createTextNode("Default")),l.title="Display first 3 dimensions",l.classList.add("neuroglancer-display-dimensions-widget-default"),a.addEventListener("change",()=>{this.updateDefault()}),o.appendChild(l),this.registerDisposer(e),this.registerDisposer(n),this.registerDisposer(t.changed.add(this.scheduleUpdateView)),this.registerDisposer(e.changed.add(this.scheduleUpdateView));const u=this.registerDisposer(new yn(r,Sb));u.allShortcutsAreGlobal=!0,this.registerDisposer(new tn(r,Sb)),Z(o,"cancel",()=>{this.updateView();const g=document.activeElement;g instanceof HTMLElement&&r.contains(g)&&g.blur()});const{depthGridContainer:h}=this;h.classList.add("neuroglancer-depth-range-widget-grid"),r.appendChild(h);const p=document.createElement("label"),m=document.createElement("input");m.type="checkbox",p.classList.add("neuroglancer-depth-range-relative-checkbox-label"),m.classList.add("neuroglancer-depth-range-relative-checkbox"),p.appendChild(m),p.appendChild(document.createTextNode("Zoom-relative")),m.addEventListener("change",()=>{const g=m.checked;let v=this.depthRange.value;g!==v<0&&(g?v=-v/this.zoom.value:v=-v*this.zoom.value,this.depthRange.value=v)}),p.title="Depth range is multiplied by scale",r.appendChild(p),Z(h,"adjust-via-wheel",g=>{const v=g.detail,{deltaY:y}=v;if(y===0)return;const S=this.depthRange.value;this.depthRange.value=S*2**Math.sign(y)}),this.registerDisposer((0,_.no)((g,v,{factors:y})=>{Me(h);const{displayRank:S,globalDimensionNames:w,displayDimensionIndices:b,displayDimensionUnits:x,displayDimensionScales:E,canonicalVoxelFactors:D}=v,I=[],L=()=>{m.checked=this.depthRange.value<0;let O=this.depthRange.value;O<0&&(O*=-this.zoom.value);for(const V of I){const{input:z}=V;z.value=Ri(O*V.scale,V.unit,{precision:2,elide1:!1}),$t(z)}},N=O=>{const V=sr(O.input.value);if(V===void 0||V.unit!==O.unit)return!1;let z=V.scale/O.scale;return this.depthRange.value<0&&(z=-z/this.zoom.value),this.depthRange.value=z,!0};for(let O=0;Oce.unit===Y&&ce.factor===Q);if(X===void 0){const ce=document.createElement("div");ce.title="Visible depth range",ce.style.display="contents",h.appendChild(ce);const oe=document.createElement("span");oe.textContent="\xB1",ce.appendChild(oe);const Se=document.createElement("input");Se.spellcheck=!1,Se.autocomplete="off",Se.addEventListener("focus",()=>{Se.select()}),Z(Se,"commit",()=>{N(X)}),Se.addEventListener("change",()=>{N(X)||L()}),Se.addEventListener("input",()=>{$t(Se)}),ce.appendChild(Se);const Ke=document.createElement("span");Ke.classList.add("neuroglancer-depth-range-widget-dimension-names"),ce.appendChild(Ke),X={unit:Y,factor:Q,dimensionNames:[],input:Se,label:Ke,scale:E[O]/D[O]},I.push(X)}X.dimensionNames.push(z)}for(const O of I)O.dimensionNames.length!==S&&(O.label.textContent=O.dimensionNames.join(" "));g.registerDisposer(Z(h,"cancel",()=>{L();const O=document.activeElement;O instanceof HTMLElement&&h.contains(O)&&O.blur()}));const k=g.registerCancellable((0,Qe.t)(L));g.registerDisposer(this.depthRange.changed.add(k)),g.registerDisposer(this.zoom.changed.add(k)),L()},e,this.relativeDisplayScales)),this.updateView()}zoomDimension(e,t){this.updateScaleFactors();const{displayDimensions:n}=this,{relativeDisplayScales:s}=this,{displayDimensionIndices:r}=n.value,o=r[e];if(o===-1)return;const{factors:a}=s.value,l=new Float64Array(a);l[o]*=2**-t,s.setFactors(l)}updateNameValidity(){const{dimensionElements:e}=this,{displayDimensionIndices:t}=this.displayDimensions.value,n=e.map(l=>l.name.value),s=jl(n),r=this.displayDimensions.coordinateSpace.value,{names:o}=r,a=n.length;for(let l=0;la.name.value).filter(a=>a.length>0);if(!ho(e))return!1;const{displayDimensions:t}=this.displayDimensionRenderInfo;if(e.length===0)return t.reset(),!0;const n=new Int32Array(3);n.fill(-1);const s=t.coordinateSpace.value,{names:r}=s,o=e.length;for(let a=0;aat(n));for(let s=0;s<2;++s){const r=t[Math.min(t.length-1,s)];i.registerDisposer(Z(e.element,s===0?"toggle-layout":"toggle-layout-alternative",o=>{i.container.name=r,o.stopPropagation()}))}for(const s of t){const r=document.createElement("button"),o=document.createElement("div");r.appendChild(o),o.textContent=oh.get(s),r.title=`Switch to ${s} layout.`,r.addEventListener("click",()=>{i.container.name=s}),n.appendChild(r)}e.element.appendChild(n)}function XO(i,e){const t=new na(i.chunkManager,i.layerManager,e.navigationState.addRef(),i.wireFrame),n=()=>{const{width:{value:s},height:{value:r}}=e;t.projectionParameters.setViewport({width:s,height:r,logicalWidth:s,logicalHeight:r,visibleLeftFraction:0,visibleTopFraction:0,visibleWidthFraction:1,visibleHeightFraction:1})};return t.registerDisposer(e.width.changed.add(n)),t.registerDisposer(e.height.changed.add(n)),n(),t}function lh(i,e,t){const n=new Map;(()=>{const r=new Set;for(const o of t.values()){if(r.add(o),n.has(o))continue;const a=XO(i,o);e.sliceViews.set(a,!0),n.set(o,a)}for(const[o,a]of n)r.has(o)||e.sliceViews.delete(a)})()}class ZO extends T.O8{constructor(e,t,n,s){super(),this.container=e,this.rootElement=t,this.viewer=n;const r=qO(n),{display:o}=n,a={...ah(e),showSliceViews:n.showPerspectiveSliceViews,showSliceViewsCheckbox:!0},l={...bl(n),showScaleBar:n.showScaleBar},c={...bl(n),showScaleBar:new nt(!1,!1)},d=(h,p,m,g)=>{const v=this.registerDisposer(new Sl(o,p,r.get(h),m));return g&&Zs(this,v),er(this,v,[h,`${h}-3d`]),v},u=[dn(1,rs("column",[dn(1,rs("row",[dn(1,h=>{d("xy",h,l,!0)}),dn(1,h=>{d("xz",h,c,!1)})])),dn(1,rs("row",[dn(1,h=>{const p=this.registerDisposer(new rh(o,h,a));for(const m of r.values())p.sliceViews.set(m.addRef(),!1);Zs(this,p),lh(n,p,s),er(this,p,["3d"])}),dn(1,h=>{d("yz",h,c,!1)})]))]))];rs("row",u)(t)}disposed(){Me(this.rootElement),super.disposed()}}class e_ extends T.O8{constructor(e,t,n,s,r,o){super(),this.container=e,this.rootElement=t,this.viewer=n,this.direction=s;const a=so(n,r),{display:l}=n,c={...ah(e),showSliceViews:n.showPerspectiveSliceViews,showSliceViewsCheckbox:!0},d={...bl(n),showScaleBar:n.showScaleBar};dn(1,rs(s,[dn(1,u=>{const h=this.registerDisposer(new Sl(l,u,a,d));Zs(this,h),er(this,h,[r,"4panel"])}),dn(1,u=>{const h=this.registerDisposer(new rh(l,u,c));h.sliceViews.set(a.addRef(),!1),lh(n,h,o),Zs(this,h),er(this,h,["3d","4panel"])})]))(t)}disposed(){Me(this.rootElement),super.disposed()}}class t_ extends T.O8{constructor(e,t,n,s){super(),this.container=e,this.rootElement=t,this.viewer=n;const r=so(n,s),o={...bl(n),showScaleBar:n.showScaleBar};rs("row",[dn(1,a=>{const l=this.registerDisposer(new Sl(n.display,a,r,o));Zs(this,l),er(this,l,["4panel",`${s}-3d`])})])(t)}disposed(){Me(this.rootElement),super.disposed()}}class n_ extends T.O8{constructor(e,t,n,s){super(),this.container=e,this.rootElement=t,this.viewer=n;const r={...ah(e),showSliceViews:new nt(!1,!1)};rs("row",[dn(1,o=>{const a=this.registerDisposer(new rh(n.display,o,r));lh(n,a,s),Zs(this,a),er(this,a,["4panel"])})])(t)}disposed(){Me(this.rootElement),super.disposed()}}const ch=new Map([["4panel",{factory:(i,e,t,n)=>new ZO(i,e,t,n)}],["3d",{factory:(i,e,t,n)=>new n_(i,e,t,n)}]]);for(const i of bb.keys()){ch.set(i,{factory:(t,n,s)=>new t_(t,n,s,i)});const e=`${i}-3d`;oh.set(i,Cb),oh.set(e,"\u25EB"),ch.set(e,{factory:(t,n,s,r)=>new e_(t,n,s,"row",i,r)})}function xb(i){const e=ch.get(i);if(e===void 0)throw new Error(`Invalid layout name: ${JSON.stringify(i)}.`);return e}function i_(i){return xb(i),i}class s_ extends T.O8{constructor(e){super(),this.width=new _.DN(1e3,f.We),this.height=new _.DN(1e3,f.We),this.changed=new j.IY,this.position=new Yp(e.position.addRef()),this.position.changed.add(this.changed.dispatch),this.orientation=new vc(e.pose.orientation.addRef()),this.orientation.changed.add(this.changed.dispatch),this.width.changed.add(this.changed.dispatch),this.height.changed.add(this.changed.dispatch),this.scale=new yc(e.zoomFactor.addRef(),e.zoomFactor.displayDimensionRenderInfo.addRef()),this.scale.changed.add(this.changed.dispatch),this.navigationState=this.registerDisposer(new ws(new Cs(this.position.value,e.pose.displayDimensionRenderInfo.addRef(),this.orientation.value),this.scale.value,e.depthRange.addRef()))}restoreState(e){(0,f.Rf)(e),Mt(e,"width",this.width),Mt(e,"height",this.height),Mt(e,"position",vr(this.position)),Mt(e,"orientation",this.orientation),Mt(e,"scale",this.scale),Mt(e,"zoom",vr(this.scale))}reset(){this.width.reset(),this.height.reset(),this.position.reset(),this.orientation.reset(),this.scale.reset()}toJSON(){return{width:this.width.toJSON(),height:this.height.toJSON(),position:this.position.toJSON(),orientation:this.orientation.toJSON(),scale:this.scale.toJSON()}}}class r_ extends rc{constructor(e){super((t,n)=>t.registerDisposer(t.registerDisposer(n).changed.add(this.changed.dispatch))),this.parentNavigationState=e,this.registerDisposer(e)}restoreState(e){(0,f.Rf)(e);for(const t of Object.keys(e)){const n=new s_(this.parentNavigationState);try{this.set(t,n.addRef()),n.restoreState(e[t])}finally{n.dispose()}}}reset(){this.clear()}toJSON(){if(this.size===0)return;const e={};for(const[t,n]of this)e[t]=n.toJSON();return e}}class o_ extends T.O8{constructor(e,t){super(),this.changed=new j.IY,this.orthographicProjection=new nt(!1),this.type=new _.DN(t,i_),this.type.changed.add(this.changed.dispatch),this.crossSections=this.registerDisposer(new r_(e.addRef())),this.crossSections.changed.add(this.changed.dispatch),this.orthographicProjection.changed.add(this.changed.dispatch),this.registerDisposer(e)}reset(){this.crossSections.clear(),this.orthographicProjection.reset(),this.type.reset()}restoreState(e){this.crossSections.clear(),this.orthographicProjection.reset(),typeof e=="string"?this.type.restoreState(e):((0,f.Rf)(e),(0,f.cQ)(e,"type",t=>this.type.restoreState(t)),(0,f.cQ)(e,"orthographicProjection",t=>this.orthographicProjection.restoreState(t)),(0,f.cQ)(e,"crossSections",t=>t!==void 0&&this.crossSections.restoreState(t)))}toJSON(){const{type:e,crossSections:t,orthographicProjection:n}=this,s=n.toJSON();return t.size===0&&s===void 0?e.value:{type:e.value,crossSections:t.toJSON(),orthographicProjection:s}}}class a_ extends T.O8{constructor(e,t){super(),this.viewer=e,this.element=document.createElement("div"),this.specification=this.registerDisposer(new o_(this.viewer.navigationState.addRef(),t)),this.element.style.flex="1";const n=this.registerCancellable((0,Fe.A)(()=>this.updateLayout(),0));this.specification.type.changed.add(n),Z(this.element,"toggle-orthographic-projection",()=>this.specification.orthographicProjection.toggle()),this.registerDisposer(this.viewer.display.updateStarted.add(()=>n.flush())),n()}get name(){return this.specification.type.value}set name(e){this.specification.type.value=e}get changed(){return this.specification.changed}toJSON(){return this.specification.toJSON()}restoreState(e){this.specification.restoreState(e)}reset(){this.specification.reset()}disposeLayout(){const{layout:e}=this;e!==void 0&&(e.dispose(),this.layout=void 0)}updateLayout(){this.disposeLayout(),this.layout=xb(this.name).factory(this,this.element,this.viewer,this.specification.crossSections)}disposed(){this.disposeLayout(),super.disposed()}}const l_=typeof{cave:{url:"middleauth+https://global.daf-apis.com/nglstate/api/v1/post",default:!0}}<"u"&&Object.keys({cave:{url:"middleauth+https://global.daf-apis.com/nglstate/api/v1/post",default:!0}}).length>0;class c_ extends T.O8{constructor(e){if(super(),this.element=document.createElement("div"),this.button=Ne({text:"Share",title:"Share State"}),typeof{cave:{url:"middleauth+https://global.daf-apis.com/nglstate/api/v1/post",default:!0}}>"u")throw new Error("Cannot construct StateSare without defining STATE_SERVERS");if(Object.keys({cave:{url:"middleauth+https://global.daf-apis.com/nglstate/api/v1/post",default:!0}}).length>1){const t=document.createElement("select");t.style.marginRight="5px",this.registerDisposer(e.selectedStateServer.changed.add(()=>{const n=e.selectedStateServer.value;Object.values({cave:{url:"middleauth+https://global.daf-apis.com/nglstate/api/v1/post",default:!0}}).map(s=>s.url).includes(n)&&(t.value=n)})),this.registerEventListener(t,"change",()=>{e.selectedStateServer.value=t.value});for(const[n,s]of Object.entries({cave:{url:"middleauth+https://global.daf-apis.com/nglstate/api/v1/post",default:!0}})){const r=document.createElement("option");r.textContent=n,r.value=s.url,r.selected=!!s.default,t.appendChild(r)}this.element.appendChild(t),this.selectStateServerElement=t}this.element.appendChild(this.button),this.registerEventListener(this.button,"click",()=>{const t=this.selectStateServerElement?this.selectStateServerElement.value:Object.values({cave:{url:"middleauth+https://global.daf-apis.com/nglstate/api/v1/post",default:!0}})[0].url,n=new URL(t).protocol,{url:s,credentialsProvider:r}=wn(t,Zn);pe.forPromise(Nt(r,s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e.state.toJSON())},ke.cj).then(o=>{const a=new URL(o).protocol,l=o.substring(a.length),c=`${window.location.origin}/#!${n}${l}`;navigator.clipboard.writeText(c).then(()=>{pe.showTemporaryMessage("Share link copied to clipboard")})}).catch(()=>{pe.showTemporaryMessage("Could not access state server.",4e3)}),{initialMessage:`Posting state to ${t}.`,delay:!0,errorPrefix:""})})}disposed(){this.element.remove(),super.disposed()}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function d_(i){return i.startsWith("key")?i.substring(3):i.startsWith("digit")||i.startsWith("arrow")?i.substring(5):i}function u_(i){return i.split("+").map(d_).join("+")}const h_={...Ui,side:"left",row:1};class p_{constructor(){this.location=new Si(h_)}get changed(){return this.location.changed}toJSON(){return(0,f.Zu)(this.location.toJSON())}reset(){this.location.reset()}restoreState(e){this.location.restoreState(e)}}class f_ extends ji{constructor(e,t,n,s,r){super(e,t.location),this.bindings=n,this.toolBinder=r,this.scroll=document.createElement("div"),this.addTitleBar({title:"Help"});const o=document.createElement("div");o.classList.add("neuroglancer-help-body");const{scroll:a}=this;a.classList.add("neuroglancer-help-scroll-container"),o.appendChild(a),this.addBody(o);const l=this.registerCancellable((0,Qe.t)(()=>this.updateView()));this.registerDisposer(r.changed.add(l)),this.registerDisposer(s.layersChanged.add(l)),this.updateView()}updateView(){const{scroll:e,bindings:t,toolBinder:n}=this;if(Me(e),typeof NEUROGLANCER_BUILD_INFO<"u"){const d=document.createElement("h2");d.textContent="Build info";const u=document.createElement("div");u.classList.add("neuroglancer-build-info");const h=document.createElement("a"),{tag:p,url:m,timestamp:g}=NEUROGLANCER_BUILD_INFO;if(h.textContent=p,h.target="_blank",m!==void 0&&(h.href=m),e.appendChild(d),u.appendChild(h),g!==void 0){const v=document.createElement("div");v.classList.add("neuroglancer-build-timestamp");const y=Intl.DateTimeFormat("en",{hour12:!1,dateStyle:"medium",timeStyle:"long"}).format(new Date(g));v.textContent=`Built at ${y}`,u.append(v)}e.appendChild(u)}const s=new Map;function r(d,u){for(const h of d.parents)h.label!==void 0?o(h.label,h):r(h,u);for(const[h,p]of d.bindings.entries()){const m=h.indexOf(":"),g=h.substring(m+1);u.set(g,p.action)}}function o(d,u){if(s.has(u))return;const h={label:d,entries:new Map};r(u,h.entries),s.set(u,h)}for(const[d,u]of t)o(d,u);const a=(d,u)=>{const h=document.createElement("h2");h.textContent=d,e.appendChild(h);for(const[p,m]of u){const g=document.createElement("div");g.className="dt",g.textContent=u_(p);const v=document.createElement("div");v.className="dd",v.textContent=m,e.appendChild(g),e.appendChild(v)}},l=new Map;for(const[d,u]of n.bindings)if(u.context instanceof Rn){let h=l.get(u.context);h===void 0&&(h=[],l.set(u.context,h)),h.push([`shift+key${d.toLowerCase()}`,u.description])}const c=Array.from(l.entries());c.length>0&&(c[0][0].manager.root.layerManager.updateNonArchivedLayerIndices(),c.sort((d,u)=>d[0].managedLayer.nonArchivedLayerIndex-u[0].managedLayer.nonArchivedLayerIndex));for(const[d,u]of c)u.sort(),a(`Tool bindings for layer ${d.managedLayer.nonArchivedLayerIndex+1}: ${d.managedLayer.name}`,u);for(const d of s.values())a(d.label,d.entries)}}/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function g_(i,e){i.style.display="block";const{offsetWidth:t,offsetHeight:n}=i,s=document.documentElement.clientWidth,r=document.documentElement.clientHeight,o=document.documentElement.scrollLeft+Math.min(s-t,e.clientX),a=document.documentElement.scrollTop+Math.min(r-n,e.clientY);i.style.left=o+"px",i.style.top=a+"px"}class m_ extends T.O8{constructor(e){super(),this.element=document.createElement("div"),this.parentDisposers=new Map,this.disabledValue=!1,this.opened=new j.IY,this.closed=new j.IY;const{element:t}=this;t.className="neuroglancer-context-menu",t.style.display="none",t.tabIndex=-1,document.body.appendChild(t),e!==void 0&&this.registerParent(e)}get disabled(){return this.disabledValue}set disabled(e){this.disabledValue!==e&&(this.disabledValue=e,e&&this.hide())}get open(){return this.menuDisposer!==void 0}registerParent(e){const{parentDisposers:t}=this;t.has(e)||t.set(e,(0,T.K6)(e,"contextmenu",n=>{this.show(n),n.stopPropagation(),n.preventDefault()}))}show(e){if(this.disabledValue)return;this.hide();const{element:t}=this,n=(0,T.K6)(document,"mousedown",o=>{o.target instanceof Node&&!t.contains(o.target)&&this.hide()},!0),s=(0,T.K6)(document,"keydown",o=>{o.code==="Escape"&&this.hide()},!0),r=()=>{s(),n(),t.style.display="none"};this.opened.dispatch(),g_(t,e),this.menuDisposer=r}unregisterParent(e){const{parentDisposers:t}=this,n=t.get(e);n!==void 0&&(n(),t.delete(e))}disposed(){const{parentDisposers:e}=this;for(const t of e.values())t();e.clear(),at(this.element)}hide(){this.menuDisposer!==void 0&&(this.menuDisposer(),this.menuDisposer=void 0,this.closed.dispatch())}}/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function Eb(i){return Le(new TextEncoder().encode(i))}function v_(i){return new TextDecoder().decode(We(i))}function T2(i,e){return i+Eb(JSON.stringify(e))}function y_(i,e){if(i.startsWith(e))try{const t=v_(i.substring(e.length));return JSON.parse(t)}catch{return}}function S_(i,e){return i+Eb(JSON.stringify(e))}function b_(i,e){for(const t of i){const n=y_(t,e);if(n!==void 0)return{parameters:n,dragType:t}}}let Tb;function dh(i,e){return i.dataTransfer.dropEffect=e,Tb=e,e}function uh(){return Tb}function C_(i){return i.draggable=!0,(0,T.K6)(i,"dragstart",e=>{e.stopPropagation(),e.preventDefault()})}/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const Db="neuroglancer-layer\0";let un;function Ib(i,e){i.dataTransfer.setData(S_(Db,e.layers.map(s=>({name:s.name,visible:s.visible}))),JSON.stringify({layers:e.layers.map(s=>s.toJSON()),layout:e.layoutSpec})),un!==void 0&&un.disposer();let t;const n=()=>{e.manager.unregisterDisposer(n);for(const s of e.layers)s.dispose();e.manager.dispose(),un===t&&(un=void 0)};un=t={manager:e.manager.addRef(),layers:e.layers.map(s=>s.addRef()),layoutSpec:e.layoutSpec,isLayerListPanel:e.isLayerListPanel??!1,disposer:n}}function Cl(i="none"){if(un!==void 0){if(i==="move"){const e=new Set(un.layers);un.manager.layerManager.filter(t=>!e.has(t))}un.disposer()}}function wl(i){return b_(i.dataTransfer.types,Db)}function Lb(i){if(un!==void 0&&un.manager.rootLayers===i.rootLayers)return un}class Rb{initializeExternalLayers(e){const{dragType:t}=this;if(t!==void 0)try{const{layers:n,layout:s}=JSON.parse(e.dataTransfer.getData(t));if(!Array.isArray(n)||this.numSourceLayers!==n.length)throw new Error("Invalid layer drop data");this.layoutSpec=s;for(const[r,o]of this.layers)WT(r,n[o])}catch{return!1}return!0}updateArchiveStates(e){const{targetIsLayerListPanel:t}=this,n=e.dataTransfer.dropEffect;for(const s of this.layers.keys()){let r=t;t&&!s.archived&&n!=="copy"&&this.sourceIsLayerListPanel&&(r=!1),(s.archived!==r||r&&s.visible)&&(s.archived=r,r&&(s.visible=!1),s.layerChanged.dispatch())}}get method(){return this.sourceManager!==void 0?this.manager===this.sourceManager&&this.sourceIsLayerListPanel===this.targetIsLayerListPanel?"move":"link":"copy"}compatibleWithMethod(e){return this.method===e?!0:this.forceCopy&&e!=="copy"?!1:!this.moveSupported&&e==="move"}}function kb(i,e,t){let n;i.shiftKey?n="copy":i.ctrlKey&&t?n="move":n=e;let s="";const r=o=>{s!==""&&(s+=", "),s+=o};return e!=="none"&&n!==e&&(i.shiftKey?r(`release SHIFT to ${e}`):r(`release CONTROL to ${e}`)),n!=="copy"&&r("hold SHIFT to copy"),n!=="move"&&t&&e!=="move"&&r("hold CONTROL to move"),{dropEffect:n,dropEffectMessage:s}}function Pb(i,e,t,n){const s=Lb(e);let r=!1,o;return s===void 0?o="copy":n?(s.isLayerListPanel||(r=!0),o="link"):s.manager===e&&s.isLayerListPanel===t?(o="move",r=!0):t?o="none":(s.isLayerListPanel||(r=!0),o="link"),kb(i,o,r)}function w_(i,e,t,n){const s=Pb(i,e,t,n);return dh(i,s.dropEffect),s}function hh(i,e,t){const{forceCopy:n,newTarget:s,isLayerListPanel:r=!1}=t,o=Lb(e);if(!n&&o!==void 0){const l=!s&&o.manager===e&&(o.isLayerListPanel===r||o.isLayerListPanel),c=new Rb;return c.manager=e,c.numSourceLayers=o.layers.length,c.sourceManager=o.manager,c.targetIsLayerListPanel=r,c.sourceIsLayerListPanel=o.isLayerListPanel,c.moveSupported=l,c.layers=new Map,c.forceCopy=!1,c.layoutSpec=o.layoutSpec,l?o.layers.forEach((d,u)=>{c.layers.set(d,u)}):o.layers.forEach((d,u)=>{(s||!e.layerManager.has(d))&&c.layers.set(d.addRef(),u)}),c}const a=wl(i);if(a!==void 0)try{const l=(0,f.$v)(a.parameters,(d,u)=>{const h=(0,f.cQ)(d,"name",f.zr);let p=(0,f.cQ)(d,"visible",f.aO);const m=new Kc(h,e);return r&&(p=!1),m.visible=p,m.archived=r,[m,u]}),c=new Rb;return c.numSourceLayers=l.length,c.targetIsLayerListPanel=r,c.sourceIsLayerListPanel=!1,c.sourceManager=void 0,c.moveSupported=!1,c.forceCopy=o!==void 0,c.manager=e,c.dragType=a.dragType,c.layers=new Map(l),c}catch{}}function ph(i,e){return i.moveSupported?!1:(i.manager.layerManager.filter(t=>!i.layers.has(t)),e!==void 0&&i.layers.has(e))}function xl(i,e,t,n=!1){function s(r,o){let a=i.dropLayers;const{dropEffect:l,dropEffectMessage:c}=o?Pb(r,i.manager,n,!1):{dropEffect:uh(),dropEffectMessage:""};if(l===void 0)return;dh(r,l);let d=!0;if(!(a!==void 0&&!a.compatibleWithMethod(l)&&(i.dropLayers=void 0,ph(a,t)))){if(a===void 0){if(a=i.dropLayers=hh(r,i.manager,{forceCopy:l==="copy",newTarget:!1,isLayerListPanel:n}),a===void 0)return;d=a.method==="move"}if(t!==void 0&&a.layers.has(t))return{dropLayers:a,dropEffect:l,dropEffectMessage:c};if(d){const{layerManager:u}=i.manager,h=new Set;let p=Number.POSITIVE_INFINITY;const m=u.managedLayers=u.managedLayers.filter((v,y)=>a.layers.has(v)?(p===Number.POSITIVE_INFINITY&&(p=y),h.add(v),!1):!0);let g;t!==void 0?(g=m.indexOf(t),p<=g&&++g):g=m.length;for(const v of a.layers.keys())h.has(v)||a.layers.delete(v);m.splice(g,0,...a.layers.keys()),u.layersChanged.dispatch()}else{let u;t!==void 0&&(u=i.manager.layerManager.managedLayers.indexOf(t));for(const h of a.layers.keys())i.manager.add(h,u)}return{dropLayers:a,dropEffect:l,dropEffectMessage:c}}}e.addEventListener("dragenter",r=>{s(r,!0)!==void 0?r.preventDefault():kt(i.element,"drop")}),e.addEventListener("drop",r=>{r.preventDefault(),i.dragEnterCount=0,kt(i.element,"drop");const o=s(r,!1)?.dropLayers;if(i.dropLayers=void 0,o!==void 0){if(!o.initializeExternalLayers(r)){ph(o);return}o.updateArchiveStates(r),Cl(o.method==="move"?void 0:r.dataTransfer.dropEffect)}}),e.addEventListener("dragover",r=>{const o=s(r,!0);if(o===void 0){kt(i.element,"drop");return}const{dropLayers:a,dropEffect:l,dropEffectMessage:c}=o,d=a.layers.size;let u="";const h=a.numSourceLayers===1?"":"s",p=a.numSourceLayers;if(l==="none")u=`Cannot link dragged layer${h} here`;else{const m=p===d?`${p}`:`${d}/${p}`;u=`Drop to ${l} ${m} layer${h}`}c&&(u+=` (${c})`),Cn(i.element,"drop",u),r.preventDefault(),r.stopPropagation()})}function Ab(i,e,t,n){e.draggable=!0,e.addEventListener("dragstart",s=>{Cn(e,"drag","Drag layer to another layer bar/panel (including in another Neuroglancer window), or to the left/top/right/bottom edge of a layer group"),Ib(s,{manager:i.manager,layers:[t],layoutSpec:n.getLayoutSpec(),isLayerListPanel:n.isLayerListPanel}),s.stopPropagation()}),e.addEventListener("dragend",()=>{kt(e,"drag"),Cl()})}function Mb(i){i.element.addEventListener("dragenter",()=>{++i.dragEnterCount}),i.element.addEventListener("dragleave",()=>{if(--i.dragEnterCount!==0)return;kt(i.element,"drop");const{dropLayers:e}=i;e!==void 0&&(ph(e),i.manager.layerManager.layersChanged.dispatch(),i.dropLayers=void 0)})}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class x_ extends T.O8{constructor(e,t){super(),this.layer=e,this.panel=t,this.element=document.createElement("div"),this.layerNumberElement=document.createElement("div"),this.labelElement=document.createElement("div"),this.visibleProgress=document.createElement("div"),this.prefetchProgress=document.createElement("div"),this.labelElementText=document.createTextNode(""),this.valueElement=document.createElement("div"),this.maxLength=0,this.prevValueText="";const{element:n,labelElement:s,layerNumberElement:r,valueElement:o,visibleProgress:a,prefetchProgress:l,labelElementText:c}=this;n.className="neuroglancer-layer-item neuroglancer-noselect",n.appendChild(a),n.appendChild(l),s.className="neuroglancer-layer-item-label",s.appendChild(c),this.registerDisposer(e.readyStateChanged.add(()=>{if(console.log("layer is ready",e.isReady()),e.isReady()&&e.layer instanceof Ct){const g=e.layer.graphConnection,v=Ne({text:"\u{1F558}",title:"Share State"});v.addEventListener("click",w=>{if(w.stopPropagation(),g.value instanceof is){const{timestamp:b}=g.value.state;b.reset()}});let y;const S=()=>{if(y&&y(),g.value instanceof is){n.appendChild(v);const{timestamp:w}=g.value.state,b=()=>{v.style.display=w.value>0?"inherit":"none"};y=this.registerDisposer(w.changed.add(b)),b()}else n.contains(v)&&n.removeChild(v)};S(),this.registerDisposer(g.changed.add(S))}})),a.className="neuroglancer-layer-item-visible-progress",l.className="neuroglancer-layer-item-prefetch-progress",r.className="neuroglancer-layer-item-number",o.className="neuroglancer-layer-item-value";const d=document.createElement("div");d.className="neuroglancer-layer-item-value-container";const u=document.createElement("div");u.className="neuroglancer-layer-item-button-container";const h=No();h.title="Remove layer from this layer group",h.addEventListener("click",g=>{this.panel.layerManager===this.panel.manager.rootLayers?this.layer.setArchived(!0):this.layer.containers.size>2?this.panel.layerManager.removeManagedLayer(this.layer):this.layer.setArchived(!0),g.stopPropagation()});const p=Mn();p.title="Delete this layer",p.addEventListener("click",g=>{Ms(this.layer),g.stopPropagation()}),n.appendChild(r),d.appendChild(o),d.appendChild(u),u.appendChild(h),u.appendChild(p),n.appendChild(s),n.appendChild(d);const m=this.registerDisposer(new xs(e.localPosition,e.localCoordinateSpaceCombiner,{copyButton:!1,velocity:e.localVelocity,getToolBinder:()=>e.layer?.toolBinder}));n.appendChild(m.element),m.element.addEventListener("click",g=>{g.stopPropagation()}),m.element.addEventListener("dblclick",g=>{g.stopPropagation()}),n.addEventListener("click",g=>{g.ctrlKey?t.selectedLayer.toggle(e):g.altKey?e.pickEnabled=!e.pickEnabled:e.setVisible(!e.visible)}),n.addEventListener("contextmenu",g=>{t.selectedLayer.layer=e,t.selectedLayer.visible=!0,g.stopPropagation(),g.preventDefault()}),Ab(t,n,e,{getLayoutSpec:()=>t.getLayoutSpecForDrag()}),xl(this.panel,n,this.layer)}update(){const{layer:e,element:t}=this;this.labelElementText.textContent=e.name,t.dataset.visible=e.visible.toString(),t.dataset.selected=(e===this.panel.selectedLayer.layer).toString(),t.dataset.pick=e.pickEnabled.toString();let n=`Click to ${e.visible?"hide":"show"}, control+click to show side panel`;e.supportsPickOption&&(n+=`, alt+click to ${e.pickEnabled?"disable":"enable"} spatial object selection`),n+=", drag to move, shift+drag to copy",t.title=n}disposed(){this.element.remove(),super.disposed()}}class E_ extends T.O8{constructor(e,t,n){super(),this.layerGroupViewer=e,this.getLayoutSpecForDrag=t,this.showLayerHoverValues=n,this.layerWidgets=new Map,this.element=document.createElement("div"),this.layerUpdateNeeded=!0,this.valueUpdateNeeded=!1,this.layerWidgetInsertionPoint=document.createElement("div"),this.positionWidget=this.registerDisposer(new xs(this.viewerNavigationState.position.value,this.manager.root.coordinateSpaceCombiner,{velocity:this.viewerNavigationState.velocity.velocity,getToolBinder:()=>this.layerGroupViewer.toolBinder})),this.dragEnterCount=0,this.scheduleUpdate=this.registerCancellable((0,Qe.t)(()=>this.update()));const{element:s,manager:r,selectedLayer:o}=this;s.className="neuroglancer-layer-panel",this.registerDisposer(r.layerSelectedValues.changed.add(()=>{this.handleLayerValuesChanged()})),this.registerDisposer(r.layerManager.layersChanged.add(()=>{this.handleLayersChanged()})),this.registerDisposer(o.changed.add(()=>{this.handleLayersChanged()})),this.registerDisposer(n.changed.add(()=>{this.handleLayerItemValueChanged()})),this.element.dataset.showHoverValues=this.showLayerHoverValues.value.toString(),this.layerWidgetInsertionPoint.style.display="none",this.element.appendChild(this.layerWidgetInsertionPoint);const a=Ne({svg:Fa,title:"Click to add layer, control+click/right click/\u2318+click to add local annotation layer."});a.classList.add("neuroglancer-layer-add-button");const l=this.dropZone=document.createElement("div");l.className="neuroglancer-layer-panel-drop-zone";const c=u=>{if(u.ctrlKey||u.metaKey||u.type==="contextmenu"){const h=$g(this.manager,"annotation",{type:"annotation",source:"local://annotations"});this.manager.add(h),this.selectedLayer.layer=h,this.selectedLayer.visible=!0}else this.addLayerMenu()};this.registerEventListener(a,"click",c),this.registerEventListener(a,"contextmenu",c),s.appendChild(a),s.appendChild(l),this.registerDisposer(C_(a)),s.appendChild(this.positionWidget.element);const d=()=>{const u=this.viewerNavigationState.position.link.value;this.positionWidget.element.style.display=u===Ro.LINKED?"none":""};this.registerDisposer(this.viewerNavigationState.position.link.changed.add(d)),d(),this.update(),this.updateChunkStatistics(),Mb(this),xl(this,l,void 0),this.registerDisposer(this.display.updateStarted.add(()=>this.updateLayers())),this.registerDisposer(r.chunkManager.layerChunkStatisticsUpdated.add(this.registerCancellable((0,Qe.t)(()=>this.updateChunkStatistics()))))}get layerManager(){return this.manager.layerManager}get manager(){return this.layerGroupViewer.layerSpecification}get display(){return this.layerGroupViewer.display}get selectedLayer(){return this.layerGroupViewer.selectedLayer}get viewerNavigationState(){return this.layerGroupViewer.viewerNavigationState}disposed(){this.layerWidgets.forEach(e=>e.dispose()),this.layerWidgets=void 0,at(this.element),super.disposed()}handleLayersChanged(){this.layerUpdateNeeded=!0,this.handleLayerValuesChanged()}handleLayerValuesChanged(){this.valueUpdateNeeded||(this.valueUpdateNeeded=!0,this.scheduleUpdate())}handleLayerItemValueChanged(){this.element.dataset.showHoverValues=this.showLayerHoverValues.value.toString()}update(){if(this.valueUpdateNeeded=!1,this.updateLayers(),this.showLayerHoverValues.value===!1)return;const e=this.manager.layerSelectedValues;for(const[t,n]of this.layerWidgets){const s=t.layer;let r="";if(s!==null){const o=e.get(s);if(o!==void 0){const{value:a}=o;a!==void 0&&(r=""+a)}}if(r!==n.prevValueText){if(n.prevValueText=r,r.length>n.maxLength){const o=n.maxLength=r.length;n.valueElement.style.width=`${o}ch`}n.valueElement.textContent=r}}}updateChunkStatistics(){for(const[e,t]of this.layerWidgets){let n=0,s=0,r=0,o=0;const a=e.layer;if(a!==null)for(const{layerChunkProgressInfo:l}of a.renderLayers)n+=l.numVisibleChunksNeeded,s+=l.numVisibleChunksAvailable,r+=l.numPrefetchChunksNeeded,o+=l.numPrefetchChunksAvailable;t.visibleProgress.style.width=`${s/Math.max(1,n)*100}%`,t.prefetchProgress.style.width=`${o/Math.max(1,r)*100}%`}}updateLayers(){if(!this.layerUpdateNeeded)return;this.layerUpdateNeeded=!1;const e=this.element,t=new Set;let n=this.layerWidgetInsertionPoint.nextElementSibling;this.manager.rootLayers.updateNonArchivedLayerIndices();for(const s of this.manager.layerManager.managedLayers){if(s.archived&&!this.dropLayers?.layers.has(s))continue;t.add(s);let r=this.layerWidgets.get(s);const o=s.nonArchivedLayerIndex;r===void 0&&(r=new x_(s,this),this.layerWidgets.set(s,r)),r.layerNumberElement.textContent=""+(1+o),r.update();const{element:a}=r;a!==n&&e.insertBefore(r.element,n),n=a.nextElementSibling}for(const[s,r]of this.layerWidgets)t.has(s)||(this.layerWidgets.delete(s),r.dispose())}addLayerMenu(){Qg(this.manager,this.selectedLayer)}}/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function Nb(i,e){const t=(0,T.K6)(i,"drop",o=>{if(o.preventDefault(),o.dataTransfer.types.indexOf(Fo)!==-1){o.stopPropagation();const a=(0,f.Rf)(JSON.parse(o.dataTransfer.getData(Fo))),l=(0,f.cQ)(a,"dimensions",Yl),c=(0,f.cQ)(a,"position",p=>(0,f.$v)(p,f.zo));if(c.length!==l.length)throw new Error("length mismatch between position and dimensions");const d=c.length,{coordinateSpace:{value:{names:u}},value:h}=e;for(let p=0;p{o.dataTransfer.types.indexOf(Fo)!==-1&&(o.dataTransfer.dropEffect="link",o.preventDefault(),o.stopPropagation())},s=(0,T.K6)(i,"dragenter",n),r=(0,T.K6)(i,"dragover",n);return()=>{s(),r(),t()}}/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const fh="neuroglancer-layer-group-viewer";function Ob(i){return i.dataTransfer.types.indexOf(fh)!==-1}let _n;function T_(i){if(_n&&_n.viewer.layerSpecification.rootLayers===i.rootLayers)return _n.viewer}function D_(i,e){const t=T_(e);let n,s=!1;return t===void 0||t.layerSpecification===t.layerSpecification.root?n="copy":(s=!0,n="move"),kb(i,n,s)}class I_ extends T.O8{constructor(e){super(),this.relativeDisplayScales=new Kw(e.navigationState.pose.relativeDisplayScales.addRef()),this.displayDimensions=new Xw(e.navigationState.pose.displayDimensions.addRef()),this.position=new Yp(e.navigationState.position.addRef()),this.velocity=this.registerDisposer(new Yw(e.velocity,this.position.link)),this.crossSectionOrientation=new vc(e.navigationState.pose.orientation.addRef()),this.displayDimensionRenderInfo=this.registerDisposer(new Zp(this.relativeDisplayScales.value,this.displayDimensions.value)),this.crossSectionScale=new yc(e.navigationState.zoomFactor.addRef(),this.displayDimensionRenderInfo.addRef()),this.crossSectionDepthRange=new nf(e.navigationState.depthRange.addRef(),this.displayDimensionRenderInfo),this.projectionDepthRange=new nf(e.perspectiveNavigationState.depthRange.addRef(),this.displayDimensionRenderInfo),this.navigationState=this.registerDisposer(new ws(new Cs(this.position.value,this.displayDimensionRenderInfo.addRef(),this.crossSectionOrientation.value),this.crossSectionScale.value,this.crossSectionDepthRange.value)),this.projectionOrientation=new vc(e.perspectiveNavigationState.pose.orientation.addRef()),this.projectionScale=new yc(e.perspectiveNavigationState.zoomFactor.addRef(),this.displayDimensionRenderInfo.addRef()),this.projectionNavigationState=this.registerDisposer(new ws(new Cs(this.position.value.addRef(),this.displayDimensionRenderInfo.addRef(),this.projectionOrientation.value),this.projectionScale.value,this.projectionDepthRange.value))}copyToParent(){for(const e of[this.relativeDisplayScales,this.displayDimensions,this.position,this.velocity,this.crossSectionOrientation,this.crossSectionScale,this.projectionOrientation,this.projectionScale])e.copyToPeer()}register(e){e.add("dimensionRenderScales",this.relativeDisplayScales),e.add("displayDimensions",this.displayDimensions),e.add("position",vr(this.position)),e.add("velocity",this.velocity),e.add("crossSectionOrientation",this.crossSectionOrientation),e.add("crossSectionScale",this.crossSectionScale),e.add("crossSectionDepth",this.crossSectionDepthRange),e.add("projectionOrientation",this.projectionOrientation),e.add("projectionScale",this.projectionScale),e.add("projectionDepth",this.projectionDepthRange)}}function L_(i,e){const t=new m_(i),n=t.element;n.classList.add("neuroglancer-layer-group-viewer-context-menu");const s=document.createElement("button");s.textContent="Remove layer group",n.appendChild(s),t.registerEventListener(s,"click",()=>{e.layerSpecification.layerManager.clear()});const{viewerNavigationState:r}=e;for(const[o,a]of[["Render scale factors",r.relativeDisplayScales.link],["Render dimensions",r.displayDimensions.link],["Position",r.position.link],["Cross-section orientation",r.crossSectionOrientation.link],["Cross-section zoom",r.crossSectionScale.link],["Cross-section depth range",r.crossSectionDepthRange.link],["3-D projection orientation",r.projectionOrientation.link],["3-D projection zoom",r.projectionScale.link],["3-D projection depth range",r.projectionDepthRange.link]]){const l=t.registerDisposer(new Bo(a)),c=document.createElement("label");c.style.display="flex",c.style.flexDirection="row",c.style.whiteSpace="nowrap",c.textContent=o,c.appendChild(l.element),n.appendChild(c)}return t}class ro extends T.O8{constructor(e,t,n={}){super(),this.element=e,this.viewerState=t,this.state=new fr,this.options={showLayerPanel:new nt(!0),showViewerMenu:!1,showLayerHoverValues:new nt(!0),...n},this.layerSpecification=this.registerDisposer(t.layerSpecification),this.toolBinder=this.registerDisposer(new Dc(this,this.layerSpecification.root.toolBinder)),this.viewerNavigationState=this.registerDisposer(new I_(t)),this.viewerNavigationState.register(this.state),this.registerDisposer((0,_.no)((s,r)=>{r===Ro.UNLINKED&&s.registerDisposer(new mc(this.layerSpecification.root.display,this.viewerNavigationState.position.value,this.viewerNavigationState.velocity.velocity))},this.viewerNavigationState.position.link)),this.layerSpecification instanceof zg?this.state.add("layers",this.layerSpecification):this.state.add("layers",{changed:this.layerSpecification.changed,toJSON:()=>this.layerSpecification.layerManager.managedLayers.map(s=>s.name),reset:()=>{throw new Error("not implemented")},restoreState:()=>{throw new Error("not implemented")}}),e.classList.add("neuroglancer-layer-group-viewer"),this.registerDisposer(new za(e)),this.layout=this.registerDisposer(new a_(this,"xy")),this.state.add("layout",this.layout),this.state.add("toolBindings",this.toolBinder),this.registerActionBindings(),this.registerDisposer(this.layerManager.useDirectly()),this.registerDisposer(Nb(e,this.navigationState.position)),this.registerDisposer(this.options.showLayerPanel.changed.add(this.registerCancellable((0,Fe.A)(()=>this.updateUI(),0)))),this.makeUI()}get perspectiveNavigationState(){return this.viewerNavigationState.projectionNavigationState}get navigationState(){return this.viewerNavigationState.navigationState}get selectionDetailsState(){return this.layerSpecification.root.selectionState}get display(){return this.viewerState.display}get selectedLayer(){return this.viewerState.selectedLayer}get layerManager(){return this.layerSpecification.layerManager}get chunkManager(){return this.layerSpecification.chunkManager}get mouseState(){return this.viewerState.mouseState}get showAxisLines(){return this.viewerState.showAxisLines}get wireFrame(){return this.viewerState.wireFrame}get enableAdaptiveDownsampling(){return this.viewerState.enableAdaptiveDownsampling}get showScaleBar(){return this.viewerState.showScaleBar}get showPerspectiveSliceViews(){return this.viewerState.showPerspectiveSliceViews}get inputEventBindings(){return this.viewerState.inputEventBindings}get visibility(){return this.viewerState.visibility}get visibleLayerRoles(){return this.viewerState.visibleLayerRoles}get crossSectionBackgroundColor(){return this.viewerState.crossSectionBackgroundColor}get perspectiveViewBackgroundColor(){return this.viewerState.perspectiveViewBackgroundColor}get scaleBarOptions(){return this.viewerState.scaleBarOptions}get changed(){return this.state.changed}bindAction(e,t){this.registerDisposer(Z(this.element,e,t))}registerActionBindings(){this.bindAction("add-layer",()=>{this.layerPanel&&this.layerPanel.addLayerMenu()}),this.bindAction("t-",()=>{this.navigationState.pose.translateNonDisplayDimension(0,-1)}),this.bindAction("t+",()=>{this.navigationState.pose.translateNonDisplayDimension(0,1)})}toJSON(){return{type:"viewer",...this.state.toJSON()}}reset(){this.state.reset()}restoreState(e){this.state.restoreState(e),Mt(e,"crossSectionZoom",vr(this.viewerNavigationState.crossSectionScale)),Mt(e,"perspectiveZoom",vr(this.viewerNavigationState.projectionScale)),Mt(e,"perspectiveOrientation",this.viewerNavigationState.projectionOrientation)}makeUI(){this.element.style.flex="1",this.element.style.display="flex",this.element.style.flexDirection="column",this.element.appendChild(this.layout.element),this.updateUI()}updateUI(){const{options:e}=this,t=e.showLayerPanel.value;if(this.layerPanel!==void 0&&!t){this.layerPanel.dispose(),this.layerPanel=void 0;return}if(t&&this.layerPanel===void 0){const n=this.layerPanel=new E_(this,()=>this.layout.toJSON(),this.options.showLayerHoverValues);if(e.showViewerMenu?(n.registerDisposer(L_(n.element,this)),n.element.title="Right click for options, drag to move/copy layer group."):n.element.title="Drag to move/copy layer group.",typeof NEUROGLANCER_SHOW_LAYER_BAR_EXTRA_BUTTONS<"u"&&NEUROGLANCER_SHOW_LAYER_BAR_EXTRA_BUTTONS===!0){{const r=document.createElement("button");r.textContent="Clear segments",r.title='De-select all objects ("x")',r.addEventListener("click",o=>{af(o,o,{action:"clear-segments"})}),n.element.appendChild(r)}for(const r of["3d","xy","xz","yz"]){const o=document.createElement("button");o.textContent=r,o.title=`Switch to ${r} layout`,o.addEventListener("click",()=>{let a;this.layout.name===r?r!=="3d"?a=`${r}-3d`:a="4panel":a=r,this.layout.name=a}),n.element.appendChild(o)}}n.element.draggable=!0;const s=n.element;s.addEventListener("dragstart",r=>{Cn(n.element,"drag","Drag layer group to the left/top/right/bottom edge of a layer group, or to another layer bar/panel (including in another Neuroglancer window)"),Ib(r,{manager:this.layerSpecification,layers:this.layerManager.managedLayers,layoutSpec:this.layout.toJSON()});const o=()=>{_n&&_n.viewer===this&&(_n=void 0),this.unregisterDisposer(o)};_n={viewer:this,disposer:o},this.registerDisposer(o);const a=this.toJSON();a.layers=void 0,r.dataTransfer.setData(fh,JSON.stringify(a)),n.element.style.backgroundColor="black",setTimeout(()=>{n.element.style.backgroundColor=""},0)}),n.element.addEventListener("dragend",()=>{kt(s,"drag"),Cl(),_n!==void 0&&_n.viewer===this&&_n.disposer()}),this.element.insertBefore(s,this.element.firstChild)}}disposed(){Me(this.element);const{layerPanel:e}=this;e!==void 0&&(e.dispose(),this.layerPanel=void 0),super.disposed()}}/** + * @license + * Copyright 2017 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const _b=Symbol("layoutComponentContainer");class tr extends T.O8{constructor(e,t,n){super(),this.viewer=e,this.parent=n,this.changed=new j.IY,this.flex=new _.DN(1,f.Mo),this.element=document.createElement("div");const{element:s}=this;s.style.display="flex",s.style.flex="1",s.style.position="relative",s.style.alignItems="stretch",s[_b]=this,this.flex.changed.add(()=>{s.style.flexGrow=""+this.flex.value,this.changed.dispatch()}),this.setSpecification(t);const r=[],o=l=>{const c=document.createElement("div");c.className="neuroglancer-layout-split-drop-zone";let d;switch(c.style[l]="0",l){case"left":case"right":d="row",c.style.width="10px",c.style.height="100%";break;case"top":case"bottom":d="column",c.style.height="10px",c.style.width="100%";break}c.style.display="none",r.push({element:c,direction:d,orientation:l}),s.appendChild(c),Bb(c,this.viewer.layerSpecification,()=>this.split(l).newContainer.component,d==="row"?"column":"row")};o("left"),o("right"),o("top"),o("bottom");let a=!1;s.addEventListener("dragenter",l=>{if(!a&&wl(l)!==void 0){a=!0;for(const{element:c,direction:d,orientation:u}of r){if(n!==void 0&&d===n.direction&&((u==="left"||u==="top")&&n.get(0)!==this||(u==="bottom"||u==="right")&&n.get(n.length-1)!==this))continue;const{component:h}=this;h instanceof El&&h.direction===d||(c.style.display="block")}}},!0),s.addEventListener("drop",l=>{if(a){a=!1;for(const{element:c}of r)c.style.display="none"}},!0),s.addEventListener("dragleave",l=>{const{relatedTarget:c}=l;if(a&&!(c instanceof HTMLElement&&this.element.contains(c))){a=!1;for(const{element:d}of r)d.style.display="none"}},!0)}unsetComponent(){const e=this.componentValue;e!==void 0&&(e.changed.remove(this.changed.dispatch),this.element.removeChild(e.element),e.dispose())}get component(){return this.componentValue}setComponent(e){if(this.unsetComponent(),this.componentValue=e,e.changed.add(this.changed.dispatch),this.element.appendChild(e.element),e instanceof ro){const{layerManager:t}=e,n=e.registerCancellable((0,Fe.A)(()=>{t.managedLayers.length===0&&this.dispose()},0));e.registerDisposer(t.layersChanged.add(()=>{t.managedLayers.length===0&&n()})),n()}else if(e instanceof El){const t=e.registerCancellable((0,Fe.A)(()=>{const{length:n}=e;if(n===0&&this.parent!==void 0)this.dispose();else if(n===1){const s=e.get(0).component;let r;if(this.parent===void 0&&s instanceof ro){r=s.layout.specification.toJSON(),s.viewerNavigationState.copyToParent();const o=s.layerManager.managedLayers,a=new Set(o),{layerSpecification:l}=s;l.rootLayers.filter(u=>a.has(u)||u.archived);const c=[],{managedLayers:d}=l.rootLayers;for(let u=0,h=d.length;u{e.length<2&&t()})),t()}this.changed.dispatch()}toJSON(){const e=this.component.toJSON();return this.parent instanceof El&&(e.flex=this.flex.toJSON()),e}setSpecification(e){this.setComponent(R_(this,e)),this.flex.value=(0,f.MM)(e,"flex",f.Mo,1)}static getFromElement(e){return e[_b]}disposed(){this.unsetComponent(),this.componentValue=void 0,super.disposed()}split(e){const t={type:"viewer"},{parent:n}=this;if(n!==void 0){if(e==="left"&&n.direction==="row"||e==="top"&&n.direction==="column")return{newContainer:n.insertChild(t,this),existingContainer:this};if(e==="right"&&n.direction==="row"||e==="bottom"&&n.direction==="column")return{newContainer:n.insertChild(t),existingContainer:this}}let s;const r=this.component;r instanceof gh?s=r.layerGroupViewer.toJSON():s=r.toJSON();let o,a;const l=e==="left"||e==="right"?"row":"column";switch(e){case"left":case"top":o={type:l,children:[t,s]},a=0;break;case"right":case"bottom":o={type:l,children:[s,t]},a=1;break}this.setSpecification(o);const c=this.component;return{newContainer:c.get(a),existingContainer:c.get(1-a)}}}function Vb(i){return{mouseState:i.mouseState,showAxisLines:i.showAxisLines,wireFrame:i.wireFrame,enableAdaptiveDownsampling:i.enableAdaptiveDownsampling,showScaleBar:i.showScaleBar,scaleBarOptions:i.scaleBarOptions,showPerspectiveSliceViews:i.showPerspectiveSliceViews,inputEventBindings:i.inputEventBindings,visibility:i.visibility,selectedLayer:i.selectedLayer,visibleLayerRoles:i.visibleLayerRoles,navigationState:i.navigationState.addRef(),perspectiveNavigationState:i.perspectiveNavigationState.addRef(),velocity:i.velocity.addRef(),crossSectionBackgroundColor:i.crossSectionBackgroundColor,perspectiveViewBackgroundColor:i.perspectiveViewBackgroundColor}}class gh extends T.O8{constructor(e,t,n){super(),this.element=e,this.layerGroupViewer=this.registerDisposer(new ro(e,{display:n.display,layerSpecification:n.layerSpecification.addRef(),...Vb(n)},{showLayerPanel:n.uiControlVisibility.showLayerPanel,showViewerMenu:!1,showLayerHoverValues:n.uiControlVisibility.showLayerHoverValues})),this.layerGroupViewer.layout.restoreState(t)}toJSON(){return this.layerGroupViewer.layout.specification.toJSON()}get changed(){return this.layerGroupViewer.layout.changed}}function Bb(i,e,t,n){i.addEventListener("dragenter",s=>{wl(s)!==void 0&&i.classList.add("neuroglancer-drag-over")}),i.addEventListener("dragleave",()=>{kt(i,"drop"),i.classList.remove("neuroglancer-drag-over")}),i.addEventListener("dragover",s=>{const r=(o,a)=>{o.dropEffectMessage&&(a+=` (${o.dropEffectMessage})`),Cn(i,"drop",a),s.stopPropagation(),s.preventDefault()};if(Ob(s)){const o=D_(s,e);dh(s,o.dropEffect),r(o,`Drop to ${o.dropEffect} layer group as new ${n}`);return}if(wl(s)!==void 0){const o=w_(s,e,!1,!0);r(o,`Drop to ${o.dropEffect} layer as new ${n}`);return}}),i.addEventListener("drop",s=>{i.classList.remove("neuroglancer-drag-over"),kt(i,"drop");let r,o;if(Ob(s)){s.stopPropagation();try{o=JSON.parse(s.dataTransfer.getData(fh))}catch{return}if(r=hh(s,e,{forceCopy:!1,newTarget:!0}),r===void 0)return}else{if(r=hh(s,e,{forceCopy:uh()==="copy",newTarget:!0}),r===void 0)return;o=r.layoutSpec}if(!r.initializeExternalLayers(s)){if(!r.moveSupported)for(const c of r.layers.keys())c.dispose();return}s.preventDefault();const a=s.dataTransfer.dropEffect=uh();Cl(a);const l=t();r.updateArchiveStates(s);for(const c of r.layers.keys())l.layerSpecification.add(c);try{l.restoreState(o)}catch{l.layout.reset()}})}class El extends T.O8{constructor(e,t,n,s){super(),this.element=e,this.direction=t,this.container=s,this.changed=new j.IY,e.classList.add("neuroglancer-stack-layout"),e.classList.add(`neuroglancer-stack-layout-${t}`),e.style.display="flex",e.style.flexDirection=t,e.appendChild(this.makeDropPlaceholder(this));for(const r of n)this.insertChild(r)}get length(){return(this.element.childElementCount-1)/2}makeDropPlaceholder(e){const t=document.createElement("div");return t.className="neuroglancer-stack-layout-drop-placeholder",Bb(t,this.viewer.layerSpecification,()=>{const n=t.nextElementSibling;let s;return n!==null&&(s=tr.getFromElement(n)),this.insertChild({type:"viewer",layers:[]},s).component},this.direction==="row"?"column":"row"),e.registerDisposer(()=>{at(t)}),t.addEventListener("pointerdown",n=>{if("button"in n&&n.button!==0)return;const s=t.nextElementSibling;if(s===null)return;const r=tr.getFromElement(s),o=t.previousElementSibling;if(o===null)return;const a=tr.getFromElement(o);n.preventDefault();const l=()=>{Cn(t,"drag",`Drag to resize, current ${Ji[this.direction]} ratio is ${a.flex.value} : ${r.flex.value}`)};l(),zt(n,c=>{const d=a.element.getBoundingClientRect(),u=r.element.getBoundingClientRect(),h=Math.max(.1,Math.min(.9,this.direction==="column"?(c.clientY-d.top)/(u.bottom-d.top):(c.clientX-d.left)/(u.right-d.left))),p=Number(a.flex.value)+Number(r.flex.value);a.flex.value=Math.round(h*p*100)/100,r.flex.value=Math.round((1-h)*p*100)/100,l()},()=>{kt(t,"drag")})}),t}get viewer(){return this.container.viewer}get(e){return tr.getFromElement(this.element.children[e*2+1])}insertChild(e,t){const n=new tr(this.viewer,e,this),s=this.makeDropPlaceholder(n);n.element.classList.add("neuroglancer-stack-layout-child"),n.registerDisposer(n.changed.add(this.changed.dispatch)),n.registerDisposer(()=>{this.element.removeChild(n.element),this.changed.dispatch()});const r=t!==void 0?t.element:null;return this.element.insertBefore(n.element,r),this.element.insertBefore(s,r),this.changed.dispatch(),n}disposed(){this.clear(),super.disposed()}clear(){for(;this.length!==0;)this.get(0).dispose()}*[Symbol.iterator](){const{length:e}=this;for(let t=0;te.toJSON())}}}function R_(i,e){const t=document.createElement("div");if(t.style.flex="1",t.style.width="0px",typeof e=="string"){if(i.parent!==void 0)throw new Error(`Invalid layout component specification: ${JSON.stringify(e)}`);return new gh(t,e,i.viewer)}(0,f.Rf)(e);const n=(0,f.cQ)(e,"type",f.zr);switch(n){case"row":case"column":return new El(t,n,(0,f.cQ)(e,"children",s=>{const r=(0,f.$v)(s,o=>o);if(i.parent===void 0&&r.length===0)throw new Error("Stack layout requires at least one child.");return r}),i);case"viewer":{const s=i.viewer,r=new zg(s.layerSpecification.addRef()),o=new ro(t,{display:s.display,layerSpecification:r,...Vb(s)},{showLayerPanel:s.uiControlVisibility.showLayerPanel,showViewerMenu:!0,showLayerHoverValues:s.uiControlVisibility.showLayerHoverValues});try{o.restoreState(e)}catch(a){throw o.dispose(),a}return o}default:return new gh(t,e,i.viewer)}}class k_ extends T.O8{constructor(e,t){super(),this.viewer=e,this.defaultSpecification=t,this.container=this.registerDisposer(new tr(this.viewer,this.defaultSpecification,void 0))}get changed(){return this.container.changed}get element(){return this.container.element}reset(){this.container.setSpecification(this.defaultSpecification)}restoreState(e){this.container.setSpecification(e)}disposed(){super.disposed()}toJSON(){return this.container.toJSON()}}var P_=G(1152),A_=G(5093);/** + * @license + * Copyright 2018 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const M_=Ae.fromObject({escape:{action:"cancel"}});class Fb extends T.O8{constructor(e){super(),this.layer=e,this.element=document.createElement("input");const{element:t}=this;t.classList.add("neuroglancer-layer-side-panel-name"),t.spellcheck=!1,t.autocomplete="off";const n=this.registerDisposer(new yn(t,M_));n.allShortcutsAreGlobal=!0,Z(t,"cancel",s=>{this.updateView(),t.blur(),s.stopPropagation(),s.preventDefault()}),t.title="Rename layer",this.registerDisposer(e.layerChanged.add(()=>this.updateView())),t.addEventListener("change",()=>this.updateModel()),t.addEventListener("blur",()=>this.updateModel()),this.updateView()}updateView(){this.element.value=this.layer.name}updateModel(){Jg(this.layer,this.element.value)}}class N_ extends T.O8{constructor(e){super(),this.layer=e,this.element=document.createElement("select"),this.measureElement=document.createElement("div");const{element:t,measureElement:n}=this;t.classList.add("neuroglancer-layer-side-panel-type"),n.classList.add("neuroglancer-layer-side-panel-type-measure"),t.title="Change layer type",document.body.appendChild(n);for(const[s,r]of Mr){if(r.type!==s)continue;const o=document.createElement("option");o.textContent=r.typeAbbreviation,o.value=s,t.appendChild(o)}t.addEventListener("change",()=>{const s=t.value,r=Mr.get(s);Zc(this.layer.managedLayer,r)}),this.updateView()}updateView(){const e=this.layer.type,{element:t,measureElement:n}=this;n.textContent=this.layer.constructor.typeAbbreviation,t.value=e,t.style.width=`${n.offsetWidth}px`}disposed(){this.measureElement.remove()}}class Tl extends ji{constructor(e,t){super(e,t.location),this.panelState=t;const n=this.layer=t.layer,{element:s}=this,{titleBar:r}=this.addTitleBar({});r.classList.add("neuroglancer-layer-side-panel-title"),r.appendChild(this.registerDisposer(new N_(n)).element),r.appendChild(this.registerDisposer(new Fb(n.managedLayer)).element),this.registerDisposer((0,_.W1)(l=>{s.dataset.neuroglancerLayerVisible=l.toString()},{get value(){return n.managedLayer.visible},changed:n.managedLayer.layerChanged}));const o=this.registerDisposer(new rn({get value(){return n.managedLayer.pickEnabled},set value(l){n.managedLayer.pickEnabled=l},changed:n.managedLayer.layerChanged},{svg:A_,enableTitle:"Spatial object selection: disabled",disableTitle:"Spatial object selection: enabled"}));this.registerDisposer(new en({get value(){return n.managedLayer.supportsPickOption},changed:n.managedLayer.layerChanged},o.element)),r.appendChild(o.element);const a={get value(){return t!==n.panels.panels[0]},set value(l){l?t.pin():t.unpin()},changed:n.manager.root.layerManager.layersChanged};r.appendChild(this.registerDisposer(new rn(a,{text:"\u{1F4CC}\uFE0E",enableTitle:"Pin panel to this layer",disableTitle:"Unpin panel to this layer"})).element),this.registerDisposer((0,_.W1)(l=>{s.dataset.neuroglancerLayerPanelPinned=l.toString()},a)),r.appendChild(Mn({title:"Delete layer",onClick:()=>{Ms(this.layer.managedLayer)}})),this.tabView=new gx({makeTab:l=>n.tabs.options.get(l).getter(),selectedTab:t.selectedTab,tabs:this.registerDisposer(new _.pz({get value(){return t.tabs.map(l=>{const{label:c,hidden:d}=n.tabs.options.get(l);return{id:l,label:c,hidden:d?.value||!1}})},changed:t.tabsChanged})),handleTabElement:(l,c)=>{c.draggable=!0,c.addEventListener("dragstart",d=>{d.stopPropagation(),d.dataTransfer.setData("neuroglancer-side-panel","");let u="Drag tab to dock as new panel to the left/right/top/bottom of another panel";t.panels.panels.find(p=>p!==t&&p.location.visible)&&(u+=`, or move tab to other ${JSON.stringify(n.managedLayer.name)} panel`),Cn(c,"drag",u),this.sidePanelManager.startDrag({dropAsNewPanel:p=>{this.panelState.splitOffTab(l,{...Tg,...p})},canDropAsTabs:p=>p instanceof Tl&&p.layer===this.layer&&p!==this?1:0,dropAsTab:p=>{this.panelState.moveTabTo(l,p.panelState)}},d)}),c.addEventListener("dragend",d=>{kt(c,"drag"),this.sidePanelManager.endDrag()})}},this.visibility),this.tabView.element.style.flex="1",this.tabView.element.classList.add("neuroglancer-layer-side-panel-tab-view"),this.tabView.element.style.position="relative",this.tabView.element.appendChild(this.makeTabDropZone()),this.addBody(this.tabView.element),this.registerDisposer(t.tabsChanged.add(()=>{t.tabs.length===0&&(this.location.visible=!1)}))}makeDragSource(){return{...super.makeDragSource(),canDropAsTabs:e=>e instanceof Tl&&e.layer===this.layer&&e!==this?this.panelState.tabs.length:0,dropAsTab:e=>{this.panelState.mergeInto(e.panelState)}}}makeTabDropZone(){const e=document.createElement("div");return e.className="neuroglancer-side-panel-drop-zone",e.style.position="absolute",e.style.left="20px",e.style.right="20px",e.style.bottom="20px",e.style.top="20px",e.addEventListener("dragenter",t=>{const{dragSource:n}=this.sidePanelManager,s=n?.canDropAsTabs?.(this);s&&(e.classList.add(_s),Cn(e,"drop",`Move ${s} ${s===1?"tab":"tabs"} to this panel`),t.preventDefault())}),e.addEventListener("dragleave",()=>{kt(e,"drop"),e.classList.remove(_s)}),e.addEventListener("dragover",t=>{const{dragSource:n}=this.sidePanelManager;n?.canDropAsTabs?.(this)&&t.preventDefault()}),e.addEventListener("drop",t=>{kt(e,"drop");const{dragSource:n}=this.sidePanelManager;n?.canDropAsTabs?.(this)&&(e.classList.remove(_s),n.dropAsTab(this),t.preventDefault(),t.stopPropagation())}),e}}class O_ extends T.O8{constructor(e,t){super(),this.sidePanelManager=e,this.selectedLayerState=t,this.layerSidePanels=new Map,this.generation=0,this.layersNeedUpdate=!0;const n=()=>{this.layersNeedUpdate=!0,this.sidePanelManager.display.scheduleRedraw()};this.registerDisposer(t.changed.add(n)),this.registerDisposer(t.layerManager.layersChanged.add(n)),this.registerDisposer(e.beforeRender.add(()=>this.update()))}getSelectedUserLayer(){return this.selectedLayerState.layer?.layer??void 0}update(){if(!this.layersNeedUpdate)return;const{layerManager:e}=this.selectedLayerState,t=++this.generation;this.layersNeedUpdate=!1;const{layerSidePanels:n}=this,s=r=>{let o=n.get(r);o===void 0?(o={generation:t,unregister:this.sidePanelManager.registerPanel({location:r.location,makePanel:()=>new Tl(this.sidePanelManager,r)})},n.set(r,o)):o.generation=t};{const r=this.getSelectedUserLayer(),{location:o}=this.selectedLayerState;if(r===void 0||!o.visible)this.placeholderSelectedLayerPanel===void 0&&(this.placeholderSelectedLayerPanel=this.sidePanelManager.registerPanel({location:o,makePanel:()=>new ji(this.sidePanelManager,o)}));else{this.placeholderSelectedLayerPanel?.(),this.placeholderSelectedLayerPanel=void 0;const a=r.panels.panels[0];a.location.value=o.value,s(a)}}for(const r of e.managedLayers){const o=r.layer;if(o===null)continue;const{panels:a}=o.panels;for(let l=1,c=a.length;l{this.layer.setVisible(!1)}}),s=Ne({svg:_m,title:"Show layer",onClick:()=>{this.layer.setVisible(!0)}});t.appendChild(s),t.appendChild(n);const r=()=>{const o=this.layer.visible;n.style.display=o?"":"none",s.style.display=o?"none":""};r(),this.registerDisposer(e.layerChanged.add(r))}}function F_(i){const{selectedLayer:e}=i.manager.root,t=new rn({get value(){return e.layer===i&&e.visible},set value(n){n?(e.layer=i,e.visible=!0):e.visible=!1},changed:e.changed},{backgroundScheme:"dark",enableTitle:"Show layer side panel",disableTitle:"Hide layer side panel",svg:rb});return t.element.classList.add("neuroglancer-layer-list-panel-item-controls"),t}class U_ extends T.O8{constructor(e,t){super(),this.panel=e,this.layer=t,this.element=document.createElement("div"),this.numberElement=document.createElement("div"),this.generation=-1;const{element:n,numberElement:s}=this;n.classList.add("neuroglancer-layer-list-panel-item"),s.classList.add("neuroglancer-layer-list-panel-item-number"),n.appendChild(this.registerDisposer(new pn({get value(){return!t.archived},set value(o){t.setArchived(!o)},changed:t.layerChanged},{enableTitle:"Archive layer (disable and remove from layer groups)",disableTitle:"Unarchive layer (enable and add to all layer groups)"})).element),n.appendChild(s),n.appendChild(this.registerDisposer(new B_(t)).element),n.appendChild(this.registerDisposer(new Fb(t)).element),n.appendChild(this.registerDisposer(F_(t)).element);const r=Mn({title:"Delete layer",onClick:()=>{Ms(this.layer)}});r.classList.add("neuroglancer-layer-list-panel-item-delete"),n.appendChild(r),Ab(e,n,t,{isLayerListPanel:!0,getLayoutSpec:()=>{}}),xl(e,n,t,!0),n.addEventListener("click",o=>{o.ctrlKey?(e.selectedLayer.toggle(t),o.preventDefault()):o.altKey&&(t.pickEnabled=!t.pickEnabled,o.preventDefault())}),n.addEventListener("contextmenu",o=>{e.selectedLayer.toggle(t),o.stopPropagation(),o.preventDefault()})}}class $_ extends ji{constructor(e,t,n){super(e,n.location),this.manager=t,this.state=n,this.items=new Map,this.itemContainer=document.createElement("div"),this.layerDropZone=document.createElement("div"),this.dragEnterCount=0,this.generation=-1;const{itemContainer:s,layerDropZone:r}=this,{titleElement:o}=this.addTitleBar({title:""});this.titleElement=o,s.classList.add("neuroglancer-layer-list-panel-items"),this.addBody(s),r.style.flex="1";const a=this.registerCancellable((0,Qe.t)(()=>this.render()));this.visibility.changed.add(a),this.registerDisposer(this.layerManager.layersChanged.add(a)),this.registerDisposer(this.selectedLayer.changed.add(a)),Mb(this),xl(this,r,void 0,!0),this.render()}get layerManager(){return this.manager.layerManager}get selectedLayer(){return this.manager.selectedLayer}render(){const e=this,t=this.selectedLayer.layer,n=++this.generation;let s=0,r=0,o=0;this.layerManager.updateNonArchivedLayerIndices();function*a(){const{items:c}=e;let d=0;for(const h of e.layerManager.managedLayers)h.archived||++d;const u=`${(d+1).toString().length}ch`;for(const h of e.layerManager.managedLayers){h.visible?++s:h.archived?++o:++r;let p=c.get(h);p===void 0&&(p=e.registerDisposer(new U_(e,h)),c.set(h,p)),p.generation=n;const{nonArchivedLayerIndex:m}=h;p.numberElement.style.width=u,m===-1?p.numberElement.style.visibility="hidden":(p.numberElement.style.visibility="",p.numberElement.textContent=`${m+1}`),p.element.dataset.selected=(h===t).toString(),p.element.dataset.archived=h.archived.toString(),yield p.element}for(const[h,p]of c)n!==p.generation&&(c.delete(h),e.unregisterDisposer(p),p.dispose());yield e.layerDropZone}nn(this.itemContainer,a());let l="Layers";if(s||r||o){l+=" (";let c="";s+r&&(l+=`${s}/${r+s} visible`,c=", "),o&&(l+=`${c}${o} archived`),l+=")"}this.titleElement.textContent=l}}class G_ extends T.O8{constructor(e){super(),this.layerManager=e,this.element=document.createElement("div");const t=this.registerCancellable((0,Qe.t)(()=>this.render()));this.registerDisposer(e.layersChanged.add(t)),this.render()}render(){let e=0;const{managedLayers:t}=this.layerManager;for(const s of t)s.archived&&++e;const{element:n}=this;if(e!==0){const s=t.length;n.textContent=`${s-e}/${s}`}else n.textContent=""}}var D2=G(6792),I2=G(8948),L2=G(1274),R2=G(795);/** + * @license + * Copyright 2018 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const z_=100;class W_ extends Jr{constructor(e){super(),this.viewer=e,this.parsedValue=null,this.debouncedValueUpdater=(0,Fe.A)(()=>{const r=this.textEditor.getValue();try{const o=JSON.parse(r);this.parsedValue=o,this.applyButton.disabled=!1,this.textEditor.setOption("lint",void 0)}catch(o){this.parsedValue=null,this.applyButton.disabled=!0;let a=0,l=0,c="Unknown parse error";if(o instanceof Error){const d=o.message.match(/^((?:.|\n)*) in JSON at position ([0-9]+)$/);if(d!==null){c=d[1];const u=parseInt(d[2],10),p=r.substring(0,u).split(` +`);a=p.length-1,l=p[p.length-1].length}else c=o.message}this.textEditor.setOption("lint",{getAnnotations:()=>[{message:c,severity:"error",from:Ti().Pos(a,l)}]})}},z_),this.content.classList.add("neuroglancer-state-editor");const t=this.applyButton=document.createElement("button");t.textContent="Apply changes",this.content.appendChild(t),t.addEventListener("click",()=>this.applyChanges()),t.disabled=!0;const n=this.closeButton=document.createElement("button");n.classList.add("close-button"),n.textContent="Close",this.content.appendChild(n),n.addEventListener("click",()=>this.dispose());const s=this.downloadButton=document.createElement("button");s.textContent="Download",s.title="Download state as a JSON file",this.content.appendChild(s),s.addEventListener("click",()=>this.downloadState()),this.textEditor=Ti()(r=>{},{value:"",mode:{name:"javascript",json:!0},foldGutter:!0,gutters:["CodeMirror-lint-markers","CodeMirror-foldgutter"]}),this.updateView(),this.textEditor.on("change",()=>{this.debouncedValueUpdater()}),this.content.appendChild(this.textEditor.getWrapperElement()),this.textEditor.refresh()}downloadState(){const e=document.createElement("a"),t=new Blob([this.getJson()],{type:"text/json"}),n=URL.createObjectURL(t);e.href=n,e.download="state.json",e.click(),document.body.removeChild(e)}applyChanges(){this.parsedValue!==null&&(this.viewer.state.reset(),this.viewer.state.restoreState(this.parsedValue)),this.applyButton.disabled=!0}updateView(){this.textEditor.setValue(this.getJson()),this.textEditor.execCommand("foldAll"),this.textEditor.execCommand("unfold")}getJson(){return JSON.stringify(Lo(this.viewer.state).value,null," ")}}/** + * @license + * Copyright 2019 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const H_={side:"bottom",size:100,minSize:50,row:0,col:0,flex:1,visible:!1};class J_{constructor(){this.location=new Si(H_)}get changed(){return this.location.changed}restoreState(e){this.location.restoreState(e)}reset(){this.location.reset()}toJSON(){return(0,f.Zu)(this.location.toJSON())}}function j_(i){const e=new Map;function t(n,s){if(n==null||typeof n!="object"){e.set(s,""+n);return}for(const r of Object.keys(n))t(n[r],s+"."+r)}return t(i,""),e}function Y_(i){const e=new Set;e.add(".type");const t=new Set;function n(s,r){for(const o of e)if(i[s].get(o)!==i[r].get(o))return!0;return!1}for(let s=0,r=i.length;s0;){let a=o,l;for(const c of t){if(e.has(c))continue;const d=[];for(const u of o)i[u].get(c)===i[s].get(c)&&d.push(u);if(d.lengthQ_(n,t))}const X_=1e3,mh=[{label:"Visible chunks/T",key:"visibleChunksTotal",getter:i=>{let e=0;for(let t=0;ti[Pi(Ue.DOWNLOADING,ri.VISIBLE)*Un+oi.numChunks]},{label:"Visible chunks/M",key:"visibleChunksSystemMemory",getter:i=>i[Pi(Ue.SYSTEM_MEMORY,ri.VISIBLE)*Un+oi.numChunks]+i[Pi(Ue.SYSTEM_MEMORY_WORKER,ri.VISIBLE)*Un+oi.numChunks]},{label:"Visible chunks/G",key:"visibleChunksGpuMemory",getter:i=>i[Pi(Ue.GPU_MEMORY,ri.VISIBLE)*Un+oi.numChunks]},{label:"Visible chunks/F",key:"visibleChunksFailed",getter:i=>i[Pi(Ue.FAILED,ri.VISIBLE)*Un+oi.numChunks]},{label:"Visible memory",key:"visibleGpuMemory",getter:i=>i[Pi(Ue.GPU_MEMORY,ri.VISIBLE)*Un+oi.gpuMemoryBytes]},{label:"Download latency",key:"downloadLatency",getter:i=>i[tp(ec.totalTime)]/i[tp(ec.totalChunks)]}];class Z_ extends ji{constructor(e,t,n){super(e,n.location),this.chunkQueueManager=t,this.displayState=n,this.data=void 0,this.requestDataTimerId=-1,this.dataRequested=!1,this.body=document.createElement("div"),this.debouncedUpdateView=this.registerCancellable((0,Fe.A)(()=>this.updateView(),0));const{body:s}=this;s.classList.add("neuroglancer-statistics-panel-body"),this.addTitleBar({title:"Chunk statistics"}),this.addBody(s),this.requestData()}disposed(){window.clearTimeout(this.requestDataTimerId),super.disposed()}requestData(){if(this.dataRequested)return;const{chunkQueueManager:e}=this;this.dataRequested=!0,e.getStatistics().then(t=>{this.dataRequested=!1,this.data=t,this.debouncedUpdateView(),this.requestDataTimerId=window.setTimeout(()=>{this.requestDataTimerId=-1,this.requestData()},X_)})}updateView(){const{data:e}=this;if(e===void 0)return;const t=document.createElement("table"),n=[];for(const[a,l]of e){const c=[a];for(const{getter:d}of mh)c.push(d(l));n.push(c)}const s=q_(n.map(a=>K_(a[0]))),r=new Map;s.forEach((a,l)=>{r.set(n[l][0],a)});{const a=document.createElement("thead");let l=document.createElement("tr");a.appendChild(l);const c=u=>{const h=document.createElement("td");h.textContent=u,l.appendChild(h)};c("Name");let d;for(const{label:u}of mh){const h=u.indexOf("/");let p=u;if(h!==-1){if(p=u.substring(0,h),p===d){++l.lastElementChild.colSpan;continue}d=p}c(p)}l=document.createElement("tr"),a.appendChild(l);{const u=document.createElement("td");l.appendChild(u)}for(const{label:u}of mh){const h=u.indexOf("/");let p="";h!==-1&&(p=u.substring(h+1));const m=document.createElement("td");m.textContent=p,l.appendChild(m)}t.appendChild(a)}const o=document.createElement("tbody");for(const[a,...l]of n){const c=document.createElement("tr"),d=u=>{const h=document.createElement("td");h.textContent=u,c.appendChild(h)};d(r.get(a));for(const u of l)d(""+u);o.appendChild(c)}t.appendChild(o),Me(this.body),this.body.appendChild(t)}}/** + * @license + * Copyright 2021 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const eV={...Ui,side:"left",row:2};class tV{constructor(){this.location=new Si(eV)}get changed(){return this.location.changed}toJSON(){return(0,f.Zu)(this.location.toJSON())}reset(){this.location.reset()}restoreState(e){this.location.restoreState(e)}}class nV extends ji{constructor(e,t,n){super(e,t.location),this.addTitleBar({title:"Settings"});const s=document.createElement("div");s.classList.add("neuroglancer-settings-body");const r=document.createElement("div");r.classList.add("neuroglancer-settings-scroll-container"),s.appendChild(r),this.addBody(s);{const c=this.registerDisposer(new lm(n.title));c.element.placeholder="Title",c.element.classList.add("neuroglancer-settings-title"),r.appendChild(c.element)}const o=(c,d)=>{const u=this.registerDisposer(new Ic(d,{label:c}));u.element.classList.add("neuroglancer-settings-limit-widget"),r.appendChild(u.element)};o("GPU memory limit",n.chunkQueueManager.capacities.gpuMemory.sizeLimit),o("System memory limit",n.chunkQueueManager.capacities.systemMemory.sizeLimit),o("Concurrent chunk requests",n.chunkQueueManager.capacities.download.itemLimit);const a=(c,d)=>{const u=document.createElement("label");u.textContent=c;const h=this.registerDisposer(new pn(d));u.appendChild(h.element),r.appendChild(u)};a("Show axis lines",n.showAxisLines),a("Show scale bar",n.showScaleBar),a("Show cross sections in 3-d",n.showPerspectiveSliceViews),a("Show default annotations",n.showDefaultAnnotations),a("Show chunk statistics",n.statisticsDisplayState.location.watchableVisible),a("Wire frame rendering",n.wireFrame),a("Enable prefetching",n.chunkQueueManager.enablePrefetch),a("Enable adaptive downsampling",n.enableAdaptiveDownsampling);const l=(c,d)=>{const u=document.createElement("label");u.textContent=c;const h=this.registerDisposer(new hi(d));u.appendChild(h.element),r.appendChild(u)};l("Cross-section background",n.crossSectionBackgroundColor),l("Projection background",n.perspectiveViewBackgroundColor)}}/** + * @license + * Copyright 2018 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class iV extends T.O8{constructor(e,t){super(),this.selectedLayer=e,this.toolBinder=t,this.element=document.createElement("div"),this.viewContext=void 0,this.updateView=this.registerCancellable((0,Qe.t)(()=>{let{viewContext:s}=this;s!==void 0&&(this.unregisterDisposer(s),s.dispose()),this.viewContext=s=this.registerDisposer(new T.O8),Me(this.element);const{selectedTool:r}=this;r!==void 0&&this.element.appendChild(this.makeWidget(s,r));const o=Array.from(this.toolBinder.bindings);o.sort(([a],[l])=>(0,kr.e)(a,l));for(const[,a]of o)this.element.appendChild(this.makeWidget(s,a))}));const{element:n}=this;n.className="neuroglancer-annotation-tool-status",this.registerDisposer(e.changed.add(()=>this.selectedLayerChanged())),this.registerDisposer(t.changed.add(this.updateView)),this.registerDisposer(this.selectedLayer.layerManager.layersChanged.add(this.updateView)),this.selectedLayerChanged()}get selectedTool(){const e=this.selectedLayer.layer;if(e===void 0)return;const t=e.layer;if(t!==null)return t.tool.value}selectedLayerChanged(){const{unbindPreviousLayer:e}=this;e!==void 0&&e();const t=this.selectedLayer.layer;t!==void 0&&(this.unbindPreviousLayer=t.specificationChanged.add(()=>{this.updateView()})),this.updateView()}disposed(){const{unbindPreviousLayer:e}=this;e!==void 0&&e(),this.unbindPreviousLayer=void 0}makeWidget(e,t){const n=document.createElement("div");n.title="dblclick \u2192 unbind",t instanceof Oo&&(n.title+=", click \u2192 bind key"),n.className="neuroglancer-annotation-tool-status-widget";const s=document.createElement("div");s.className="neuroglancer-annotation-tool-status-widget-layer-number";const r=document.createElement("div");if(r.className="neuroglancer-annotation-tool-status-widget-description",r.textContent=t.description,n.addEventListener("dblclick",()=>{t instanceof Df?t.layer.tool.value=void 0:this.toolBinder.set(t.keyBinding,void 0)}),t instanceof Oo){const a=document.createElement("div");a.className="neuroglancer-annotation-tool-status-widget-key",a.textContent=t.keyBinding,n.appendChild(a),Rf(e,n,l=>t.localBinder.set(l,t.addRef()))}const o=t.context;if(o instanceof Rn){const{managedLayer:a}=o;a.manager.rootLayers.updateNonArchivedLayerIndices();const l=a.nonArchivedLayerIndex;s.textContent=(l+1).toString(),n.appendChild(s)}return n.appendChild(r),n}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class sV extends T.O8{constructor(e,t){super(),this.gl=e,this.frameNumberCounter=t,this.worker=new Worker(new URL(G.p+G.u(717),G.b),{type:"module"}),this.chunkQueueManager=this.registerDisposer(new Vc(new ZC(this.worker,!0),this.gl,this.frameNumberCounter,{gpuMemory:new Zo({defaultItemLimit:1e6,defaultSizeLimit:1e9}),systemMemory:new Zo({defaultItemLimit:1e7,defaultSizeLimit:2e9}),download:new Zo({defaultItemLimit:100,defaultSizeLimit:Number.POSITIVE_INFINITY}),compute:new Zo({defaultItemLimit:128,defaultSizeLimit:5e8})})),this.chunkQueueManager.registerDisposer(()=>this.worker.terminate()),this.chunkManager=this.registerDisposer(new Bc(this.chunkQueueManager))}get rpc(){return this.chunkQueueManager.rpc}}class k2 extends QO{constructor(){super(...arguments),this.global=new Ae}}const Ub=["showHelpButton","showSettingsButton","showEditStateButton","showLayerListPanelButton","showSelectionPanelButton","showLayerSidePanelButton","showLocation","showAnnotationToolStatus"],$b=[...Ub,"showLayerPanel","showLayerHoverValues"],Gb=[...$b,"showUIControls","showPanelBorders"];function rV(){return Object.fromEntries(Gb.map(i=>[i,new nt(!0)]))}function oV(i,e){for(const t of Gb){const n=e[t];n!==void 0&&(i[t].value=n)}}const aV=typeof NEUROGLANCER_OVERRIDE_DEFAULT_VIEWER_OPTIONS<"u"?NEUROGLANCER_OVERRIDE_DEFAULT_VIEWER_OPTIONS:{showLayerDialog:!0,resetStateWhenEmpty:!0};class lV extends fr{constructor(e){super(),this.viewer=e,this.add("title",e.title),this.add("dimensions",e.coordinateSpace),this.add("relativeDisplayScales",e.relativeDisplayScales),this.add("displayDimensions",e.displayDimensions),this.add("position",e.position),this.add("velocity",e.velocity),this.add("crossSectionOrientation",e.crossSectionOrientation),this.add("crossSectionScale",e.crossSectionScale),this.add("crossSectionDepth",e.crossSectionDepthRange),this.add("projectionOrientation",e.projectionOrientation),this.add("projectionScale",e.projectionScale),this.add("projectionDepth",e.projectionDepthRange),this.add("layers",e.layerSpecification),this.add("showAxisLines",e.showAxisLines),this.add("wireFrame",e.wireFrame),this.add("enableAdaptiveDownsampling",e.enableAdaptiveDownsampling),this.add("showScaleBar",e.showScaleBar),this.add("showDefaultAnnotations",e.showDefaultAnnotations),this.add("showSlices",e.showPerspectiveSliceViews),this.add("gpuMemoryLimit",e.dataContext.chunkQueueManager.capacities.gpuMemory.sizeLimit),this.add("prefetch",e.dataContext.chunkQueueManager.enablePrefetch),this.add("systemMemoryLimit",e.dataContext.chunkQueueManager.capacities.systemMemory.sizeLimit),this.add("concurrentDownloads",e.dataContext.chunkQueueManager.capacities.download.itemLimit),this.add("selectedLayer",e.selectedLayer),this.add("crossSectionBackgroundColor",e.crossSectionBackgroundColor),this.add("projectionBackgroundColor",e.perspectiveViewBackgroundColor),this.add("layout",e.layout),this.add("statistics",e.statisticsDisplayState),this.add("helpPanel",e.helpPanelState),this.add("settingsPanel",e.settingsPanelState),this.add("selection",e.selectionDetailsState),this.add("layerListPanel",e.layerListPanelState),this.add("partialViewport",e.partialViewport),this.add("selectedStateServer",e.selectedStateServer),this.add("toolBindings",e.toolBinder)}restoreState(e){const{viewer:t}=this;super.restoreState(e),(0,f.MM)(e,"navigation",n=>{(0,f.Rf)(n),(0,f.MM)(n,"pose",s=>{(0,f.Rf)(s),(0,f.MM)(s,"position",r=>{(0,f.Rf)(r),Mt(r,"voxelCoordinates",t.position),(0,f.MM)(r,"voxelSize",o=>{const a=(0,f.Xu)(new Float64Array(3),o,f.Mo);for(let l=0;l<3;++l)a[l]*=1e-9;t.coordinateSpace.value=Oe({valid:!1,names:["x","y","z"],units:["m","m","m"],scales:a})})}),Mt(s,"orientation",t.crossSectionOrientation)}),Mt(n,"zoomFactor",t.crossSectionScale.legacyJsonView)}),Mt(e,"perspectiveOrientation",t.projectionOrientation),Mt(e,"perspectiveZoom",t.projectionScale.legacyJsonView),Mt(e,"perspectiveViewBackgroundColor",t.perspectiveViewBackgroundColor)}}class zb extends T.O8{constructor(e,t={}){super(),this.display=e,this.title=new _.DN(void 0,f.zr),this.coordinateSpace=new zl,this.position=this.registerDisposer(new ui(this.coordinateSpace)),this.velocity=this.registerDisposer(new gc(this.coordinateSpace)),this.relativeDisplayScales=this.registerDisposer(new Qp(this.coordinateSpace)),this.displayDimensions=this.registerDisposer(new ef(this.coordinateSpace)),this.displayDimensionRenderInfo=this.registerDisposer(new Zp(this.relativeDisplayScales.addRef(),this.displayDimensions.addRef())),this.crossSectionOrientation=this.registerDisposer(new bs),this.crossSectionScale=this.registerDisposer(new Zw(this.displayDimensionRenderInfo.addRef())),this.projectionOrientation=this.registerDisposer(new bs),this.crossSectionDepthRange=this.registerDisposer(new Sc(-10,this.displayDimensionRenderInfo)),this.projectionDepthRange=this.registerDisposer(new Sc(-50,this.displayDimensionRenderInfo)),this.projectionScale=this.registerDisposer(new ex(this.displayDimensionRenderInfo.addRef())),this.navigationState=this.registerDisposer(new ws(new Cs(this.position.addRef(),this.displayDimensionRenderInfo.addRef(),this.crossSectionOrientation.addRef()),this.crossSectionScale.addRef(),this.crossSectionDepthRange.addRef())),this.perspectiveNavigationState=this.registerDisposer(new ws(new Cs(this.position.addRef(),this.displayDimensionRenderInfo.addRef(),this.projectionOrientation.addRef()),this.projectionScale.addRef(),this.projectionDepthRange.addRef())),this.mouseState=new OT,this.layerManager=this.registerDisposer(new Mg),this.selectedLayer=this.registerDisposer(new GT(this.layerManager.addRef())),this.showAxisLines=new nt(!0,!0),this.wireFrame=new nt(!1,!1),this.enableAdaptiveDownsampling=new nt(!0,!0),this.showScaleBar=new nt(!0,!0),this.showPerspectiveSliceViews=new nt(!0,!0),this.visibleLayerRoles=aw(),this.showDefaultAnnotations=new nt(!0,!0),this.crossSectionBackgroundColor=new q(C.eR.fromValues(.5,.5,.5)),this.perspectiveViewBackgroundColor=new q(C.eR.fromValues(0,0,0)),this.scaleBarOptions=new IO,this.partialViewport=new YC,this.statisticsDisplayState=new J_,this.helpPanelState=new p_,this.settingsPanelState=new tV,this.layerSelectedValues=this.registerDisposer(new _T(this.layerManager,this.mouseState)),this.selectionDetailsState=this.registerDisposer(new VT(this.coordinateSpace,this.layerSelectedValues)),this.selectedStateServer=new _.DN("",f.zr),this.layerListPanelState=new V_,this.resetInitiated=new j.IY,this.uiControlVisibility={},this.visible=!0,this.toolInputEventMapBinder=(p,m)=>{m.registerDisposer(this.inputEventBindings.sliceView.addParent(p,Number.POSITIVE_INFINITY)),m.registerDisposer(this.inputEventBindings.perspectiveView.addParent(p,Number.POSITIVE_INFINITY))},this.globalToolBinder=this.registerDisposer(new Rx(this.toolInputEventMapBinder)),this.toolBinder=this.registerDisposer(new Dc(this,this.globalToolBinder));const{dataContext:n=new sV(e.gl,e),visibility:s=new vt(vt.VISIBLE),inputEventBindings:r={global:new Ae,sliceView:new Ae,perspectiveView:new Ae},element:o=e.makeCanvasOverlayElement(),dataSourceProvider:a=LP({credentialsManager:Zn}),uiConfiguration:l=rV()}=t;this.visibility=s,this.inputEventBindings=r,this.element=o,this.dataSourceProvider=a,this.uiConfiguration=l,this.registerDisposer((0,_.W1)(p=>{this.display.applyWindowedViewportToElement(o,p)},this.partialViewport)),this.registerDisposer(()=>at(this.element)),this.dataContext=this.registerDisposer(n),oV(l,t);const c={...aV,...t},{resetStateWhenEmpty:d,showLayerDialog:u}=c;for(const p of $b)this.uiControlVisibility[p]=this.makeUiControlVisibilityState(p);this.registerDisposer(this.uiConfiguration.showPanelBorders.changed.add(()=>{this.updateShowBorders()})),this.showLayerDialog=u,this.resetStateWhenEmpty=d,this.layerSpecification=new HT(this.display,this.dataSourceProvider,this.layerManager,this.chunkManager,this.selectionDetailsState,this.selectedLayer,this.navigationState.coordinateSpace,this.navigationState.pose.position,this.globalToolBinder),this.registerDisposer(e.updateStarted.add(()=>{this.onUpdateDisplay()})),this.showDefaultAnnotations.changed.add(()=>{this.showDefaultAnnotations.value?this.visibleLayerRoles.add(li.DEFAULT_ANNOTATION):this.visibleLayerRoles.delete(li.DEFAULT_ANNOTATION)}),this.registerDisposer(this.navigationState.changed.add(()=>{this.handleNavigationStateChanged()}));const h=this.registerCancellable((0,Fe.A)(()=>{!this.wasDisposed&&this.layerManager.managedLayers.length===0&&this.resetStateWhenEmpty&&(this.navigationState.reset(),this.perspectiveNavigationState.pose.orientation.reset(),this.perspectiveNavigationState.zoomFactor.reset(),this.resetInitiated.dispatch(),!au&&this.showLayerDialog&&this.visibility.visible&&Qg(this.layerSpecification,this.selectedLayer))}));this.layerManager.layersChanged.add(h),h(),this.registerDisposer(this.dataContext.chunkQueueManager.visibleChunksChanged.add(()=>{this.layerSelectedValues.handleLayerChange()})),this.registerDisposer(this.dataContext.chunkQueueManager.visibleChunksChanged.add(()=>{this.visible&&e.scheduleRedraw()})),this.makeUI(),this.updateShowBorders(),this.registerActionListeners(),this.registerEventActionBindings(),this.registerDisposer(Nb(o,this.navigationState.position)),this.state=new lV(this),this.registerDisposer(new mc(this.display,this.position,this.velocity))}get chunkManager(){return this.dataContext.chunkManager}get chunkQueueManager(){return this.dataContext.chunkQueueManager}makeUiControlVisibilityState(e){const t=this.uiConfiguration.showUIControls,n=this.uiConfiguration[e];return this.registerDisposer((0,_.Kk)((s,r)=>s&&r,t,n))}get inputEventMap(){return this.inputEventBindings.global}updateShowBorders(){const{element:e}=this,t="neuroglancer-show-panel-borders";this.uiConfiguration.showPanelBorders.value?e.classList.add(t):e.classList.remove(t)}makeUI(){const e=this.element;e.classList.add("neuroglancer-viewer"),e.classList.add("neuroglancer-noselect"),e.style.display="flex",e.style.flexDirection="column";const t=document.createElement("div");t.classList.add("neuroglancer-viewer-top-row"),t.style.display="flex",t.style.flexDirection="row",t.style.alignItems="stretch";const n=this.registerDisposer(new xs(this.navigationState.position,this.layerSpecification.coordinateSpaceCombiner,{velocity:this.velocity,getToolBinder:()=>this.toolBinder}));this.registerDisposer(new en(this.uiControlVisibility.showLocation,n.element)),t.appendChild(n.element);const s=this.registerDisposer(new Bx(document.createElement("div"),this.mouseState,this.navigationState.coordinateSpace));if(s.element.style.flex="1",s.element.style.alignSelf="center",this.registerDisposer(new en(this.uiControlVisibility.showLocation,s.element)),t.appendChild(s.element),typeof NEUROGLANCER_CREDIT_LINK<"u"){let a=NEUROGLANCER_CREDIT_LINK;Array.isArray(a)||(a=[a]);for(const{url:l,text:c}of a){const d=document.createElement("a");d.style.marginRight="5px",d.href=l,d.textContent=c,d.style.fontFamily="sans-serif",d.style.color="yellow",d.target="_blank",t.appendChild(d)}}const r=this.registerDisposer(new iV(this.selectedLayer,this.globalToolBinder));if(t.appendChild(r.element),this.registerDisposer(new en(this.uiControlVisibility.showAnnotationToolStatus,r.element)),l_){const a=this.registerDisposer(new c_(this));t.appendChild(a.element)}{const{layerListPanelState:a}=this,l=this.registerDisposer(new rn(a.location.watchableVisible,{svg:lO,backgroundScheme:"dark",enableTitle:"Show layer list panel",disableTitle:"Hide layer list panel"}));l.element.insertAdjacentElement("afterbegin",this.registerDisposer(new G_(this.layerManager)).element),this.registerDisposer(new en(this.uiControlVisibility.showLayerListPanelButton,l.element)),t.appendChild(l.element)}{const{selectionDetailsState:a}=this,l=this.registerDisposer(new rn(a.location.watchableVisible,{svg:cO,backgroundScheme:"dark",enableTitle:"Show selection details panel",disableTitle:"Hide selection details panel"}));this.registerDisposer(new en(this.uiControlVisibility.showSelectionPanelButton,l.element)),t.appendChild(l.element)}{const{selectedLayer:a}=this,l=this.registerDisposer(new rn({get value(){return a.visible},set value(c){a.visible=c},changed:a.location.locationChanged},{svg:rb,backgroundScheme:"dark",enableTitle:"Show layer side panel",disableTitle:"Hide layer side panel"}));this.registerDisposer(new en(this.uiControlVisibility.showLayerSidePanelButton,l.element)),t.appendChild(l.element)}{const a=Ne({text:"{}",title:"Edit JSON state"});this.registerEventListener(a,"click",()=>{this.editJsonState()}),this.registerDisposer(new en(this.uiControlVisibility.showEditStateButton,a)),t.appendChild(a)}{const{helpPanelState:a}=this,l=this.registerDisposer(new rn(a.location.watchableVisible,{text:"?",backgroundScheme:"dark",enableTitle:"Show help panel",disableTitle:"Hide help panel"}));this.registerDisposer(new en(this.uiControlVisibility.showHelpButton,l.element)),t.appendChild(l.element)}{const{settingsPanelState:a}=this,l=this.registerDisposer(new rn(a.location.watchableVisible,{svg:dO,backgroundScheme:"dark",enableTitle:"Show settings panel",disableTitle:"Hide settings panel"}));this.registerDisposer(new en(this.uiControlVisibility.showSettingsButton,l.element)),t.appendChild(l.element)}this.registerDisposer(new en((0,_.Kk)((...a)=>a.reduce((l,c)=>l||c,!1),...Ub.map(a=>this.uiControlVisibility[a])),t)),e.appendChild(t),this.layout=this.registerDisposer(new k_(this,"4panel")),this.sidePanelManager=this.registerDisposer(new ND(this.display,this.layout.element,this.visibility)),this.registerDisposer(this.sidePanelManager.registerPanel({location:this.layerListPanelState.location,makePanel:()=>new $_(this.sidePanelManager,this.layerSpecification,this.layerListPanelState)})),this.registerDisposer(new O_(this.sidePanelManager,this.selectedLayer.addRef())),this.registerDisposer(this.sidePanelManager.registerPanel({location:this.selectionDetailsState.location,makePanel:()=>new OD(this.sidePanelManager,this.selectionDetailsState,this.layerSpecification,this.selectedLayer)})),e.appendChild(this.sidePanelManager.element),this.registerDisposer(this.sidePanelManager.registerPanel({location:this.statisticsDisplayState.location,makePanel:()=>new Z_(this.sidePanelManager,this.chunkQueueManager,this.statisticsDisplayState)})),this.registerDisposer(this.sidePanelManager.registerPanel({location:this.helpPanelState.location,makePanel:()=>{const{inputEventBindings:a}=this;return new f_(this.sidePanelManager,this.helpPanelState,[["Global",a.global],["Cross section view",a.sliceView],["3-D projection view",a.perspectiveView]],this.layerManager,this.globalToolBinder)}})),this.registerDisposer(this.sidePanelManager.registerPanel({location:this.settingsPanelState.location,makePanel:()=>new nV(this.sidePanelManager,this.settingsPanelState,this)}));const o=()=>{const a=this.visibility.visible;a!==this.visible&&(e.style.visibility=a?"inherit":"hidden",this.visible=a)};o(),this.registerDisposer(this.visibility.changed.add(o))}registerEventActionBindings(){const{element:e}=this;this.registerDisposer(new yn(e,this.inputEventMap)),this.registerDisposer(new za(e))}bindAction(e,t){this.registerDisposer(Z(this.element,e,t))}registerActionListeners(){for(const t of["recolor","clear-segments"])this.bindAction(t,()=>{this.layerManager.invokeAction(t)});const e=t=>{const n=this.selectedLayer.layer?.layer;n&&n.dispatchLayerEvent(t)};this.bindAction("select-previous",()=>{e("select-previous")}),this.bindAction("select-next",()=>{e("select-next")});for(const t of["select","star"])this.bindAction(t,()=>{this.mouseState.updateUnconditionally(),this.layerManager.invokeAction(t)});this.bindAction("help",()=>this.toggleHelpPanel());for(let t=1;t<=9;++t)this.bindAction(`toggle-layer-${t}`,()=>{const n=this.layerManager.getLayerByNonArchivedIndex(t-1);n!==void 0&&n.setVisible(!n.visible)}),this.bindAction(`toggle-pick-layer-${t}`,()=>{const n=this.layerManager.getLayerByNonArchivedIndex(t-1);n!==void 0&&(n.pickEnabled=!n.pickEnabled)}),this.bindAction(`select-layer-${t}`,()=>{const n=this.layerManager.getLayerByNonArchivedIndex(t-1);n!==void 0&&(this.selectedLayer.layer=n,this.selectedLayer.visible=!0)});for(let t=0;t<26;++t){const n=String.fromCharCode(65+t);this.bindAction(`tool-${n}`,()=>{this.activateTool(n)})}this.bindAction("annotate",()=>{const t=this.selectedLayer.layer;if(t===void 0){pe.showTemporaryMessage("The annotate command requires a layer to be selected.");return}const n=t.layer;if(n===null||n.tool.value===void 0){pe.showTemporaryMessage(`The selected layer (${JSON.stringify(t.name)}) does not have an active annotation tool.`);return}n.tool.value.trigger(this.mouseState)}),this.bindAction("toggle-axis-lines",()=>this.showAxisLines.toggle()),this.bindAction("toggle-scale-bar",()=>this.showScaleBar.toggle()),this.bindAction("toggle-default-annotations",()=>this.showDefaultAnnotations.toggle()),this.bindAction("toggle-show-slices",()=>this.showPerspectiveSliceViews.toggle()),this.bindAction("toggle-show-statistics",()=>this.showStatistics())}toggleHelpPanel(){this.helpPanelState.location.visible=!this.helpPanelState.location.visible}activateTool(e,t){this.globalToolBinder.activate(e,t)}editJsonState(){new W_(this)}showStatistics(e=void 0){e===void 0&&(e=!this.statisticsDisplayState.location.visible),this.statisticsDisplayState.location.visible=e}get gl(){return this.display.gl}onUpdateDisplay(){this.visible&&(this.dataContext.chunkQueueManager.chunkUpdateDeadline=null)}handleNavigationStateChanged(){if(this.visible){const{chunkQueueManager:e}=this.dataContext;e.chunkUpdateDeadline===null&&(e.chunkUpdateDeadline=Date.now()+10)}}isReady(){if(this.chunkQueueManager.flushPendingChunkUpdates(),!this.display.isReady())return!1;for(const e of this.layerManager.managedLayers)if(!e.isReady())return!1;return!0}}$x(zb),zx(ro),Gx(Rn);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function cV(i={}){try{let{target:e=document.getElementById("neuroglancer-container")}=i;e===null&&(e=document.createElement("div"),e.id="neuroglancer-container",document.body.appendChild(e));const t=new QC(e);return new zb(t,i)}catch(e){throw pe.showMessage(`Error: ${e.message}`),e}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function dV(i){return YN(),QN(),cV(i)}/** + * @license + * Copyright 2021 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function uV(i){const e=(0,Qe.t)(()=>{const n=i.value?.trim();n?document.title=`${n} - neuroglancer`:document.title="neuroglancer"}),t=i.changed.add(e);return e(),e.flush(),()=>{t(),e.cancel()}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */function hV(i){return encodeURI(i).replace(/[!'()*;,]/g,e=>"%"+e.charCodeAt(0).toString(16).toUpperCase())}class pV extends T.O8{constructor(e,t,n={}){super(),this.root=e,this.credentialsManager=t,this.parseError=new _.B0(void 0);const{updateDelayMilliseconds:s=200,defaultFragment:r="{}"}=n;this.registerEventListener(window,"hashchange",()=>this.updateFromUrlHash());const o=(0,Fe.A)(()=>this.setUrlHash(),s,{maxWait:s*2});this.registerDisposer(e.changed.add(o)),this.registerDisposer(()=>o.cancel()),this.defaultFragment=r}setUrlHash(){const e=Lo(this.root),{generation:t}=e;if(t!==this.prevStateGeneration){this.prevStateGeneration=e.generation;const n=hV(JSON.stringify(e.value));n!==this.prevStateString&&(this.prevStateString=n,decodeURIComponent(n)==="{}"?history.replaceState(null,"","#"):history.replaceState(null,"","#!"+n))}}updateFromUrlHash(){try{let e=location.href.replace(/^[^#]+/,"");if((e===""||e==="#"||e==="#!")&&(e="#!"+this.defaultFragment),e.match(/^#!([a-z][a-z\d+-.]*):\/\//)){const t=e.substring(2),{url:n,credentialsProvider:s}=wn(t,this.credentialsManager);pe.forPromise(Nt(s,n,{},ke.cj).then(r=>{(0,f.Rf)(r),this.root.reset(),this.root.restoreState(r)}),{initialMessage:`Loading state from ${t}`,errorPrefix:"Error loading state:"})}else if(e.startsWith("#!+")){e=e.slice(3),e=decodeURIComponent(e);const t=(0,f.Sf)(e);(0,f.Rf)(t),this.root.restoreState(t),this.prevStateString=void 0}else if(e.startsWith("#!")){if(e=e.slice(2),e=decodeURIComponent(e),e===this.prevStateString)return;this.prevStateString=e,this.root.reset();const t=(0,f.Sf)(e);(0,f.Rf)(t),this.root.restoreState(t)}else throw new Error('URL hash is expected to be of the form "#!{...}" or "#!+{...}".');this.parseError.value=void 0}catch(e){this.parseError.value=e}}}/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const fV=typeof{keym:{layer:"segmentation",tool:"grapheneMergeSegments",provider:"graphene"},keyc:{layer:"segmentation",tool:"grapheneMulticutSegments",provider:"graphene"},keyf:{layer:"segmentation",tool:"grapheneFindPath",provider:"graphene"},keyx:!1,"control+shift+keyx":"clear-segments",bracketleft:"select-previous",bracketright:"select-next"}<"u"&&Object.keys({keym:{layer:"segmentation",tool:"grapheneMergeSegments",provider:"graphene"},keyc:{layer:"segmentation",tool:"grapheneMulticutSegments",provider:"graphene"},keyf:{layer:"segmentation",tool:"grapheneFindPath",provider:"graphene"},keyx:!1,"control+shift+keyx":"clear-segments",bracketleft:"select-previous",bracketright:"select-next"}).length>0;function gV(){const i=window.viewer=dV();RD(i.inputEventBindings);const e=(n,s,r,o)=>{let a,l;typeof n=="string"&&(n={type:n}),(0,f.Rf)(n);const c=(0,f.cQ)(n,"type",f.zr);i.bindAction(`tool-${c}`,()=>{const d=i.layerManager.managedLayers.filter(u=>{const h=u.layer instanceof r;if(o&&h){for(const p of u.layer?.dataSources||[])if(i.dataSourceProvider.getProvider(p.spec.url)[2]===o)return!0;return!1}else return h});if(d.length>0){const u=d[0].layer;u&&(u!==l&&(a=Tc(u,n),l=u),a&&i.activateTool(s,a))}})};if(fV){const n=(s,r)=>{s.delete(r);for(const o of s.parents)n(o,r)};for(const[s,r]of Object.entries({keym:{layer:"segmentation",tool:"grapheneMergeSegments",provider:"graphene"},keyc:{layer:"segmentation",tool:"grapheneMulticutSegments",provider:"graphene"},keyf:{layer:"segmentation",tool:"grapheneFindPath",provider:"graphene"},keyx:!1,"control+shift+keyx":"clear-segments",bracketleft:"select-previous",bracketright:"select-next"}))if(n(i.inputEventBindings.global,s),n(i.inputEventBindings.perspectiveView,s),n(i.inputEventBindings.sliceView,s),typeof r=="string")i.inputEventBindings.global.set(s,r);else if(typeof r!="boolean"){i.inputEventBindings.global.set(s,`tool-${r.tool}`);const o=Mr.get(r.layer);if(o){const a=s.charAt(s.length-1).toUpperCase();e(r.tool,a,o,r.provider)}}}const t=i.registerDisposer(new pV(i.state,i.dataSourceProvider.credentialsManager,{defaultFragment:typeof NEUROGLANCER_DEFAULT_STATE_FRAGMENT<"u"?NEUROGLANCER_DEFAULT_STATE_FRAGMENT:void 0}));return i.registerDisposer(t.parseError.changed.add(()=>{const{value:n}=t.parseError;n!==void 0&&(new pe().setErrorMessage(`Error parsing state: ${n.message}`),console.log("Error parsing state",n)),t.parseError})),t.updateFromUrlHash(),i.registerDisposer(uV(i.title)),HN(i),jN(i),i}var P2=G(8626);/** + * @license + * Copyright 2016 Google Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */gV()}},Hb={};function _e(se){var Ee=Hb[se];if(Ee!==void 0)return Ee.exports;var G=Hb[se]={exports:{}};return Wb[se].call(G.exports,G,G.exports,_e),G.exports}_e.m=Wb,_e.x=()=>{var se=_e.O(void 0,[562,993,367],()=>_e(4320));return se=_e.O(se),se},(()=>{var se=[];_e.O=(Ee,G,_,F)=>{if(G){F=F||0;for(var fe=se.length;fe>0&&se[fe-1][2]>F;fe--)se[fe]=se[fe-1];se[fe]=[G,_,F];return}for(var C=1/0,fe=0;fe=F)&&Object.keys(_e.O).every(tt=>_e.O[tt](G[Le]))?G.splice(Le--,1):(ye=!1,F{var Ee=se&&se.__esModule?()=>se.default:()=>se;return _e.d(Ee,{a:Ee}),Ee},_e.d=(se,Ee)=>{for(var G in Ee)_e.o(Ee,G)&&!_e.o(se,G)&&Object.defineProperty(se,G,{enumerable:!0,get:Ee[G]})},_e.f={},_e.e=se=>Promise.all(Object.keys(_e.f).reduce((Ee,G)=>(_e.f[G](se,Ee),Ee),[])),_e.u=se=>se===717?"neuroglancer_chunk_worker.6de531489d574d806f47.js":""+se+"."+{367:"ad6071abcab399305157",562:"1d0cecad9cc0725955f0",993:"ca23372ceee17151541a"}[se]+".js",_e.miniCssF=se=>{},_e.o=(se,Ee)=>Object.prototype.hasOwnProperty.call(se,Ee),_e.r=se=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(se,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(se,"__esModule",{value:!0})},(()=>{var se;if(typeof import.meta.url=="string"&&(se=import.meta.url),!se)throw new Error("Automatic publicPath is not supported in this browser");se=se.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),_e.p=se})(),(()=>{_e.b=new URL("./",import.meta.url);var se={792:0},Ee=G=>{var{ids:_,modules:F,runtime:fe}=G,C,ye,Le=0;for(C in F)_e.o(F,C)&&(_e.m[C]=F[C]);for(fe&&fe(_e);Le<_.length;Le++)ye=_[Le],_e.o(se,ye)&&se[ye]&&se[ye][0](),se[_[Le]]=0;_e.O()};_e.f.j=(G,_)=>{var F=_e.o(se,G)?se[G]:void 0;if(F!==0)if(F)_.push(F[1]);else{var fe=import("./"+_e.u(G)).then(Ee,C=>{throw se[G]!==0&&(se[G]=void 0),C}),fe=Promise.race([fe,new Promise(C=>F=se[G]=[C])]);_.push(F[1]=fe)}},_e.O.j=G=>se[G]===0})(),(()=>{var se=_e.x;_e.x=()=>Promise.all([562,993,367].map(_e.e,_e)).then(se)})();var N2=_e.x(); + +//# sourceMappingURL=main.cb26101b553ed6b82856.js.map \ No newline at end of file diff --git a/neuvue_project/workspace/static/spelunker-workspace/main.cb26101b553ed6b82856.js.map b/neuvue_project/workspace/static/spelunker-workspace/main.cb26101b553ed6b82856.js.map new file mode 100644 index 0000000..cfed18d --- /dev/null +++ b/neuvue_project/workspace/static/spelunker-workspace/main.cb26101b553ed6b82856.js.map @@ -0,0 +1 @@ +{"version":3,"file":"main.cb26101b553ed6b82856.js","mappings":"6EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAkBO,IAAKA,GAAAA,KACVA,GAAAA,GAAA,mBAAqB,CAAC,EAAtB,qBACAA,GAAAA,GAAA,mBAAqB,CAAC,EAAtB,qBACAA,GAAAA,GAAA,wBAA0B,GAA1B,0BACAA,GAAAA,GAAA,2BAA6B,GAA7B,6BAJUA,KAAAA,GAAA,IAQL,SAASC,GAAgBC,GAAmB,CACjD,MAAO,EAAAA,GAAU,OAAS,GAC5B,CAEO,MAAMC,EAAyB,IAAI,IAAO,WAAY,UAAU,C,iNC9BvE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAiCO,MAAMC,CAAwD,CAWnE,YAAsBC,EAAW,CAAX,YAAAA,EADtB,aAAU,IAAI,KACoB,CAVlC,IAAI,OAAQ,CACV,OAAO,KAAK,MACd,CACA,IAAI,MAAMC,EAAa,CACjBA,IAAa,KAAK,SACpB,KAAK,OAASA,EACd,KAAK,QAAQ,SAAS,EAE1B,CAGF,CAEO,MAAMC,WAA0BH,CAAuC,CAC5E,YACEI,EACOC,EACAC,EAAeF,EACtB,CACA,MAAMA,CAAK,EAHJ,eAAAC,EACA,kBAAAC,CAGT,CACA,QAAc,CACZ,KAAM,CAAE,OAAAL,CAAO,EAAI,KACnB,GAAIA,IAAW,KAAK,aAGpB,OAAO,KAAK,MACd,CACA,OAAQ,CACN,KAAK,MAAQ,KAAK,YACpB,CACA,aAAaM,EAAQ,CACnB,GAAIA,IAAM,O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AAyB+N,CAAQ,CACtC,EACA,KAAKluC,EAAgByf,EAAgB,CACnC44D,EAAKl4C,EAAI+N,EAAUluC,EAAQyf,CAAM,CACnC,CACF,CACR,CAAC,CACH,CACF,CACF,CAEA,SAAS+4D,GACP5sC,EACA+J,EACAhF,EACAC,EACA,CACA,OAAOwnC,GACLxsC,EACA,CAACzL,EAAI+N,EAAUluC,EAAQyf,IAAW,CAChC0gB,EAAG,oBACD+N,EACUyH,EACAhF,EACMC,EAChB5wC,EACAyf,CACF,CACF,CACF,CACF,CAEA,SAASg5D,GACP7sC,EACA+J,EACAhF,EACA,CACA,OAAOynC,GACLxsC,EACA,CAACzL,EAAI+N,EAAUluC,EAAQyf,IAAW,CAChC0gB,EAAG,qBACD+N,EACUyH,EACAhF,EACV3wC,EACAyf,CACF,CACF,CACF,CACF,CAEA,MAAMi5D,GAEF,CACF,IAAKF,GACH,aACA,EACA,uBAAuB,cACP,EAClB,EACA,KAAMA,GACJ,aACA,EACA,uBAAuB,cACP,EAClB,EACA,QAASA,GACP,cACA,EACA,uBAAuB,MACP,EAClB,EACA,OAAQC,GACN,aACA,EACA,uBAAuB,YACzB,EACA,MAAOA,GACL,YACA,EACA,uBAAuB,GACzB,EACA,OAAQA,GACN,aACA,EACA,uBAAuB,cACzB,EACA,MAAOA,GACL,YACA,EACA,uBAAuB,KACzB,EACA,MAAOA,GACL,aACA,EACA,uBAAuB,aACzB,EACA,KAAMA,GACJ,YACA,EACA,uBAAuB,IACzB,CACF,EAEA,MAAME,WAAmC,IAAW,CAQlD,YACSx4C,EACA5e,EACArY,EACAgZ,EACP,CACA,MAAM,EALC,QAAAie,EACA,oBAAA5e,EACA,UAAArY,EACA,gBAAAgZ,EAGP,MAAM02D,EACH,KAAK,qCACJp3D,GAAuBD,CAAc,EAAE,gBAAgBrY,CAAI,EACzD,CACJ,QAAAkX,EACA,gBAAiBy4D,EACjB,mBAAA54D,CACF,EAAIN,GACFzW,EACA0vE,EACA12D,CACF,EACA,KAAK,6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ACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,CACF,CAAC,EAEYC,IAAwC,IAAM,CAwBzD,MAAMC,EAA+B,CAAC,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,CAAC,EAGtDC,EAA+B,CAAC,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,CAAC,EAGtDC,EAAoB,CACxB,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,CACF,EAIMC,EAAoB,CACxB,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,CACF,EAEMC,EAAgB,IAAI,WAAW,EAAI,EAAI,CAAC,EAC9C,QAAS7/G,EAAI,EAAGA,EAAI,EAAG,EAAEA,EACvB,QAAS/K,EAAI,EAAGA,EAAI0qH,EAAkB,OAAQ,EAAE1qH,EAAG,CACjD,MAAM6qH,EACJJ,EAA6B1/G,CAAC,EAAI,EAAI2/G,EAAkB1qH,CAAC,EAC3D4qH,EAAc7/G,EAAI,EAAI,EAAI/K,CAAC,EACzBwqH,EAA6BG,EAAkBE,CAAsB,CAAC,CAC1E,CAEF,OAAOD,CACT,GAAG,EAEI,SAASE,GAAoCv5E,EAAwB,CAE1EA,EAAQ,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H,EAQAklK,GAAoB,EAAE,EAAKa,GAAaG,GAAgBH,CAAO,IAAM,C,WC1DrE,IAAI9iJ,GAAOiiJ,GAAoB,EAC/BA,GAAoB,EAAI,IAChB,QAAQ,IAAI,CAAC,IAAI,IAAI,GAAG,EAAE,IAAIA,GAAoB,EAAGA,EAAmB,CAAC,EAAE,KAAKjiJ,EAAI,C,KCD5F,IAAIsiJ,GAAsBL,GAAoB,EAAE","sources":["webpack://neuroglancer/./src/segmentation_graph/segment_id.ts","webpack://neuroglancer/./src/trackable_value.ts","webpack://neuroglancer/./src/util/array.ts","webpack://neuroglancer/./src/util/cancellation.ts","webpack://neuroglancer/./src/util/disposable.ts","webpack://neuroglancer/./src/util/geom.ts","webpack://neuroglancer/./src/util/google_tag_manager.ts","webpack://neuroglancer/./src/util/http_request.ts","webpack://neuroglancer/./src/util/json.ts","webpack://neuroglancer/./src/util/matrix.ts","webpack://neuroglancer/./src/util/signal.ts","webpack://neuroglancer/./src/util/hex.ts","webpack://neuroglancer/./src/util/color.ts","webpack://neuroglancer/./src/util/data_type.ts","webpack://neuroglancer/./src/util/endian.ts","webpack://neuroglancer/./src/util/float.ts","webpack://neuroglancer/./src/util/lerp.ts","webpack://neuroglancer/./src/util/random.ts","webpack://neuroglancer/./src/annotation/index.ts","webpack://neuroglancer/./src/util/si_units.ts","webpack://neuroglancer/./src/util/vector.ts","webpack://neuroglancer/./src/coordinate_transform.ts","webpack://neuroglancer/./src/render_coordinate_transform.ts","webpack://neuroglancer/./src/chunk_manager/base.ts","webpack://neuroglancer/./src/util/framerate.ts","webpack://neuroglancer/./src/display_context.ts","webpack://neuroglancer/./src/projection_parameters.ts","webpack://neuroglancer/./src/util/message_list.ts","webpack://neuroglancer/./src/worker_rpc.ts","webpack://neuroglancer/./src/shared_watchable_value.ts","webpack://neuroglancer/./src/visibility_priority/frontend.ts","webpack://neuroglancer/./src/renderlayer.ts","webpack://neuroglancer/./src/trackable_boolean.ts","webpack://neuroglancer/./src/util/error.ts","webpack://neuroglancer/./src/util/watchable_map.ts","webpack://neuroglancer/./src/util/object_id.ts","webpack://neuroglancer/./src/webgl/shader.ts","webpack://neuroglancer/./src/webgl/dynamic_shader.ts","webpack://neuroglancer/./src/webgl/buffer.ts","webpack://neuroglancer/./src/webgl/square_corners_buffer.ts","webpack://neuroglancer/./src/webgl/texture.ts","webpack://neuroglancer/./src/webgl/trivial_shaders.ts","webpack://neuroglancer/./src/webgl/offscreen.ts","webpack://neuroglancer/./src/webgl/shader_lib.ts","webpack://neuroglancer/./src/webgl/empirical_cdf.ts","webpack://neuroglancer/./src/webgl/lerp.ts","webpack://neuroglancer/./src/util/trackable.ts","webpack://neuroglancer/./src/navigation_state.ts","webpack://neuroglancer/./src/util/hierarchical_map.ts","webpack://neuroglancer/./src/util/event_action_map.ts","webpack://neuroglancer/./src/util/mouse_bindings.ts","webpack://neuroglancer/./src/util/mouse_drag.ts","webpack://neuroglancer/./src/util/wheel_zoom.ts","webpack://neuroglancer/./src/webgl/quad.ts","webpack://neuroglancer/./src/webgl/lines.ts","webpack://neuroglancer/./src/webgl/rectangle_grid_buffer.ts","webpack://neuroglancer/./src/util/colorspace.ts","webpack://neuroglancer/./src/widget/color.ts","webpack://neuroglancer/./src/util/dom.ts","webpack://neuroglancer/./src/widget/icon.ts","webpack://neuroglancer/./src/widget/tab_view.ts","webpack://neuroglancer/./src/widget/invlerp.ts","webpack://neuroglancer/./src/widget/close_button.ts","webpack://neuroglancer/./src/status.ts","webpack://neuroglancer/./src/ui/tool.ts","webpack://neuroglancer/./src/util/clipboard.ts","webpack://neuroglancer/./src/util/keyboard_bindings.ts","webpack://neuroglancer/./src/widget/checkbox_icon.ts","webpack://neuroglancer/./src/widget/copy_button.ts","webpack://neuroglancer/./src/widget/dependent_view_widget.ts","webpack://neuroglancer/./src/widget/enum_widget.ts","webpack://neuroglancer/./src/widget/number_input_widget.ts","webpack://neuroglancer/./src/widget/position_plot.ts","webpack://neuroglancer/./src/widget/position_widget.ts","webpack://neuroglancer/./src/widget/transfer_function.ts","webpack://neuroglancer/./src/webgl/shader_ui_controls.ts","webpack://neuroglancer/./src/annotation/annotation_layer_state.ts","webpack://neuroglancer/./src/sliceview/base.ts","webpack://neuroglancer/./src/annotation/base.ts","webpack://neuroglancer/./src/webgl/colormaps.ts","webpack://neuroglancer/./src/annotation/type_handler.ts","webpack://neuroglancer/./src/chunk_manager/frontend.ts","webpack://neuroglancer/./src/segmentation_display_state/base.ts","webpack://neuroglancer/./src/render_scale_statistics.ts","webpack://neuroglancer/./src/sliceview/renderlayer.ts","webpack://neuroglancer/./src/sliceview/frontend.ts","webpack://neuroglancer/./src/annotation/frontend_source.ts","webpack://neuroglancer/./src/util/completion.ts","webpack://neuroglancer/./src/datasource/index.ts","webpack://neuroglancer/./src/layer/layer_data_source.ts","webpack://neuroglancer/./src/ui/side_panel_location.ts","webpack://neuroglancer/./src/ui/layer_side_panel_state.ts","webpack://neuroglancer/./src/util/signal_binding_updater.ts","webpack://neuroglancer/./src/layer/index.ts","webpack://neuroglancer/./src/layer/segmentation/json_keys.ts","webpack://neuroglancer/./src/widget/layer_control.ts","webpack://neuroglancer/./src/widget/layer_control_checkbox.ts","webpack://neuroglancer/./src/widget/layer_control_enum.ts","webpack://neuroglancer/./src/widget/range.ts","webpack://neuroglancer/./src/widget/layer_control_range.ts","webpack://neuroglancer/./src/util/number_to_string.ts","webpack://neuroglancer/./src/widget/render_scale_widget.ts","webpack://neuroglancer/./src/widget/layer_control_color.ts","webpack://neuroglancer/./src/widget/text_input.ts","webpack://neuroglancer/./src/widget/segmentation_color_mode.ts","webpack://neuroglancer/./src/layer/segmentation/layer_controls.ts","webpack://neuroglancer/./src/util/zorder.ts","webpack://neuroglancer/./src/mesh/multiscale.ts","webpack://neuroglancer/./src/perspective_view/render_layer.ts","webpack://neuroglancer/./src/gpu_hash/hash_table.ts","webpack://neuroglancer/./src/webgl/texture_access.ts","webpack://neuroglancer/./src/gpu_hash/shader.ts","webpack://neuroglancer/./src/segment_color.ts","webpack://neuroglancer/./src/ui/default_input_event_bindings.ts","webpack://neuroglancer/./src/ui/drag_and_drop.ts","webpack://neuroglancer/./src/ui/side_panel.ts","webpack://neuroglancer/./src/widget/move_to_button.ts","webpack://neuroglancer/./src/ui/selection_details.ts","webpack://neuroglancer/./src/widget/eye_button.ts","webpack://neuroglancer/./src/widget/filter_button.ts","webpack://neuroglancer/./src/widget/star_button.ts","webpack://neuroglancer/./src/segmentation_display_state/frontend.ts","webpack://neuroglancer/./src/mesh/frontend.ts","webpack://neuroglancer/./src/util/hash.ts","webpack://neuroglancer/./src/segmentation_display_state/property_map.ts","webpack://neuroglancer/./src/segmentation_graph/source.ts","webpack://neuroglancer/./src/shared_disjoint_sets.ts","webpack://neuroglancer/./src/segmentation_graph/local.ts","webpack://neuroglancer/./src/webgl/circles.ts","webpack://neuroglancer/./src/webgl/vertex_id.ts","webpack://neuroglancer/./src/skeleton/frontend.ts","webpack://neuroglancer/./src/sliceview/volume/base.ts","webpack://neuroglancer/./src/sliceview/volume/frontend.ts","webpack://neuroglancer/./src/sliceview/bounding_box_shader_helper.ts","webpack://neuroglancer/./src/sliceview/volume/renderlayer.ts","webpack://neuroglancer/./src/sliceview/volume/segmentation_renderlayer.ts","webpack://neuroglancer/./src/trackable_alpha.ts","webpack://neuroglancer/./src/webgl/bounding_box.ts","webpack://neuroglancer/./src/annotation/bounding_box.ts","webpack://neuroglancer/./src/annotation/line.ts","webpack://neuroglancer/./src/annotation/point.ts","webpack://neuroglancer/./src/webgl/ellipse.ts","webpack://neuroglancer/./src/webgl/spheres.ts","webpack://neuroglancer/./src/annotation/ellipsoid.ts","webpack://neuroglancer/./src/sliceview/wire_frame.ts","webpack://neuroglancer/./src/annotation/renderlayer.ts","webpack://neuroglancer/./src/widget/add_button.ts","webpack://neuroglancer/./src/widget/delete_button.ts","webpack://neuroglancer/./src/widget/virtual_list.ts","webpack://neuroglancer/./src/ui/annotations.ts","webpack://neuroglancer/./src/ui/segment_select_tools.ts","webpack://neuroglancer/./src/ui/segment_split_merge_tools.ts","webpack://neuroglancer/./src/ui/segment_list.ts","webpack://neuroglancer/./src/util/automatic_focus.ts","webpack://neuroglancer/./src/overlay.ts","webpack://neuroglancer/./src/widget/help_button.ts","webpack://neuroglancer/./src/widget/linked_layer.ts","webpack://neuroglancer/./src/widget/maximize_button.ts","webpack://neuroglancer/./src/widget/shader_code_widget.ts","webpack://neuroglancer/./src/widget/layer_control_channel_invlerp.ts","webpack://neuroglancer/./src/widget/layer_control_property_invlerp.ts","webpack://neuroglancer/./src/widget/shader_controls.ts","webpack://neuroglancer/./src/ui/segmentation_display_options_tab.ts","webpack://neuroglancer/./src/uint64_map.ts","webpack://neuroglancer/./src/uint64_ordered_set.ts","webpack://neuroglancer/./src/uint64_set.ts","webpack://neuroglancer/./src/layer/segmentation/index.ts","webpack://neuroglancer/./src/widget/coordinate_transform.ts","webpack://neuroglancer/./src/util/dropdown.ts","webpack://neuroglancer/./src/util/longest_common_prefix.ts","webpack://neuroglancer/./src/widget/multiline_autocomplete.ts","webpack://neuroglancer/./src/ui/layer_data_sources_tab.ts","webpack://neuroglancer/./src/widget/layer_reference.ts","webpack://neuroglancer/./src/layer/annotation/index.ts","webpack://neuroglancer/./src/trackable_blend.ts","webpack://neuroglancer/./src/sliceview/volume/image_renderlayer.ts","webpack://neuroglancer/./src/trackable_finite_float.ts","webpack://neuroglancer/./src/volume_rendering/trackable_volume_rendering_mode.ts","webpack://neuroglancer/./src/volume_rendering/base.ts","webpack://neuroglancer/./src/volume_rendering/volume_render_layer.ts","webpack://neuroglancer/./src/widget/channel_dimensions_widget.ts","webpack://neuroglancer/./src/layer/image/index.ts","webpack://neuroglancer/./src/credentials_provider/shared.ts","webpack://neuroglancer/./src/credentials_provider/chunk_source_frontend.ts","webpack://neuroglancer/./src/util/false.ts","webpack://neuroglancer/./src/util/s3_bucket_listing.ts","webpack://neuroglancer/./src/util/s3.ts","webpack://neuroglancer/./src/util/special_protocol_request.ts","webpack://neuroglancer/./src/webgl/index_emulation.ts","webpack://neuroglancer/./src/single_mesh/frontend.ts","webpack://neuroglancer/./src/layer/single_mesh/index.ts","webpack://neuroglancer/./src/datasource/boss/api.ts","webpack://neuroglancer/./src/datasource/boss/frontend.ts","webpack://neuroglancer/./src/datasource/default_provider.ts","webpack://neuroglancer/./src/datasource/boss/register_default.ts","webpack://neuroglancer/./src/credentials_provider/index.ts","webpack://neuroglancer/./src/credentials_provider/default_manager.ts","webpack://neuroglancer/./src/datasource/boss/credentials_provider.ts","webpack://neuroglancer/./src/datasource/boss/register_credentials_provider.ts","webpack://neuroglancer/./src/datasource/brainmaps/api.ts","webpack://neuroglancer/./src/datasource/brainmaps/frontend.ts","webpack://neuroglancer/./src/datasource/brainmaps/register_default.ts","webpack://neuroglancer/./src/util/google_oauth2.ts","webpack://neuroglancer/./src/datasource/brainmaps/credentials_provider.ts","webpack://neuroglancer/./src/datasource/brainmaps/register_credentials_provider.ts","webpack://neuroglancer/./src/datasource/dvid/api.ts","webpack://neuroglancer/./src/util/gcs_bucket_listing.ts","webpack://neuroglancer/./src/util/http_path_completion.ts","webpack://neuroglancer/./src/datasource/precomputed/frontend.ts","webpack://neuroglancer/./src/datasource/deepzoom/frontend.ts","webpack://neuroglancer/./src/datasource/deepzoom/register_default.ts","webpack://neuroglancer/./src/datasource/dvid/frontend.ts","webpack://neuroglancer/./src/datasource/dvid/register_default.ts","webpack://neuroglancer/./src/datasource/dvid/credentials_provider.ts","webpack://neuroglancer/./src/datasource/dvid/register_credentials_provider.ts","webpack://neuroglancer/./src/datasource/graphene/base.ts","webpack://neuroglancer/./src/widget/datetime.ts","webpack://neuroglancer/./src/datasource/graphene/frontend.ts","webpack://neuroglancer/./src/datasource/graphene/register_default.ts","webpack://neuroglancer/./src/datasource/middleauth/credentials_provider.ts","webpack://neuroglancer/./src/datasource/middleauth/register_credentials_provider.ts","webpack://neuroglancer/./src/datasource/n5/frontend.ts","webpack://neuroglancer/./src/datasource/n5/register_default.ts","webpack://neuroglancer/./src/datasource/ngauth/credentials_provider.ts","webpack://neuroglancer/./src/datasource/ngauth/register_credentials_provider.ts","webpack://neuroglancer/./src/datasource/nggraph/credentials_provider.ts","webpack://neuroglancer/./src/datasource/nggraph/frontend.ts","webpack://neuroglancer/./src/datasource/nggraph/register_default.ts","webpack://neuroglancer/./src/datasource/nifti/frontend.ts","webpack://neuroglancer/./src/datasource/nifti/register_default.ts","webpack://neuroglancer/./src/datasource/obj/frontend.ts","webpack://neuroglancer/./src/datasource/obj/register_default.ts","webpack://neuroglancer/./src/datasource/precomputed/register_default.ts","webpack://neuroglancer/./src/datasource/render/frontend.ts","webpack://neuroglancer/./src/datasource/render/register_default.ts","webpack://neuroglancer/./src/datasource/vtk/frontend.ts","webpack://neuroglancer/./src/datasource/vtk/register_default.ts","webpack://neuroglancer/./src/datasource/zarr/metadata/parse_util.ts","webpack://neuroglancer/./src/datasource/zarr/codec/resolve.ts","webpack://neuroglancer/./src/datasource/zarr/codec/blosc/resolve.ts","webpack://neuroglancer/./src/datasource/zarr/codec/zstd/resolve.ts","webpack://neuroglancer/./src/datasource/zarr/codec/bytes/resolve.ts","webpack://neuroglancer/./src/datasource/zarr/codec/crc32c/resolve.ts","webpack://neuroglancer/./src/datasource/zarr/codec/gzip/resolve.ts","webpack://neuroglancer/./src/datasource/zarr/metadata/index.ts","webpack://neuroglancer/./src/util/numpy_dtype.ts","webpack://neuroglancer/./src/datasource/zarr/metadata/parse.ts","webpack://neuroglancer/./src/datasource/zarr/codec/sharding_indexed/resolve.ts","webpack://neuroglancer/./src/datasource/zarr/codec/transpose/resolve.ts","webpack://neuroglancer/./src/datasource/zarr/ome.ts","webpack://neuroglancer/./src/datasource/zarr/frontend.ts","webpack://neuroglancer/./src/datasource/zarr/register_default.ts","webpack://neuroglancer/./src/ui/default_clipboard_handling.ts","webpack://neuroglancer/./src/ui/disable_default_actions.ts","webpack://neuroglancer/./src/sliceview/single_texture_chunk_format.ts","webpack://neuroglancer/./src/sliceview/uncompressed_chunk_format.ts","webpack://neuroglancer/./src/sliceview/compressed_segmentation/decode_common.ts","webpack://neuroglancer/./src/sliceview/compressed_segmentation/decode_uint32.ts","webpack://neuroglancer/./src/sliceview/compressed_segmentation/decode_uint64.ts","webpack://neuroglancer/./src/sliceview/compressed_segmentation/chunk_format.ts","webpack://neuroglancer/./src/sliceview/chunk_format_handlers.ts","webpack://neuroglancer/./src/layout.ts","webpack://neuroglancer/./src/axes_lines.ts","webpack://neuroglancer/./src/object_picking.ts","webpack://neuroglancer/./src/util/touch_bindings.ts","webpack://neuroglancer/./src/rendered_data_panel.ts","webpack://neuroglancer/./src/widget/scale_bar.ts","webpack://neuroglancer/./src/perspective_view/panel.ts","webpack://neuroglancer/./src/sliceview/panel.ts","webpack://neuroglancer/./src/widget/display_dimensions_widget.ts","webpack://neuroglancer/./src/data_panel_layout.ts","webpack://neuroglancer/./src/datasource/state_share.ts","webpack://neuroglancer/./src/help/input_event_bindings.ts","webpack://neuroglancer/./src/ui/context_menu.ts","webpack://neuroglancer/./src/util/drag_and_drop.ts","webpack://neuroglancer/./src/ui/layer_drag_and_drop.ts","webpack://neuroglancer/./src/ui/layer_bar.ts","webpack://neuroglancer/./src/ui/position_drag_and_drop.ts","webpack://neuroglancer/./src/layer_group_viewer.ts","webpack://neuroglancer/./src/layer_groups_layout.ts","webpack://neuroglancer/./src/ui/layer_side_panel.ts","webpack://neuroglancer/./src/ui/layer_list_panel.ts","webpack://neuroglancer/./src/ui/state_editor.ts","webpack://neuroglancer/./src/ui/statistics.ts","webpack://neuroglancer/./src/ui/viewer_settings.ts","webpack://neuroglancer/./src/widget/annotation_tool_status.ts","webpack://neuroglancer/./src/viewer.ts","webpack://neuroglancer/./src/ui/minimal_viewer.ts","webpack://neuroglancer/./src/ui/default_viewer.ts","webpack://neuroglancer/./src/ui/title.ts","webpack://neuroglancer/./src/ui/url_hash_binding.ts","webpack://neuroglancer/./src/ui/default_viewer_setup.ts","webpack://neuroglancer/./src/main.ts","webpack://neuroglancer/webpack/bootstrap","webpack://neuroglancer/webpack/runtime/chunk loaded","webpack://neuroglancer/webpack/runtime/compat get default export","webpack://neuroglancer/webpack/runtime/define property getters","webpack://neuroglancer/webpack/runtime/ensure chunk","webpack://neuroglancer/webpack/runtime/get javascript chunk filename","webpack://neuroglancer/webpack/runtime/get mini-css chunk filename","webpack://neuroglancer/webpack/runtime/hasOwnProperty shorthand","webpack://neuroglancer/webpack/runtime/make namespace object","webpack://neuroglancer/webpack/runtime/publicPath","webpack://neuroglancer/webpack/runtime/import chunk loading","webpack://neuroglancer/webpack/runtime/startup chunk dependencies","webpack://neuroglancer/webpack/startup"],"sourcesContent":["/**\n * @license\n * Copyright 2020 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Uint64 } from \"#src/util/uint64.js\";\n\nexport enum VisibleSegmentEquivalencePolicy {\n MIN_REPRESENTATIVE = 0, // defafult, representative elmement is the minimum element in equivalence set\n MAX_REPRESENTATIVE = 1, // representative elmement is the maximum element in equivalence set\n REPRESENTATIVE_EXCLUDED = 1 << 1, // filter out the representative element when iterating over visible segments\n NONREPRESENTATIVE_EXCLUDED = 1 << 2, // filter out non representative elements when iterating over visible segments\n}\n\n// Returns `true` if `segmentId` is a base segment id, rather than a segment id added to the graph.\nexport function isBaseSegmentId(segmentId: Uint64) {\n return segmentId.high >>> 31 ? false : true;\n}\n\nexport const UNKNOWN_NEW_SEGMENT_ID = new Uint64(0xffffffff, 0xffffffff);\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { debounce } from \"lodash-es\";\nimport type { Borrowed, Disposable, Owned } from \"#src/util/disposable.js\";\nimport { invokeDisposers, RefCounted } from \"#src/util/disposable.js\";\nimport type { NullaryReadonlySignal } from \"#src/util/signal.js\";\nimport { neverSignal, NullarySignal, Signal } from \"#src/util/signal.js\";\nimport type { Trackable } from \"#src/util/trackable.js\";\n\nexport interface WatchableValueInterface {\n value: T;\n changed: NullaryReadonlySignal;\n}\n\nexport interface WatchableValueChangeInterface {\n readonly value: T;\n readonly changed: Signal<(oldValue: T, newValue: T) => void>;\n}\n\nexport class WatchableValue implements WatchableValueInterface {\n get value() {\n return this.value_;\n }\n set value(newValue: T) {\n if (newValue !== this.value_) {\n this.value_ = newValue;\n this.changed.dispatch();\n }\n }\n changed = new NullarySignal();\n constructor(protected value_: T) {}\n}\n\nexport class TrackableValue extends WatchableValue implements Trackable {\n constructor(\n value: T,\n public validator: (value: any) => T,\n public defaultValue = value,\n ) {\n super(value);\n }\n toJSON(): any {\n const { value_ } = this;\n if (value_ === this.defaultValue) {\n return undefined;\n }\n return this.value_;\n }\n reset() {\n this.value = this.defaultValue;\n }\n restoreState(x: any) {\n if (x !== undefined) {\n const { validator } = this;\n try {\n this.value = validator(x);\n return;\n } catch {\n // Ignore invalid values in JSON representation.\n }\n }\n this.value = this.defaultValue;\n }\n}\n\nclass DerivedWatchableValue\n extends RefCounted\n implements WatchableValueInterface\n{\n changed = new NullarySignal();\n get value() {\n return this.f(...this.ws.map((w) => w.value));\n }\n private f: (...v: any[]) => U;\n private ws: WatchableValueInterface[];\n\n constructor(f: (...v: any[]) => U, ws: WatchableValueInterface[]) {\n super();\n this.f = f;\n this.ws = ws;\n for (const w of ws) {\n this.registerDisposer(w.changed.add(this.changed.dispatch));\n }\n }\n}\n\nexport function makeDerivedWatchableValue(\n f: (...v: T) => U,\n ...ws: { [K in keyof T]: WatchableValueInterface }\n) {\n return new DerivedWatchableValue(f, ws);\n}\n\nclass CachedLazyDerivedWatchableValue\n extends RefCounted\n implements WatchableValueInterface\n{\n changed = new NullarySignal();\n private value_: U | undefined;\n private valueGeneration = -1;\n get value() {\n const generation = this.changed.count;\n if (generation !== this.valueGeneration) {\n this.value_ = this.f(...this.ws.map((w) => w.value));\n this.valueGeneration = generation;\n }\n return this.value_ as U;\n }\n private f: (...v: any[]) => U;\n private ws: WatchableValueInterface[];\n\n constructor(f: (...v: any[]) => U, ws: WatchableValueInterface[]) {\n super();\n this.f = f;\n this.ws = ws;\n for (const w of ws) {\n this.registerDisposer(w.changed.add(this.changed.dispatch));\n }\n }\n}\n\nexport function makeCachedLazyDerivedWatchableValue(\n f: (...v: T) => U,\n ...ws: { [K in keyof T]: WatchableValueInterface }\n) {\n return new CachedLazyDerivedWatchableValue(f, ws);\n}\n\nexport class CachedWatchableValue\n extends RefCounted\n implements WatchableValueInterface\n{\n changed = new Signal();\n value: T;\n constructor(\n base: WatchableValueInterface,\n isEqual: (a: T, b: T) => boolean = (a, b) => a === b,\n ) {\n super();\n this.value = base.value;\n this.registerDisposer(\n base.changed.add(() => {\n const newValue = base.value;\n if (!isEqual(this.value, newValue)) {\n this.value = newValue;\n this.changed.dispatch();\n }\n }),\n );\n }\n}\n\nexport function makeCachedDerivedWatchableValue(\n f: (...v: T) => U,\n ws: { [K in keyof T]: WatchableValueInterface },\n isEqual?: (a: U, b: U) => boolean,\n) {\n const derived = new DerivedWatchableValue(f, ws);\n const cached = new CachedWatchableValue(derived, isEqual);\n cached.registerDisposer(derived);\n return cached;\n}\n\nexport class AggregateWatchableValue\n extends RefCounted\n implements WatchableValueInterface\n{\n changed = new NullarySignal();\n value: T;\n constructor(\n getWatchables: (self: RefCounted) => {\n [k in keyof T]: WatchableValueInterface;\n },\n ) {\n super();\n const watchables = getWatchables(this);\n const keys = Object.keys(watchables) as (keyof T)[];\n const updateValue = () => {\n const obj = (Array.isArray(watchables) ? [] : {}) as T;\n for (const k of keys) {\n obj[k] = watchables[k].value;\n }\n this.value = obj;\n this.changed.dispatch();\n };\n updateValue();\n for (const k of keys) {\n const watchable = watchables[k];\n // Ensure a unique function is used each time in case the same watchable is assigned to\n // multiple properties.\n this.registerDisposer(watchable.changed.add(() => updateValue()));\n }\n }\n}\n\nexport class ComputedWatchableValue\n extends RefCounted\n implements WatchableValueInterface\n{\n get value() {\n return this.f();\n }\n changed = new NullarySignal();\n constructor(\n public f: () => U,\n ...signals: NullarySignal[]\n ) {\n super();\n for (const signal of signals) {\n this.registerDisposer(signal.add(this.changed.dispatch));\n }\n }\n}\n\nexport class WatchableRefCounted\n extends RefCounted\n implements WatchableValueInterface\n{\n changed = new NullarySignal();\n\n private value_: Owned | undefined;\n private valueHandler: (() => void) | undefined;\n\n get value(): Borrowed | undefined {\n return this.value_;\n }\n\n set value(value: Owned | undefined) {\n const { value_ } = this;\n this.value_ = value;\n if (value_ !== undefined) {\n value_.dispose();\n value_.unregisterDisposer(this.valueHandler!);\n this.valueHandler = undefined;\n }\n if (value !== undefined) {\n const valueHandler = (this.valueHandler = () => {\n if (this.value_ === value) {\n this.value_ = undefined;\n this.changed.dispatch();\n }\n });\n value.registerDisposer(valueHandler);\n }\n\n if (value !== value_) {\n this.changed.dispatch();\n }\n }\n\n reset() {\n this.value = undefined;\n }\n\n disposed() {\n if (this.value_ !== undefined) {\n this.value_.unregisterDisposer(this.valueHandler!);\n this.value_.dispose();\n }\n this.value_ = undefined;\n super.disposed();\n }\n}\n\nexport interface TrackableValueInterface\n extends WatchableValueInterface,\n Trackable {}\n\nexport class TrackableRefCounted\n extends WatchableRefCounted\n implements TrackableValueInterface\n{\n constructor(\n public validator: (value: any) => T | undefined,\n public jsonConverter: (value: T) => any,\n ) {\n super();\n }\n toJSON() {\n const { value } = this;\n return value && this.jsonConverter(value);\n }\n\n restoreState(x: any) {\n this.value = this.validator(x);\n }\n}\n\nexport class WatchableSet {\n changed = new Signal<(x: T | null, add: boolean) => void>();\n values: Set;\n constructor(values?: Iterable) {\n if (values === undefined) {\n this.values = new Set();\n } else {\n this.values = new Set(values);\n }\n }\n add(x: T) {\n const { values } = this;\n if (!values.has(x)) {\n values.add(x);\n this.changed.dispatch(x, true);\n }\n return this;\n }\n delete(x: T) {\n const { values } = this;\n if (values.delete(x)) {\n this.changed.dispatch(x, false);\n return true;\n }\n return false;\n }\n has(x: T) {\n return this.values.has(x);\n }\n get size() {\n return this.values.size;\n }\n [Symbol.iterator]() {\n return this.values[Symbol.iterator]();\n }\n clear() {\n const { values } = this;\n if (values.size > 0) {\n values.clear();\n this.changed.dispatch(null, false);\n }\n }\n}\n\nexport interface NestedStateManager extends Disposable {\n flush: () => void;\n value: T;\n}\n\nexport function registerNested(\n f: (context: RefCounted, ...values: T) => U,\n ...watchables: { [K in keyof T]: WatchableValueInterface }\n): NestedStateManager {\n const values = watchables.map((w) => w.value) as T;\n const count = watchables.length;\n let context = new RefCounted();\n let result = f(context, ...values);\n\n const handleChange = debounce(() => {\n let changed = false;\n for (let i = 0; i < count; ++i) {\n const watchable = watchables[i];\n const value = watchable.value;\n if (values[i] !== value) {\n values[i] = value;\n changed = true;\n }\n }\n if (!changed) return;\n context.dispose();\n context = new RefCounted();\n result = f(context, ...values);\n }, 0);\n\n const signalDisposers = watchables.map((w) => w.changed.add(handleChange));\n\n return {\n flush() {\n handleChange.flush();\n },\n dispose() {\n handleChange.cancel();\n invokeDisposers(signalDisposers);\n context.dispose();\n },\n get value() {\n handleChange.flush();\n return result;\n },\n };\n}\n\nexport function registerNestedSync(\n f: (context: RefCounted, ...values: T) => U,\n ...watchables: { [K in keyof T]: WatchableValueInterface }\n): { readonly value: U; dispose(): void } {\n const values = watchables.map((w) => w.value) as T;\n const count = watchables.length;\n let context = new RefCounted();\n let result = f(context, ...values);\n\n const handleChange = () => {\n let changed = false;\n for (let i = 0; i < count; ++i) {\n const watchable = watchables[i];\n const value = watchable.value;\n if (values[i] !== value) {\n values[i] = value;\n changed = true;\n }\n }\n if (!changed) return;\n context.dispose();\n context = new RefCounted();\n result = f(context, ...values);\n };\n\n const signalDisposers = watchables.map((w) => w.changed.add(handleChange));\n\n return {\n dispose() {\n invokeDisposers(signalDisposers);\n context.dispose();\n },\n get value() {\n return result;\n },\n };\n}\n\nexport function constantWatchableValue(\n value: T,\n): WatchableValueInterface {\n return { changed: neverSignal, value };\n}\n\nexport function observeWatchable(\n callback: (value: T) => void,\n watchable: WatchableValueInterface,\n) {\n callback(watchable.value);\n return watchable.changed.add(() => callback(watchable.value));\n}\n\nexport function linkWatchableValue(\n source: WatchableValueInterface,\n target: WatchableValueInterface,\n) {\n target.value = source.value;\n return source.changed.add(() => {\n target.value = source.value;\n });\n}\n\nexport class IndirectWatchableValue\n implements Disposable, WatchableValueInterface\n{\n protected inner: WatchableValueInterface;\n changed = new NullarySignal();\n disposer: (() => void) | undefined;\n private update = () => {\n const { disposer, outer } = this;\n if (disposer !== undefined) {\n disposer();\n }\n const inner = (this.inner = this.getInner(outer.value));\n this.disposer = inner.changed.add(this.changed.dispatch);\n this.changed.dispatch();\n };\n constructor(\n private outer: WatchableValueInterface,\n private getInner: (outer: U) => WatchableValueInterface,\n ) {\n outer.changed.add(this.update);\n this.update();\n }\n\n dispose() {\n this.outer.changed.remove(this.update);\n this.disposer!();\n }\n\n get value() {\n return this.inner.value;\n }\n set value(value: T) {\n this.inner.value = value;\n }\n}\n\nexport class IndirectTrackableValue\n extends IndirectWatchableValue\n implements Trackable\n{\n declare inner: TrackableValueInterface;\n reset() {\n this.inner.reset();\n }\n restoreState(obj: unknown) {\n this.inner.restoreState(obj);\n }\n toJSON() {\n return this.inner.toJSON();\n }\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface WritableArrayLike {\n length: number;\n [n: number]: T;\n}\n\n/**\n * Partitions array[start:end] such that all elements for which predicate\n * returns true are before the elements for which predicate returns false.\n *\n * predicate will be called exactly once for each element in array[start:end],\n * in order.\n *\n * @returns {number} The index of the first element for which predicate returns\n * false, or end if there is no such element.\n */\nexport function partitionArray(\n array: T[],\n start: number,\n end: number,\n predicate: (x: T) => boolean,\n): number {\n while (start < end) {\n const x = array[start];\n if (predicate(x)) {\n ++start;\n continue;\n }\n --end;\n array[start] = array[end];\n array[end] = x;\n }\n return end;\n}\n\nexport function filterArrayInplace(\n array: T[],\n predicate: (x: T, index: number, array: T[]) => boolean,\n) {\n const length = array.length;\n let outIndex = 0;\n for (let i = 0; i < length; ++i) {\n if (predicate(array[i], i, array)) {\n array[outIndex] = array[i];\n ++outIndex;\n }\n }\n array.length = outIndex;\n}\n\nexport type TypedArrayConstructor =\n | typeof Int8Array\n | typeof Uint8Array\n | typeof Int16Array\n | typeof Uint16Array\n | typeof Int32Array\n | typeof Uint32Array\n | typeof Float32Array\n | typeof Float64Array;\n\nexport type TypedArray =\n | Int8Array\n | Uint8Array\n | Int16Array\n | Uint16Array\n | Int32Array\n | Uint32Array\n | Float32Array\n | Float64Array;\n\n/**\n * Returns an array of size newSize that starts with the contents of array.\n * Either returns array if it has the correct size, or a new array with zero\n * padding at the end.\n */\nexport function maybePadArray(\n array: T,\n newSize: number,\n): T {\n if (array.length === newSize) {\n return array;\n }\n const newArray = new (array.constructor)(newSize);\n newArray.set(array);\n return newArray;\n}\n\nexport function getFortranOrderStrides(\n size: ArrayLike,\n baseStride = 1,\n) {\n const length = size.length;\n const strides = new Array(length);\n let stride = (strides[0] = baseStride);\n for (let i = 1; i < length; ++i) {\n stride *= size[i - 1];\n strides[i] = stride;\n }\n return strides;\n}\n\n/**\n * Converts an array of shape [majorSize, minorSize] to\n * [minorSize, majorSize].\n */\nexport function transposeArray2d(\n array: T,\n majorSize: number,\n minorSize: number,\n): T {\n const transpose = new (array.constructor)(array.length);\n for (let i = 0; i < majorSize * minorSize; i += minorSize) {\n for (let j = 0; j < minorSize; j++) {\n const index: number = i / minorSize;\n transpose[j * majorSize + index] = array[i + j];\n }\n }\n return transpose;\n}\n\nexport function tile2dArray(\n array: T,\n majorDimension: number,\n minorTiles: number,\n majorTiles: number,\n) {\n const minorDimension = array.length / majorDimension;\n const length = array.length * minorTiles * majorTiles;\n const result: T = new (array.constructor)(length);\n const minorTileStride = array.length * majorTiles;\n const majorTileStride = majorDimension;\n const minorStride = majorDimension * majorTiles;\n for (let minor = 0; minor < minorDimension; ++minor) {\n for (let major = 0; major < majorDimension; ++major) {\n const inputValue = array[minor * majorDimension + major];\n const baseOffset = minor * minorStride + major;\n for (let minorTile = 0; minorTile < minorTiles; ++minorTile) {\n for (let majorTile = 0; majorTile < majorTiles; ++majorTile) {\n result[\n minorTile * minorTileStride +\n majorTile * majorTileStride +\n baseOffset\n ] = inputValue;\n }\n }\n }\n }\n return result;\n}\n\nexport function binarySearch(\n haystack: ArrayLike,\n needle: T,\n compare: (a: T, b: T) => number,\n low = 0,\n high = haystack.length,\n) {\n while (low < high) {\n const mid = (low + high - 1) >> 1;\n const compareResult = compare(needle, haystack[mid]);\n if (compareResult > 0) {\n low = mid + 1;\n } else if (compareResult < 0) {\n high = mid;\n } else {\n return mid;\n }\n }\n return ~low;\n}\n\n/**\n * Returns the index of the element in `haystack` that is closest to `needle`, according to\n * `compare`. If there are multiple elements that are equally close, the index of the first such\n * element encountered is returned. If `haystack` is empty, returns -1.\n */\nexport function findClosestMatchInSortedArray(\n haystack: ArrayLike,\n needle: T,\n compare: (a: T, b: T) => number,\n low = 0,\n high = haystack.length,\n): number {\n let bestIndex = -1;\n let bestDistance = Infinity;\n while (low < high) {\n const mid = (low + high - 1) >> 1;\n const compareResult = compare(needle, haystack[mid]);\n if (compareResult > 0) {\n low = mid + 1;\n } else if (compareResult < 0) {\n high = mid;\n } else {\n return mid;\n }\n const distance = Math.abs(compareResult);\n if (distance < bestDistance) {\n bestDistance = distance;\n bestIndex = mid;\n }\n }\n return bestIndex;\n}\n\n/**\n * Returns the first index in `[begin, end)` for which `predicate` is `true`, or returns `end` if no\n * such index exists.\n *\n * For any index `i` in `(begin, end)`, it must be the case that `predicate(i) >= predicate(i - 1)`.\n */\nexport function binarySearchLowerBound(\n begin: number,\n end: number,\n predicate: (index: number) => boolean,\n): number {\n let count = end - begin;\n while (count > 0) {\n const step = Math.floor(count / 2);\n const i = begin + step;\n if (predicate(i)) {\n count = step;\n } else {\n begin = i + 1;\n count -= step + 1;\n }\n }\n return begin;\n}\n\n/**\n * Returns an array of indices into `input` that equal (under `===`) `value`.\n */\nexport function findMatchingIndices(input: T[], value: T) {\n const out: number[] = [];\n for (let i = 0, length = input.length; i < length; ++i) {\n if (input[i] === value) {\n out.push(i);\n }\n }\n return out;\n}\n\n/**\n * Returns an array of the indices in `[0, ..., max)` not in `indices`.\n */\nexport function getIndicesComplement(indices: number[], max: number) {\n const mask: boolean[] = [];\n mask.length = max;\n for (const i of indices) {\n mask[i] = true;\n }\n return findMatchingIndices(mask, undefined);\n}\n\nexport function arraysEqual(a: ArrayLike, b: ArrayLike) {\n const length = a.length;\n if (b.length !== length) return false;\n for (let i = 0; i < length; ++i) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n}\n\nexport function arraysEqualWithPredicate(\n a: ArrayLike,\n b: ArrayLike,\n elementsEqual: (a: T, b: T) => boolean = (a, b) => a === b,\n) {\n const length = a.length;\n if (b.length !== length) return false;\n for (let i = 0; i < length; ++i) {\n if (!elementsEqual(a[i], b[i])) return false;\n }\n return true;\n}\n\nexport function getInsertPermutation(\n n: number,\n sourceIndex: number,\n targetIndex: number,\n) {\n const newToOld: number[] = [];\n if (targetIndex === sourceIndex) {\n for (let i = 0; i < n; ++i) {\n newToOld[i] = i;\n }\n return newToOld;\n }\n newToOld[targetIndex] = sourceIndex;\n for (let oldDim = 0, newDim = 0; oldDim < n; ) {\n if (oldDim === sourceIndex) {\n ++oldDim;\n continue;\n }\n if (newDim === targetIndex) {\n ++newDim;\n }\n newToOld[newDim++] = oldDim++;\n }\n return newToOld;\n}\n\nexport function scatterUpdate<\n T,\n Dest extends { [index: number]: T },\n Source extends { readonly [index: number]: T },\n>(dest: Dest, source: Source, indices: ArrayLike): Dest {\n for (\n let sourceIndex = 0, length = indices.length;\n sourceIndex < length;\n ++sourceIndex\n ) {\n const destIndex = indices[sourceIndex];\n if (destIndex === -1) continue;\n dest[destIndex] = source[sourceIndex];\n }\n return dest;\n}\n\nexport function gatherUpdate<\n T,\n Dest extends { [index: number]: T },\n Source extends { readonly [index: number]: T },\n>(dest: Dest, source: Source, indices: ArrayLike): Dest {\n for (\n let destIndex = 0, length = indices.length;\n destIndex < length;\n ++destIndex\n ) {\n const sourceIndex = indices[destIndex];\n if (sourceIndex === -1) continue;\n dest[destIndex] = source[sourceIndex];\n }\n return dest;\n}\n\nexport function transposeNestedArrays(x: T[][]) {\n const result: T[][] = [];\n for (\n let outerIndex = 0, outerLength = x.length;\n outerIndex < outerLength;\n ++outerIndex\n ) {\n const inner = x[outerIndex];\n for (\n let innerIndex = 0, innerLength = inner.length;\n innerIndex < innerLength;\n ++innerIndex\n ) {\n let resultInner = result[innerIndex];\n if (resultInner === undefined) {\n resultInner = result[innerIndex] = [];\n }\n resultInner.push(inner[innerIndex]);\n }\n }\n return result;\n}\n\nexport interface ArraySpliceOp {\n retainCount: number;\n deleteCount: number;\n insertCount: number;\n}\n\nexport function spliceArray(\n array: T[],\n splices: readonly Readonly[],\n) {\n const parts: T[][] = [];\n let origOffset = 0;\n for (let i = 0, numSplices = splices.length; i < numSplices; ++i) {\n const { retainCount, deleteCount, insertCount } = splices[i];\n if (retainCount !== 0) {\n parts.push(array.slice(origOffset, origOffset + retainCount));\n origOffset += retainCount;\n }\n origOffset += deleteCount;\n if (insertCount !== 0) {\n parts.push(new Array(insertCount));\n }\n }\n const origLength = array.length;\n if (origOffset !== origLength) {\n parts.push(array.slice(origOffset));\n }\n return new Array(0).concat(...parts);\n}\n\nexport function getMergeSplices(\n oldArray: readonly T[],\n newArray: readonly T[],\n compare: (a: T, b: T) => number,\n): ArraySpliceOp[] {\n const splices: ArraySpliceOp[] = [];\n let oldIndex = 0;\n let newIndex = 0;\n const oldCount = oldArray.length;\n const newCount = newArray.length;\n while (oldIndex < oldCount && newIndex < newCount) {\n let c: number;\n const oldValue = oldArray[oldIndex];\n const newValue = newArray[newIndex];\n c = compare(oldValue, newValue);\n if (c === 0) {\n let retainCount = 1;\n ++oldIndex;\n ++newIndex;\n while (\n oldIndex < oldCount &&\n newIndex < newCount &&\n (c = compare(oldArray[oldIndex], newArray[newIndex])) === 0\n ) {\n ++retainCount;\n ++oldIndex;\n ++newIndex;\n }\n splices.push({ retainCount, deleteCount: 0, insertCount: 0 });\n continue;\n }\n if (c < 0) {\n let deleteCount = 1;\n while (\n ++oldIndex < oldCount &&\n (c = compare(oldArray[oldIndex], newValue)) < 0\n ) {\n ++deleteCount;\n }\n splices.push({ retainCount: 0, deleteCount, insertCount: 0 });\n continue;\n }\n if (c > 0) {\n let insertCount = 1;\n while (\n ++newIndex < newCount &&\n (c = compare(oldValue, newArray[newIndex])) > 0\n ) {\n ++insertCount;\n }\n splices.push({ retainCount: 0, deleteCount: 0, insertCount });\n }\n }\n if (oldIndex < oldCount || newIndex < newCount) {\n splices.push({\n retainCount: 0,\n deleteCount: oldCount - oldIndex,\n insertCount: newCount - newIndex,\n });\n }\n return splices;\n}\n\nexport function getFixedOrderMergeSplices(\n oldArray: readonly T[],\n newArray: readonly T[],\n equal: (a: T, b: T) => boolean,\n): ArraySpliceOp[] {\n const splices: ArraySpliceOp[] = [];\n let oldIndex = 0;\n let newIndex = 0;\n const oldCount = oldArray.length;\n const newCount = newArray.length;\n while (oldIndex < oldCount) {\n let retainCount = 0;\n while (\n oldIndex < oldCount &&\n newIndex < newCount &&\n equal(oldArray[oldIndex], newArray[newIndex])\n ) {\n ++retainCount;\n ++oldIndex;\n ++newIndex;\n }\n if (retainCount !== 0) {\n splices.push({ retainCount, deleteCount: 0, insertCount: 0 });\n }\n let deleteCount = 0;\n while (\n oldIndex < oldCount &&\n (newIndex === newCount || !equal(oldArray[oldIndex], newArray[newIndex]))\n ) {\n ++deleteCount;\n ++oldIndex;\n }\n if (deleteCount !== 0) {\n splices.push({ retainCount: 0, deleteCount, insertCount: 0 });\n }\n }\n if (newIndex !== newCount) {\n splices.push({\n retainCount: 0,\n deleteCount: 0,\n insertCount: newCount - newIndex,\n });\n }\n return splices;\n}\n\nexport function mergeSequences(\n aCount: number,\n bCount: number,\n compare: (a: number, b: number) => number,\n aCallback: (a: number) => void,\n bCallback: (b: number) => void,\n abCallback: (a: number, b: number) => void,\n) {\n let a = 0;\n let b = 0;\n if (aCount !== 0 && bCount !== 0) {\n while (true) {\n const x = compare(a, b);\n if (x < 0) {\n aCallback(a);\n if (++a === aCount) break;\n } else if (x > 0) {\n bCallback(b);\n if (++b === bCount) break;\n } else {\n abCallback(a, b);\n ++a;\n ++b;\n if (a === aCount || b === bCount) break;\n }\n }\n }\n while (a < aCount) {\n aCallback(a);\n ++a;\n }\n while (b < bCount) {\n bCallback(b);\n ++b;\n }\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @file\n * Cancellation token system with similarity to the cancellation_token in Microsoft's PPL.\n */\n\n/**\n * Interface used by cancelable operations to monitor whether cancellation has occurred.\n *\n * Note that this interface does not provide any way to trigger cancellation; for that,\n * CancellationTokenSource is used.\n */\nexport interface CancellationToken {\n /**\n * Indicates whether cancellation has occurred.\n */\n readonly isCanceled: boolean;\n\n /**\n * Add a cancellation handler function. The handler will be invoked synchronously if\n * this.isCanceled === true. Otherwise, it will be invoked synchronously upon cancellation,\n * unless it is removed prior to cancellation.\n *\n * The handler function must not throw any exceptions when called.\n *\n * @precondition The handler function must not already be registered.\n *\n * @param handler The handler function to add.\n *\n * @return A function that unregisters the handler.\n */\n add(handler: () => void): () => void;\n\n /**\n * Unregister a cancellation handler function. If this.isCanceled, or the specified handler\n * function has not been registered, then this function has no effect.\n */\n remove(handler: () => void): void;\n}\n\nexport class CancellationError extends Error {\n name = \"CancellationError\";\n message = \"CANCELED\";\n toString() {\n return \"CANCELED\";\n }\n}\n\n/**\n * Singleton instance of CancellationError thrown to indicate cancellation.\n */\nexport const CANCELED = new CancellationError();\n\n/**\n * Throws CANCELED if token.isCanceled === true.\n */\nexport function throwIfCanceled(token: CancellationToken) {\n if (token.isCanceled === true) {\n throw CANCELED;\n }\n}\n\nconst noopFunction = () => {};\n\n/**\n * CancellationToken that cannot be canceled. This can be passed to operations that require a\n * CancellationToken but will not need to be canceled.\n */\nexport const uncancelableToken: CancellationToken = {\n isCanceled: false,\n add: () => noopFunction,\n remove: noopFunction,\n};\n\n/**\n * Class that can be used to trigger cancellation.\n */\nexport class CancellationTokenSource implements CancellationToken {\n /**\n * Trigger cancellation.\n *\n * If this.isCanceled === false, then each registered cancellation handler is invoked\n * synchronously.\n */\n cancel() {\n const { handlers } = this;\n if (handlers !== null) {\n this.handlers = null;\n if (handlers !== undefined) {\n for (const handler of handlers) {\n handler();\n }\n }\n }\n }\n\n get isCanceled() {\n return this.handlers === null;\n }\n\n private handlers: Set<() => void> | undefined | null;\n\n add(handler: () => void) {\n let { handlers } = this;\n if (handlers === null) {\n handler();\n return noopFunction;\n }\n if (handlers === undefined) {\n handlers = this.handlers = new Set<() => void>();\n }\n handlers.add(handler);\n return () => {\n this.remove(handler);\n };\n }\n\n remove(handler: () => void) {\n const { handlers } = this;\n if (handlers != null) {\n handlers.delete(handler);\n }\n }\n}\n\n/**\n * Creates a CancellationToken corresponding to an asynchronous process with multiple consumers. It\n * is cancelled only when the cancellation tokens corresponding to all of the consumers have been\n * cancelled.\n */\nexport class MultipleConsumerCancellationTokenSource extends CancellationTokenSource {\n private consumers = new Set();\n\n addConsumer(cancellationToken: CancellationToken = uncancelableToken) {\n const { consumers } = this;\n if (consumers.has(cancellationToken) || cancellationToken.isCanceled) {\n return;\n }\n consumers.add(cancellationToken);\n cancellationToken.add(() => {\n consumers.delete(cancellationToken);\n if (consumers.size === 0) {\n this.cancel();\n }\n });\n }\n}\n\n/**\n * Creates a promise and a dependent cancellation token.\n *\n * The dependent cancellation token will be canceled if the specified `cancellationToken` is\n * canceled while the promise is pending.\n *\n * @param cancellationToken The token that provides notification of cancellation.\n * @param executor The executor passed the resolve and reject functions for the promise, as well as\n * the dependent cancellation token. If cancellation occurs after either resolve or reject is\n * called, then the dependent token is not cancelled.\n *\n * @returns A new Promise.\n */\nexport function makeCancelablePromise(\n cancellationToken: CancellationToken,\n executor: (\n resolve: (value: T | Promise) => void,\n reject: (error: any) => void,\n token: CancellationToken,\n ) => void,\n) {\n return new Promise((resolve, reject) => {\n if (cancellationToken === uncancelableToken) {\n executor(resolve, reject, uncancelableToken);\n return;\n }\n const scopedToken = new CancellationTokenSource();\n const unregister = cancellationToken.add(() => {\n scopedToken.cancel();\n });\n executor(\n (value) => {\n unregister();\n resolve(value);\n },\n (error) => {\n unregister();\n reject(error);\n },\n scopedToken,\n );\n });\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface Disposable {\n dispose: () => void;\n}\n\nexport type Disposer = Disposable | (() => void);\n\nconst DEBUG_REF_COUNTS = false;\n\nexport function invokeDisposer(disposer: Disposer) {\n if (typeof disposer === \"object\") {\n disposer.dispose();\n } else {\n disposer();\n }\n}\n\nexport function invokeDisposers(disposers: Disposer[]) {\n for (let i = disposers.length; i > 0; --i) {\n invokeDisposer(disposers[i - 1]);\n }\n}\n\nexport function registerEventListener(\n target: EventTarget,\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions,\n) {\n target.addEventListener(type, listener, options);\n return () => target.removeEventListener(type, listener, options);\n}\n\nexport class RefCounted implements Disposable {\n public refCount = 1;\n wasDisposed: boolean | undefined;\n private disposers: Disposer[];\n addRef() {\n ++this.refCount;\n return this;\n }\n disposedStacks: any;\n dispose() {\n if (DEBUG_REF_COUNTS) {\n (this.disposedStacks = this.disposedStacks || []).push(new Error().stack);\n }\n if (--this.refCount !== 0) {\n return;\n }\n this.refCountReachedZero();\n }\n\n protected refCountReachedZero() {\n this.disposed();\n const { disposers } = this;\n if (disposers !== undefined) {\n invokeDisposers(disposers);\n this.disposers = undefined;\n }\n this.wasDisposed = true;\n }\n disposed() {}\n registerDisposer(f: T): T {\n const { disposers } = this;\n if (disposers == null) {\n this.disposers = [f];\n } else {\n disposers.push(f);\n }\n return f;\n }\n unregisterDisposer(f: T): T {\n const { disposers } = this;\n if (disposers != null) {\n const index = disposers.indexOf(f);\n if (index !== -1) {\n disposers.splice(index, 1);\n }\n }\n return f;\n }\n registerEventListener(\n target: EventTarget,\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ) {\n this.registerDisposer(\n registerEventListener(target, type, listener, options),\n );\n }\n registerCancellable void }>(cancellable: T) {\n this.registerDisposer(() => {\n cancellable.cancel();\n });\n return cancellable;\n }\n}\n\nexport class RefCountedValue extends RefCounted {\n constructor(public value: T) {\n super();\n }\n}\n\n/**\n * A variable of this type is associated with an increment of the reference count. If a function\n * parameter is declared with this type, then callers must donate a reference count.\n */\nexport type Owned = T;\n\n/**\n * A variable of this type is not associated with an increment of the reference count.\n */\nexport type Borrowed = T;\n\nexport function disposableOnce(value: Disposer | undefined) {\n return () => {\n if (value !== undefined) {\n const x = value;\n value = undefined;\n invokeDisposer(x);\n }\n };\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { mat3 } from \"gl-matrix\";\nimport { mat4, quat, vec3, vec4 } from \"gl-matrix\";\nimport type { TypedArray } from \"#src/util/array.js\";\nimport { findMatchingIndices } from \"#src/util/array.js\";\n\nexport { mat2, mat3, mat4, quat, vec2, vec3, vec4 } from \"gl-matrix\";\n\nexport const identityMat4 = mat4.create();\n\nexport const AXES_NAMES = [\"x\", \"y\", \"z\"];\n\nexport const kAxes = [\n vec3.fromValues(1, 0, 0),\n vec3.fromValues(0, 1, 0),\n vec3.fromValues(0, 0, 1),\n];\nexport const kZeroVec = vec3.fromValues(0, 0, 0);\nexport const kZeroVec4 = vec4.fromValues(0, 0, 0, 0);\nexport const kOneVec = vec3.fromValues(1, 1, 1);\nexport const kInfinityVec = vec3.fromValues(Infinity, Infinity, Infinity);\nexport const kIdentityQuat = quat.create();\n\nexport function prod3(x: ArrayLike) {\n return x[0] * x[1] * x[2];\n}\n\nexport function prod4(x: ArrayLike) {\n return x[0] * x[1] * x[2] * x[3];\n}\n\n/**\n * Implements a one-to-one conversion from Vec3 to string, suitable for use a Map key.\n *\n * Specifically, returns the string representation of the 3 values separated by commas.\n */\nexport function vec3Key(x: ArrayLike) {\n return `${x[0]},${x[1]},${x[2]}`;\n}\n\n/**\n * Transforms `a` by a 180-degree rotation about X, stores result in `out`.\n */\nexport function quatRotateX180(out: quat, a: quat) {\n const x = a[0];\n const y = a[1];\n const z = a[2];\n const w = a[3];\n out[0] = w;\n out[1] = z;\n out[2] = -y;\n out[3] = -x;\n}\n\n/**\n * Transforms `a` by a 180-degree rotation about Y, stores result in `out`.\n */\nexport function quatRotateY180(out: quat, a: quat) {\n const x = a[0];\n const y = a[1];\n const z = a[2];\n const w = a[3];\n out[0] = -z;\n out[1] = w;\n out[2] = x;\n out[3] = -y;\n}\n\n/**\n * Transforms `a` by a 180-degree rotation about Z, stores result in `out`.\n */\nexport function quatRotateZ180(out: quat, a: quat) {\n const x = a[0];\n const y = a[1];\n const z = a[2];\n const w = a[3];\n out[0] = y;\n out[1] = -x;\n out[2] = w;\n out[3] = -z;\n}\n\n/**\n * Transforms a vector `a` by a homogenous transformation matrix `m`. The translation component of\n * `m` is ignored.\n */\nexport function transformVectorByMat4(out: vec3, a: vec3, m: mat4) {\n const x = a[0];\n const y = a[1];\n const z = a[2];\n out[0] = m[0] * x + m[4] * y + m[8] * z;\n out[1] = m[1] * x + m[5] * y + m[9] * z;\n out[2] = m[2] * x + m[6] * y + m[10] * z;\n return out;\n}\n\n/**\n * Transforms a vector `a` by the transpose of a homogenous transformation matrix `m`. The\n * translation component of `m` is ignored.\n */\nexport function transformVectorByMat4Transpose(out: vec3, a: vec3, m: mat4) {\n const x = a[0];\n const y = a[1];\n const z = a[2];\n out[0] = m[0] * x + m[1] * y + m[2] * z;\n out[1] = m[4] * x + m[5] * y + m[6] * z;\n out[2] = m[8] * x + m[9] * y + m[10] * z;\n return out;\n}\n\nexport function translationRotationScaleZReflectionToMat4(\n out: mat4,\n translation: vec3,\n rotation: quat,\n scale: vec3,\n zReflection: number,\n) {\n const temp: Float32Array = out;\n out[0] = scale[0];\n out[1] = scale[1];\n out[2] = scale[2] * zReflection;\n return mat4.fromRotationTranslationScale(\n out,\n rotation,\n translation,\n temp,\n );\n}\n\n/**\n * Returns the value of `t` that minimizes `(p - (a + t * (b - a)))`.\n */\nexport function findClosestParameterizedLinePosition(\n a: Float32Array,\n b: Float32Array,\n p: Float32Array,\n) {\n // http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html\n // Compute t: -dot(a-p, b-a) / |b - a|^2\n const rank = p.length;\n let denominator = 0;\n for (let i = 0; i < rank; ++i) {\n denominator += (a[i] - b[i]) ** 2;\n }\n let numerator = 0;\n for (let i = 0; i < rank; ++i) {\n const aValue = a[i];\n numerator -= (aValue - p[i]) * (b[i] - aValue);\n }\n return numerator / Math.max(denominator, 1e-6);\n}\n\n/**\n * Sets `out` to the position on the line segment `[a, b]` closest to `p`.\n */\nexport function projectPointToLineSegment(\n out: Float32Array,\n a: Float32Array,\n b: Float32Array,\n p: Float32Array,\n) {\n const rank = out.length;\n let t = findClosestParameterizedLinePosition(a, b, p);\n t = Math.max(0.0, Math.min(1.0, t));\n for (let i = 0; i < rank; ++i) {\n const aValue = a[i];\n out[i] = aValue + t * (b[i] - aValue);\n }\n return out;\n}\n\nexport function mat3FromMat4(out: mat3, m: mat4) {\n const m00 = m[0];\n const m01 = m[1];\n const m02 = m[2];\n const m10 = m[4];\n const m11 = m[5];\n const m12 = m[6];\n const m20 = m[8];\n const m21 = m[9];\n const m22 = m[10];\n out[0] = m00;\n out[1] = m01;\n out[2] = m02;\n out[3] = m10;\n out[4] = m11;\n out[5] = m12;\n out[6] = m20;\n out[7] = m21;\n out[8] = m22;\n return out;\n}\n\n/**\n * Extracts the left, right, bottom, top, near, far clipping planes from `projectionMat`.\n * @param out Row-major array of shape `(6, 4)` specifying for each of the left, right, bottom, top,\n * near, far clipping planes the `a`, `b`, `c`, `d` coefficients such that\n * `0 < a * x + b * y + c * z + d` if the point `x, y, z` is inside the half-space of the\n * clipping plane.\n * @param m Projection matrix\n */\nexport function getFrustrumPlanes(out: Float32Array, m: mat4): Float32Array {\n // http://web.archive.org/web/20120531231005/http://crazyjoke.free.fr/doc/3D/plane%20extraction.pdf\n const m00 = m[0];\n const m10 = m[1];\n const m20 = m[2];\n const m30 = m[3];\n const m01 = m[4];\n const m11 = m[5];\n const m21 = m[6];\n const m31 = m[7];\n const m02 = m[8];\n const m12 = m[9];\n const m22 = m[10];\n const m32 = m[11];\n const m03 = m[12];\n const m13 = m[13];\n const m23 = m[14];\n const m33 = m[15];\n\n out[0] = m30 + m00; // left: a\n out[1] = m31 + m01; // left: b\n out[2] = m32 + m02; // left: c\n out[3] = m33 + m03; // left: d\n\n out[4] = m30 - m00; // right: a\n out[5] = m31 - m01; // right: b\n out[6] = m32 - m02; // right: c\n out[7] = m33 - m03; // right: d\n\n out[8] = m30 + m10; // bottom: a\n out[9] = m31 + m11; // bottom: b\n out[10] = m32 + m12; // bottom: c\n out[11] = m33 + m13; // bottom: d\n\n out[12] = m30 - m10; // top: a\n out[13] = m31 - m11; // top: b\n out[14] = m32 - m12; // top: c\n out[15] = m33 - m13; // top: d\n\n const nearA = m30 + m20; // near: a\n const nearB = m31 + m21; // near: b\n const nearC = m32 + m22; // near: c\n const nearD = m33 + m23; // near: d\n\n const farA = m30 - m20; // far: a\n const farB = m31 - m21; // far: b\n const farC = m32 - m22; // far: c\n const farD = m33 - m23; // far: d\n\n // Normalize near plane\n const nearNorm = Math.sqrt(nearA ** 2 + nearB ** 2 + nearC ** 2);\n out[16] = nearA / nearNorm;\n out[17] = nearB / nearNorm;\n out[18] = nearC / nearNorm;\n out[19] = nearD / nearNorm;\n\n // Also normalize far plane\n const farNorm = Math.sqrt(farA ** 2 + farB ** 2 + farC ** 2);\n out[20] = farA / farNorm;\n out[21] = farB / farNorm;\n out[22] = farC / farNorm;\n out[23] = farD / farNorm;\n\n return out;\n}\n\n/**\n * Checks whether the specified axis-aligned bounding box (AABB) intersects the view frustrum.\n *\n * @param clippingPlanes Array of length 24 specifying the clipping planes of the view frustrum, as\n * computed by `getFrustrumPlanes`\n */\nexport function isAABBVisible(\n xLower: number,\n yLower: number,\n zLower: number,\n xUpper: number,\n yUpper: number,\n zUpper: number,\n clippingPlanes: Float32Array,\n) {\n for (let i = 0; i < 6; ++i) {\n const a = clippingPlanes[i * 4];\n const b = clippingPlanes[i * 4 + 1];\n const c = clippingPlanes[i * 4 + 2];\n const d = clippingPlanes[i * 4 + 3];\n const sum =\n Math.max(a * xLower, a * xUpper) +\n Math.max(b * yLower, b * yUpper) +\n Math.max(c * zLower, c * zUpper) +\n d;\n if (sum < 0) {\n return false;\n }\n }\n return true;\n}\n\nexport function isAABBIntersectingPlane(\n xLower: number,\n yLower: number,\n zLower: number,\n xUpper: number,\n yUpper: number,\n zUpper: number,\n clippingPlanes: Float32Array,\n) {\n for (let i = 0; i < 4; ++i) {\n const a = clippingPlanes[i * 4];\n const b = clippingPlanes[i * 4 + 1];\n const c = clippingPlanes[i * 4 + 2];\n const d = clippingPlanes[i * 4 + 3];\n const sum =\n Math.max(a * xLower, a * xUpper) +\n Math.max(b * yLower, b * yUpper) +\n Math.max(c * zLower, c * zUpper) +\n d;\n if (sum < 0) {\n return false;\n }\n }\n {\n const i = 5;\n const a = clippingPlanes[i * 4];\n const b = clippingPlanes[i * 4 + 1];\n const c = clippingPlanes[i * 4 + 2];\n const d = clippingPlanes[i * 4 + 3];\n const maxSum =\n Math.max(a * xLower, a * xUpper) +\n Math.max(b * yLower, b * yUpper) +\n Math.max(c * zLower, c * zUpper);\n const minSum =\n Math.min(a * xLower, a * xUpper) +\n Math.min(b * yLower, b * yUpper) +\n Math.min(c * zLower, c * zUpper);\n const epsilon = Math.abs(d) * 1e-6;\n if (minSum > -d + epsilon || maxSum < -d - epsilon) return false;\n }\n return true;\n}\n\n/**\n * Returns the list (in sorted order) of input dimensions that depend on any of the specified output\n * dimensions.\n */\nexport function getDependentTransformInputDimensions(\n transform: Float32Array | Float64Array,\n rank: number,\n outputDimensions: readonly number[],\n transpose = false,\n): number[] {\n const numOutputDimensions = outputDimensions.length;\n const isDependentInputDimension: boolean[] = [];\n const inputStride = transpose ? 1 : rank + 1;\n const outputStride = transpose ? rank + 1 : 1;\n for (let i = 0; i < numOutputDimensions; ++i) {\n const outputDim = outputDimensions[i];\n for (let inputDim = 0; inputDim < rank; ++inputDim) {\n if (transform[inputDim * inputStride + outputDim * outputStride] !== 0) {\n isDependentInputDimension[inputDim] = true;\n }\n }\n }\n return findMatchingIndices(isDependentInputDimension, true);\n}\n\nexport function scaleMat3Input(out: mat3, input: mat3, scales: TypedArray) {\n for (let j = 0; j < 3; ++j) {\n const s = scales[j];\n for (let i = 0; i < 3; ++i) {\n out[i + j * 3] = s * input[i + j * 3];\n }\n }\n return out;\n}\n\nexport function scaleMat3Output(out: mat3, input: mat3, scales: TypedArray) {\n for (let i = 0; i < 3; ++i) {\n const s = scales[i];\n for (let j = 0; j < 3; ++j) {\n out[i + j * 3] = s * input[i + j * 3];\n }\n }\n return out;\n}\n\nexport function getViewFrustrumVolume(projectionMat: mat4) {\n if (projectionMat[15] === 1) {\n // orthographic projection\n const depth = 2 / Math.abs(projectionMat[10]);\n const width = 2 / Math.abs(projectionMat[0]);\n const height = 2 / Math.abs(projectionMat[5]);\n return width * height * depth;\n }\n // perspective projection\n // a = (far + near) / (near - far);\n // b = 2 * far * near / (near - far);\n const a = projectionMat[10];\n const b = projectionMat[14];\n const near = (2 * b) / (2 * a - 2);\n const far = ((a - 1) * near) / (a + 1);\n\n const baseArea = 4 / (projectionMat[0] * projectionMat[5]);\n return (baseArea / 3) * (Math.abs(far) ** 3 - Math.abs(near) ** 3);\n}\n\nexport function getViewFrustrumDepthRange(projectionMat: mat4) {\n if (projectionMat[15] === 1) {\n // orthographic projection\n const depth = 2 / Math.abs(projectionMat[10]);\n return depth;\n }\n // perspective projection\n // a = (far + near) / (near - far);\n // b = 2 * far * near / (near - far);\n const a = projectionMat[10];\n const b = projectionMat[14];\n const near = (2 * b) / (2 * a - 2);\n const far = ((a - 1) * near) / (a + 1);\n const depth = Math.abs(far - near);\n return depth;\n}\n\n// Ensures the z output is 0. Useful for disabling depth clipping.\nexport function disableZProjection(mat: mat4) {\n mat[2] = 0;\n mat[6] = 0;\n mat[10] = 0;\n mat[14] = 0;\n return mat;\n}\n\nconst tempVec3 = vec3.create();\n\n// Determines the bounding box in world coordinates of the view frustrum for a given view-projection\n// matrix.\n//\n// https://gamedev.stackexchange.com/questions/29999/how-do-i-create-a-bounding-frustum-from-a-view-projection-matrix\nexport function getViewFrustrumWorldBounds(\n invViewProjectionMat: mat4,\n bounds: Float32Array,\n) {\n bounds[0] = bounds[1] = bounds[2] = Number.POSITIVE_INFINITY;\n bounds[3] = bounds[4] = bounds[5] = Number.NEGATIVE_INFINITY;\n for (let i = 0; i < 8; ++i) {\n tempVec3[0] = 2 * (i & 1) - 1;\n tempVec3[1] = 2 * ((i >>> 1) & 1) - 1;\n tempVec3[2] = 2 * ((i >>> 2) & 1) - 1;\n vec3.transformMat4(tempVec3, tempVec3, invViewProjectionMat);\n for (let j = 0; j < 3; ++j) {\n const x = tempVec3[j];\n bounds[j] = Math.min(bounds[j], x);\n bounds[j + 3] = Math.max(bounds[j + 3], x);\n }\n }\n}\n","// Inject google tag manager script if `NEUROGLANCER_GOOGLE_TAG_MANAGER` is defined.\ndeclare const NEUROGLANCER_GOOGLE_TAG_MANAGER: string | undefined;\n\nif (typeof NEUROGLANCER_GOOGLE_TAG_MANAGER !== \"undefined\") {\n const l = \"dataLayer\";\n const i = NEUROGLANCER_GOOGLE_TAG_MANAGER;\n (window as any)[l] = (window as any)[l] || [];\n (window as any)[l].push({\n \"gtm.start\": new Date().getTime(),\n event: \"gtm.js\",\n });\n const script = document.createElement(\"script\");\n script.async = true;\n script.src = `https://www.googletagmanager.com/gtm.js?id=${i}`;\n document.head.appendChild(script);\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { CancellationToken } from \"#src/util/cancellation.js\";\nimport { CANCELED, uncancelableToken } from \"#src/util/cancellation.js\";\nimport { Uint64 } from \"#src/util/uint64.js\";\n\nexport class HttpError extends Error {\n url: string;\n status: number;\n statusText: string;\n response?: Response;\n\n constructor(\n url: string,\n status: number,\n statusText: string,\n response?: Response,\n ) {\n let message = `Fetching ${JSON.stringify(\n url,\n )} resulted in HTTP error ${status}`;\n if (statusText) {\n message += `: ${statusText}`;\n }\n message += \".\";\n super(message);\n this.name = \"HttpError\";\n this.message = message;\n this.url = url;\n this.status = status;\n this.statusText = statusText;\n if (response) {\n this.response = response;\n }\n }\n\n static fromResponse(response: Response) {\n return new HttpError(\n response.url,\n response.status,\n response.statusText,\n response,\n );\n }\n\n static fromRequestError(input: RequestInfo, error: unknown) {\n if (error instanceof TypeError) {\n let url: string;\n if (typeof input === \"string\") {\n url = input;\n } else {\n url = input.url;\n }\n return new HttpError(url, 0, \"Network or CORS error\");\n }\n return error;\n }\n}\n\nconst maxAttempts = 32;\nconst minDelayMilliseconds = 500;\nconst maxDelayMilliseconds = 10000;\n\nexport function pickDelay(attemptNumber: number): number {\n // If `attemptNumber == 0`, delay is a random number of milliseconds between\n // `[minDelayMilliseconds, minDelayMilliseconds*2]`. The lower and upper bounds of the interval\n // double with each successive attempt, up to the limit of\n // `[maxDelayMilliseconds/2,maxDelayMilliseconds]`.\n return (\n Math.min(\n 2 ** attemptNumber * minDelayMilliseconds,\n maxDelayMilliseconds / 2,\n ) *\n (1 + Math.random())\n );\n}\n\n/**\n * Issues a `fetch` request.\n *\n * If the request fails due to an HTTP status outside `[200, 300)`, throws an `HttpError`. If the\n * request fails due to a network or CORS restriction, throws an `HttpError` with a `status` of `0`.\n *\n * If the request fails due to a transient error (429, 503, 504), retry.\n */\nexport async function fetchOk(\n input: RequestInfo,\n init?: RequestInit,\n): Promise {\n for (let requestAttempt = 0; ; ) {\n if (init?.signal?.aborted) {\n throw CANCELED;\n }\n let response: Response;\n try {\n response = await fetch(input, init);\n } catch (error) {\n throw HttpError.fromRequestError(input, error);\n }\n if (!response.ok) {\n const { status } = response;\n if (status === 429 || status === 503 || status === 504) {\n // 429: Too Many Requests. Retry.\n // 503: Service unavailable. Retry.\n // 504: Gateway timeout. Can occur if the server takes too long to reply. Retry.\n if (++requestAttempt !== maxAttempts) {\n await new Promise((resolve) =>\n setTimeout(resolve, pickDelay(requestAttempt - 1)),\n );\n continue;\n }\n }\n throw HttpError.fromResponse(response);\n }\n return response;\n }\n}\n\nexport function responseArrayBuffer(response: Response): Promise {\n return response.arrayBuffer();\n}\n\nexport function responseJson(response: Response): Promise {\n return response.json();\n}\n\nexport type ResponseTransform = (response: Response) => Promise;\n\n/**\n * Issues a `fetch` request in the same way as `fetchOk`, and returns the result of the promise\n * returned by `transformResponse`.\n *\n * Additionally, the request may be cancelled through `cancellationToken`.\n *\n * The `transformResponse` function should not do anything with the `Response` object after its\n * result becomes ready; otherwise, cancellation may not work as expected.\n */\nexport async function cancellableFetchOk(\n input: RequestInfo,\n init: RequestInit,\n transformResponse: ResponseTransform,\n cancellationToken: CancellationToken = uncancelableToken,\n): Promise {\n if (cancellationToken === uncancelableToken) {\n const response = await fetchOk(input, init);\n return await transformResponse(response);\n }\n const abortController = new AbortController();\n const unregisterCancellation = cancellationToken.add(() =>\n abortController.abort(),\n );\n try {\n const response = await fetchOk(input, {\n ...init,\n signal: abortController.signal,\n });\n return await transformResponse(response);\n } finally {\n unregisterCancellation();\n }\n}\n\nconst tempUint64 = new Uint64();\n\nexport function getByteRangeHeader(\n startOffset: Uint64 | number,\n endOffset: Uint64 | number,\n) {\n let endOffsetStr: string;\n if (typeof endOffset === \"number\") {\n endOffsetStr = `${endOffset - 1}`;\n } else {\n Uint64.decrement(tempUint64, endOffset);\n endOffsetStr = tempUint64.toString();\n }\n return { Range: `bytes=${startOffset}-${endOffsetStr}` };\n}\n\nexport function parseUrl(url: string): {\n protocol: string;\n host: string;\n path: string;\n} {\n const urlProtocolPattern = /^([^:/]+):\\/\\/([^/]+)((?:\\/.*)?)$/;\n const match = url.match(urlProtocolPattern);\n if (match === null) {\n throw new Error(`Invalid URL: ${JSON.stringify(url)}`);\n }\n return { protocol: match[1], host: match[2], path: match[3] };\n}\n\nexport function isNotFoundError(e: any) {\n if (!(e instanceof HttpError)) return false;\n // Treat CORS errors (0) or 403 as not found. S3 returns 403 if the file does not exist because\n // permissions are per-file.\n return e.status === 0 || e.status === 403 || e.status === 404;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { WritableArrayLike } from \"#src/util/array.js\";\nimport { vec3 } from \"#src/util/geom.js\";\n\nexport function verifyFloat(obj: any): number {\n const t = typeof obj;\n if (t === \"number\" || t === \"string\") {\n const x = parseFloat(\"\" + obj);\n if (!Number.isNaN(x)) {\n return x;\n }\n }\n throw new Error(\n `Expected floating-point number, but received: ${JSON.stringify(obj)}.`,\n );\n}\n\nexport function verifyFiniteFloat(obj: any): number {\n const x = verifyFloat(obj);\n if (Number.isFinite(x)) {\n return x;\n }\n throw new Error(`Expected finite floating-point number, but received: ${x}.`);\n}\n\nexport function verifyFiniteNonNegativeFloat(obj: any): number {\n const x = verifyFloat(obj);\n if (Number.isFinite(x) && x >= 0) {\n return x;\n }\n throw new Error(\n `Expected finite non-negative floating-point number, but received: ${x}.`,\n );\n}\n\nexport function verifyFinitePositiveFloat(obj: any): number {\n const x = verifyFiniteFloat(obj);\n if (x > 0) {\n return x;\n }\n throw new Error(\n `Expected positive finite floating-point number, but received: ${x}.`,\n );\n}\n\nexport function makeVerifyNumberInInterval(minValue: number, maxValue: number) {\n return (obj: any) => {\n const x = verifyFloat(obj);\n if (x >= minValue && x <= maxValue) {\n return x;\n }\n throw new Error(\n `Expected floating-point number in range [${minValue}, ${maxValue}], but received: ${x}.`,\n );\n };\n}\n\nexport function parseXYZ>(\n out: A,\n obj: any,\n validator: (x: any) => number = verifyFloat,\n): A {\n verifyObject(obj);\n out[0] = out[1] = out[2] = 0;\n for (const key of Object.keys(obj)) {\n switch (key) {\n case \"x\":\n out[0] = validator(obj[key]);\n break;\n case \"y\":\n out[1] = validator(obj[key]);\n break;\n case \"z\":\n out[2] = validator(obj[key]);\n break;\n default:\n throw new Error(\n `Expected object to have keys ['x', 'y', 'z'], but received: ${JSON.stringify(\n obj,\n )}.`,\n );\n }\n }\n return out;\n}\n\nexport function parseFiniteVec>(\n out: U,\n obj: any[],\n) {\n const length = out.length;\n if (!Array.isArray(obj) || obj.length !== length) {\n throw new Error(\"Incompatible sizes\");\n }\n\n for (let i = 0; i < length; ++i) {\n if (!Number.isFinite(parseFloat(obj[i]))) {\n throw new Error(\"Non-finite value.\");\n }\n }\n for (let i = 0; i < length; ++i) {\n out[i] = parseFloat(obj[i]);\n }\n return out;\n}\n\nexport function parseIntVec>(\n out: U,\n obj: any,\n) {\n const length = out.length;\n if (!Array.isArray(obj) || obj.length !== length) {\n throw new Error(\"Incompatible sizes.\");\n }\n\n for (let i = 0; i < length; ++i) {\n const val = parseInt(obj[i], undefined);\n if (!Number.isInteger(val)) {\n throw new Error(\"Non-integer value.\");\n }\n }\n\n for (let i = 0; i < length; ++i) {\n out[i] = parseInt(obj[i], undefined);\n }\n return out;\n}\n\n/**\n * Returns a JSON representation of x, with object keys sorted to ensure a\n * consistent result.\n */\nexport function stableStringify(x: any) {\n if (typeof x === \"object\") {\n if (x === null) {\n return \"null\";\n }\n if (Array.isArray(x)) {\n let s = \"[\";\n const size = x.length;\n let i = 0;\n if (i < size) {\n s += stableStringify(x[i]);\n while (++i < size) {\n s += \",\";\n s += stableStringify(x[i]);\n }\n }\n s += \"]\";\n return s;\n }\n let s = \"{\";\n const keys = Object.keys(x).sort();\n let i = 0;\n const size = keys.length;\n if (i < size) {\n let key = keys[i];\n s += JSON.stringify(key);\n s += \":\";\n s += stableStringify(x[key]);\n while (++i < size) {\n s += \",\";\n key = keys[i];\n s += JSON.stringify(key);\n s += \":\";\n s += stableStringify(x[key]);\n }\n }\n s += \"}\";\n return s;\n }\n return JSON.stringify(x);\n}\n\nfunction swapQuotes(x: string) {\n return x.replace(/['\"]/g, (s) => {\n return s === '\"' ? \"'\" : '\"';\n });\n}\n\nexport function urlSafeStringifyString(x: string) {\n return swapQuotes(JSON.stringify(swapQuotes(x)));\n}\n\nconst URL_SAFE_COMMA = \"_\";\n\nexport function urlSafeStringify(x: any): string {\n if (typeof x === \"object\") {\n if (x === null) {\n return \"null\";\n }\n const toJSON = x.toJSON;\n if (typeof toJSON === \"function\") {\n return urlSafeStringify(toJSON.call(x));\n }\n if (Array.isArray(x)) {\n let s = \"[\";\n const size = x.length;\n let i = 0;\n if (i < size) {\n s += urlSafeStringify(x[i]);\n while (++i < size) {\n s += URL_SAFE_COMMA;\n s += urlSafeStringify(x[i]);\n }\n }\n s += \"]\";\n return s;\n }\n let s = \"{\";\n const keys = Object.keys(x);\n let first = true;\n for (const key of keys) {\n const value = x[key];\n if (value === undefined) {\n continue;\n }\n const valueString = urlSafeStringify(value);\n if (!valueString) {\n continue;\n }\n if (!first) {\n s += URL_SAFE_COMMA;\n } else {\n first = false;\n }\n s += urlSafeStringifyString(key);\n s += \":\";\n s += valueString;\n }\n s += \"}\";\n return s;\n }\n if (typeof x === \"string\") {\n return urlSafeStringifyString(x);\n }\n return JSON.stringify(x);\n}\n\nconst SINGLE_QUOTE_STRING_PATTERN = /('(?:[^'\\\\]|(?:\\\\.))*')/;\nconst DOUBLE_QUOTE_STRING_PATTERN = /(\"(?:[^\"\\\\]|(?:\\\\.))*\")/;\nconst SINGLE_OR_DOUBLE_QUOTE_STRING_PATTERN = new RegExp(\n `${SINGLE_QUOTE_STRING_PATTERN.source}|${DOUBLE_QUOTE_STRING_PATTERN.source}`,\n);\nconst DOUBLE_OR_SINGLE_QUOTE_STRING_PATTERN = new RegExp(\n `${DOUBLE_QUOTE_STRING_PATTERN.source}|${SINGLE_QUOTE_STRING_PATTERN.source}`,\n);\n\nconst DOUBLE_QUOTE_PATTERN = /^((?:[^\"'\\\\]|(?:\\\\[^']))*)(\"|\\\\')/;\nconst SINGLE_QUOTE_PATTERN = /^((?:[^\"'\\\\]|(?:\\\\.))*)'/;\n\nfunction convertStringLiteral(\n x: string,\n quoteInitial: string,\n quoteReplace: string,\n quoteSearch: RegExp,\n) {\n if (\n x.length >= 2 &&\n x.charAt(0) === quoteInitial &&\n x.charAt(x.length - 1) === quoteInitial\n ) {\n let inner = x.substr(1, x.length - 2);\n let s = quoteReplace;\n while (inner.length > 0) {\n const m = inner.match(quoteSearch);\n if (m === null) {\n s += inner;\n break;\n }\n s += m[1];\n if (m[2] === quoteReplace) {\n // We received a single unescaped quoteReplace character.\n s += \"\\\\\";\n s += quoteReplace;\n } else {\n // We received \"\\\\\" + quoteInitial. We need to remove the escaping.\n s += quoteInitial;\n }\n inner = inner.substr(m.index! + m[0].length);\n }\n s += quoteReplace;\n return s;\n }\n return x;\n}\n\n/**\n * Converts a string literal delimited by either single or double quotes into a string literal\n * delimited by double quotes.\n */\nexport function normalizeStringLiteral(x: string) {\n return convertStringLiteral(x, \"'\", '\"', DOUBLE_QUOTE_PATTERN);\n}\n\n// quoteChar: des\nfunction convertJsonHelper(\n x: string,\n desiredCommaChar: string,\n desiredQuoteChar: string,\n) {\n const commaSearch = /[&_,]/g;\n let quoteInitial: string;\n let quoteSearch: RegExp;\n let stringLiteralPattern: RegExp;\n if (desiredQuoteChar === '\"') {\n quoteInitial = \"'\";\n quoteSearch = DOUBLE_QUOTE_PATTERN;\n stringLiteralPattern = SINGLE_OR_DOUBLE_QUOTE_STRING_PATTERN;\n } else {\n quoteInitial = '\"';\n quoteSearch = SINGLE_QUOTE_PATTERN;\n stringLiteralPattern = DOUBLE_OR_SINGLE_QUOTE_STRING_PATTERN;\n }\n let s = \"\";\n while (x.length > 0) {\n const m = x.match(stringLiteralPattern);\n let before: string;\n let replacement: string;\n if (m === null) {\n before = x;\n x = \"\";\n replacement = \"\";\n } else {\n before = x.substr(0, m.index);\n x = x.substr(m.index! + m[0].length);\n const originalString = m[1];\n if (originalString !== undefined) {\n replacement = convertStringLiteral(\n originalString,\n quoteInitial,\n desiredQuoteChar,\n quoteSearch,\n );\n } else {\n replacement = m[2];\n }\n }\n s += before.replace(commaSearch, desiredCommaChar);\n s += replacement;\n }\n return s;\n}\n\nexport function urlSafeToJSON(x: string) {\n return convertJsonHelper(x, \",\", '\"');\n}\n\nexport function jsonToUrlSafe(x: string) {\n return convertJsonHelper(x, \"_\", \"'\");\n}\n\nexport function urlSafeParse(x: string) {\n return JSON.parse(urlSafeToJSON(x));\n}\n\n// Converts a string containing a Python literal into a string containing an equivalent JSON\n// literal.\nexport function pythonLiteralToJSON(x: string) {\n let s = \"\";\n while (x.length > 0) {\n const m = x.match(SINGLE_OR_DOUBLE_QUOTE_STRING_PATTERN);\n let before: string;\n let replacement: string;\n if (m === null) {\n before = x;\n x = \"\";\n replacement = \"\";\n } else {\n before = x.substr(0, m.index);\n x = x.substr(m.index! + m[0].length);\n const singleQuoteString = m[1];\n if (singleQuoteString !== undefined) {\n replacement = normalizeStringLiteral(singleQuoteString);\n } else {\n replacement = m[2];\n }\n }\n s += before\n .replace(/\\(/g, \"[\")\n .replace(/\\)/g, \"]\")\n .replace(\"True\", \"true\")\n .replace(\"False\", \"false\")\n .replace(/,\\s*([}\\]])/g, \"$1\");\n s += replacement;\n }\n return s;\n}\n\n// Converts a string containing a Python literal into an equivalent JavaScript value.\nexport function pythonLiteralParse(x: string) {\n return JSON.parse(pythonLiteralToJSON(x));\n}\n\nexport function expectArray(x: unknown, length?: number): any[] {\n if (!Array.isArray(x)) {\n throw new Error(`Expected array, but received: ${JSON.stringify(x)}.`);\n }\n if (length !== undefined && x.length !== length) {\n throw new Error(\n `Expected array of length ${length}, but received: ${JSON.stringify(x)}.`,\n );\n }\n return x;\n}\n\n// Checks that `x' is an array, maps each element by parseElement.\nexport function parseArray(\n x: any,\n parseElement: (x: any, index: number) => T,\n): T[] {\n if (!Array.isArray(x)) {\n throw new Error(`Expected array, but received: ${JSON.stringify(x)}.`);\n }\n return (x).map(parseElement);\n}\n\nexport function parseFixedLengthArray>(\n out: U,\n obj: any,\n parseElement: (x: any, index: number) => T,\n): U {\n const length = out.length;\n if (!Array.isArray(obj) || obj.length !== length) {\n throw new Error(\n `Expected length ${length} array, but received: ${JSON.stringify(obj)}.`,\n );\n }\n for (let i = 0; i < length; ++i) {\n out[i] = parseElement(obj[i], i);\n }\n return out;\n}\n\nexport function verifyObject(obj: any) {\n if (typeof obj !== \"object\" || obj == null || Array.isArray(obj)) {\n throw new Error(\n `Expected JSON object, but received: ${JSON.stringify(obj)}.`,\n );\n }\n return obj;\n}\n\nexport function verifyInt(obj: any) {\n const result = parseInt(obj, 10);\n if (!Number.isInteger(result)) {\n throw new Error(`Expected integer, but received: ${JSON.stringify(obj)}.`);\n }\n return result;\n}\n\nexport function verifyPositiveInt(obj: any) {\n const result = verifyInt(obj);\n if (result <= 0) {\n throw new Error(`Expected positive integer, but received: ${result}.`);\n }\n return result;\n}\n\nexport function verifyNonnegativeInt(obj: any) {\n const result = verifyInt(obj);\n if (result < 0) {\n throw new Error(`Expected non-negative integer, but received: ${result}.`);\n }\n return result;\n}\n\nexport function verifyMapKey(obj: any, map: Map) {\n const result = map.get(obj);\n if (result === undefined) {\n throw new Error(\n `Expected one of ${JSON.stringify(Array.from(map.keys()))}, ` +\n `but received: ${JSON.stringify(obj)}.`,\n );\n }\n return result;\n}\n\nexport function verifyString(obj: any) {\n if (typeof obj !== \"string\") {\n throw new Error(`Expected string, but received: ${JSON.stringify(obj)}.`);\n }\n return obj;\n}\n\nexport function verifyOptionalString(obj: any): string | undefined {\n if (obj === undefined) {\n return undefined;\n }\n return verifyString(obj);\n}\n\nexport function verifyOptionalInt(obj: any): number | undefined {\n if (obj === undefined) {\n return undefined;\n }\n return verifyInt(obj);\n}\n\nexport function verifyOptionalBoolean(obj: any): boolean | undefined {\n if (obj === undefined) {\n return undefined;\n }\n if (typeof obj === \"boolean\") {\n return obj;\n }\n if (obj === \"true\") {\n return true;\n }\n if (obj === \"false\") {\n return false;\n }\n throw new Error(\n `Expected string or boolean but received: ${JSON.stringify(obj)}`,\n );\n}\n\nexport function valueOr(value: T | undefined, defaultValue: T) {\n return value === undefined ? defaultValue : value;\n}\n\nexport function verifyObjectProperty(\n obj: any,\n propertyName: string,\n validator: (value: any) => T,\n): T {\n const value = Object.prototype.hasOwnProperty.call(obj, propertyName)\n ? obj[propertyName]\n : undefined;\n try {\n return validator(value);\n } catch (parseError) {\n throw new Error(\n `Error parsing ${JSON.stringify(propertyName)} property: ${\n parseError.message\n }`,\n );\n }\n}\n\nexport function verifyOptionalObjectProperty(\n obj: any,\n propertyName: string,\n validator: (value: any) => T,\n): T | undefined;\n\nexport function verifyOptionalObjectProperty(\n obj: any,\n propertyName: string,\n validator: (value: any) => T,\n defaultValue: T,\n): T;\n\nexport function verifyOptionalObjectProperty(\n obj: any,\n propertyName: string,\n validator: (value: any) => T,\n defaultValue?: any,\n) {\n return verifyObjectProperty(obj, propertyName, (x) =>\n x === undefined ? defaultValue : validator(x),\n );\n}\n\nexport function verifyObjectAsMap(\n obj: any,\n validator: (value: any) => T,\n): Map {\n verifyObject(obj);\n const map = new Map();\n for (const key of Object.keys(obj)) {\n try {\n map.set(key, validator(obj[key]));\n } catch (parseError) {\n throw new Error(\n `Error parsing value associated with key ${JSON.stringify(key)}: ${\n parseError.message\n }`,\n );\n }\n }\n return map;\n}\n\nexport function verifyFloat01(obj: any): number {\n if (typeof obj !== \"number\" || !Number.isFinite(obj) || obj < 0 || obj > 1) {\n throw new Error(\n `Expected floating point number in [0,1], but received: ${JSON.stringify(\n obj,\n )}.`,\n );\n }\n return obj;\n}\n\n/**\n * The query string parameters may either be specified in the usual\n * 'name=value&otherName=otherValue' form or as (optionally urlSafe) JSON: '{\"name\":\"value\"}`.\n */\nexport function parseQueryStringParameters(queryString: string) {\n if (queryString === \"\") {\n return {};\n }\n if (queryString.startsWith(\"{\")) {\n return urlSafeParse(queryString);\n }\n const result: any = {};\n const parts = queryString.split(/[&;]/);\n for (const part of parts) {\n const m = part.match(/^([^=&;]+)=([^&;]*)$/);\n if (m === null) {\n throw new Error(`Invalid query string part: ${JSON.stringify(part)}.`);\n }\n result[m[1]] = decodeURIComponent(m[2]);\n }\n return result;\n}\n\nexport function unparseQueryStringParameters(parameters: any) {\n if (parameters === undefined) return \"\";\n const keys = Object.keys(parameters);\n if (keys.length === 0) return \"\";\n if (keys.some((key) => typeof parameters[key] !== \"string\")) {\n return JSON.stringify(parameters);\n }\n return keys\n .map(\n (key) =>\n `${encodeURIComponent(key)}=${encodeURIComponent(parameters[key])}`,\n )\n .join(\"&\");\n}\n\n/**\n * Verifies that `obj' is a string that, when converted to uppercase, matches a string property of\n * `enumType`.\n *\n * @returns The corresponding numerical value.\n */\nexport function verifyEnumString(\n obj: any,\n enumType: { [x: string]: T | string },\n pattern: RegExp = /^[a-zA-Z]/,\n): T {\n if (typeof obj === \"string\" && obj.match(pattern) !== null) {\n const objUpperCase = obj.toUpperCase();\n if (Object.prototype.hasOwnProperty.call(enumType, objUpperCase)) {\n return enumType[objUpperCase] as T;\n }\n }\n throw new Error(`Invalid enum value: ${JSON.stringify(obj)}.`);\n}\n\nexport function verify3dVec(obj: any) {\n return parseFixedLengthArray(vec3.create(), obj, verifyFiniteFloat);\n}\n\nexport function verify3dScale(obj: any) {\n return parseFixedLengthArray(vec3.create(), obj, verifyFinitePositiveFloat);\n}\n\nexport function verify3dDimensions(obj: any) {\n return parseFixedLengthArray(vec3.create(), obj, verifyPositiveInt);\n}\n\nexport function verifyStringArray(a: any) {\n if (!Array.isArray(a)) {\n throw new Error(`Expected array, received: ${JSON.stringify(a)}.`);\n }\n for (const x of a) {\n if (typeof x !== \"string\") {\n throw new Error(`Expected string, received: ${JSON.stringify(x)}.`);\n }\n }\n return a;\n}\n\nexport function verifyIntegerArray(a: unknown) {\n if (!Array.isArray(a)) {\n throw new Error(`Expected array, received: ${JSON.stringify(a)}.`);\n }\n for (const x of a) {\n if (!Number.isInteger(x)) {\n throw new Error(`Expected integer, received: ${JSON.stringify(x)}.`);\n }\n }\n return a;\n}\n\nexport function verifyFloatArray(a: unknown) {\n if (!Array.isArray(a)) {\n throw new Error(`Expected array, received: ${JSON.stringify(a)}.`);\n }\n for (const x of a) {\n verifyFloat(x);\n }\n return a;\n}\n\nexport function verifyBoolean(x: any) {\n if (typeof x !== \"boolean\") {\n throw new Error(`Expected boolean, received: ${JSON.stringify(x)}`);\n }\n return x;\n}\n\n// If `x` is an empty object/array/string, returns undefined. Otherwise returns `x`.\nexport function emptyToUndefined(x: any) {\n for (const _ in x) {\n return x;\n }\n return undefined;\n}\n\nexport function verifyConstant(actual: unknown, expected: T) {\n if (actual !== expected) {\n throw new Error(\n `Expected ${JSON.stringify(expected)}, but received: ${JSON.stringify(\n actual,\n )}`,\n );\n }\n return expected;\n}\n\nexport function verifyOptionalFixedLengthArrayOfStringOrNull(\n obj: unknown,\n rank: number,\n) {\n if (obj === undefined) {\n const array = new Array(rank);\n array.fill(null);\n return array;\n }\n return parseFixedLengthArray(new Array(rank), obj, (value) => {\n if (value !== null && typeof value !== \"string\") {\n throw new Error(\n `Expected string or null, but received: ${JSON.stringify(name)}`,\n );\n }\n return value;\n });\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { TypedArray } from \"#src/util/array.js\";\n\n/**\n * Sets the `m * k` matrix `c` to the product of `m * n` matrix `a` and `n * k` matrix `b`.\n *\n * `a`, `b` and `c` are column-major with column strides of `lda`, `ldb`, and `ldc`, respectively.\n * `c` must not overlap `a` or `b`.\n */\nexport function multiply(\n c: T,\n ldc: number,\n a: T,\n lda: number,\n b: T,\n ldb: number,\n m: number,\n n: number,\n k: number,\n): T {\n for (let mIndex = 0; mIndex < m; ++mIndex) {\n for (let kIndex = 0; kIndex < k; ++kIndex) {\n let sum = 0;\n for (let nIndex = 0; nIndex < n; ++nIndex) {\n sum += a[mIndex + lda * nIndex] * b[nIndex + ldb * kIndex];\n }\n c[mIndex + ldc * kIndex] = sum;\n }\n }\n return c;\n}\n\nexport function identity(\n a: T,\n lda: number,\n n: number,\n): T {\n for (let i = 0; i < n; ++i) {\n const start = lda * i;\n a.fill(0, start, start + n);\n a[start + i] = 1;\n }\n return a;\n}\n\nexport function createIdentity(\n c: { new (n: number): T },\n rows: number,\n cols: number = rows,\n): T {\n return identity(new c(rows * cols), rows, Math.min(rows, cols));\n}\n\nexport function createHomogeneousScaleMatrix(\n c: { new (length: number): T },\n scales: ArrayLike,\n square = true,\n): T {\n const rank = scales.length;\n const stride = square ? rank + 1 : rank;\n const m = new c(stride * (rank + 1));\n if (square) {\n m[m.length - 1] = 1;\n }\n for (let i = 0; i < rank; ++i) {\n m[(stride + 1) * i] = scales[i];\n }\n return m;\n}\n\nexport function createHomogeneousTranslationMatrix(\n c: { new (length: number): T },\n translation: ArrayLike,\n square = true,\n): T {\n const rank = translation.length;\n const stride = square ? rank + 1 : rank;\n const m = createIdentity(c, stride, rank + 1);\n for (let i = 0; i < rank; ++i) {\n m[stride * rank + i] = translation[i];\n }\n return m;\n}\n\nexport function isIdentity(a: T, lda: number, n: number) {\n for (let i = 0; i < n; ++i) {\n for (let j = 0; j < n; ++j) {\n if (a[i * lda + j] !== (i === j ? 1 : 0)) return false;\n }\n }\n return true;\n}\n\nexport function copy(\n b: T,\n ldb: number,\n a: T,\n lda: number,\n m: number,\n n: number,\n): T {\n for (let col = 0; col < n; ++col) {\n const aOff = col * lda;\n const bOff = col * ldb;\n for (let row = 0; row < m; ++row) {\n b[bOff + row] = a[aOff + row];\n }\n }\n return b;\n}\n\nexport function extendHomogeneousTransform(\n b: T,\n bRank: number,\n a: T,\n aRank: number,\n) {\n copy(b, bRank + 1, a, aRank + 1, aRank, aRank);\n for (let i = 0; i < aRank; ++i) {\n b[(bRank + 1) * bRank + i] = a[(aRank + 1) * aRank + i];\n }\n b[b.length - 1] = 1;\n for (let i = aRank; i < bRank; ++i) {\n b[(bRank + 1) * i + i] = 1;\n }\n return b;\n}\n\nlet pivots: Uint32Array | undefined;\n\n/**\n * Computes the inverse of a square matrix in place, and returns the determinant.\n */\nexport function inverseInplace(\n a: T,\n lda: number,\n n: number,\n): number {\n let determinant = 1;\n // Use Gauss-Jordan elimination with partial pivoting to compute inverse.\n if (pivots === undefined || pivots.length < n) {\n pivots = new Uint32Array(n);\n }\n for (let i = 0; i < n; ++i) {\n pivots[i] = i;\n }\n for (let k = 0; k < n; ++k) {\n const kColOff = lda * k;\n // Find best pivot (row >= `k` with maximum-magnitude element in column `k`).\n let pivotRow = k;\n {\n let bestPivot = Math.abs(a[kColOff + k]);\n for (let row = k + 1; row < n; ++row) {\n const mag = Math.abs(a[kColOff + row]);\n if (mag > bestPivot) {\n bestPivot = mag;\n pivotRow = row;\n }\n }\n }\n // Swap rows `k` and `pivotRow`.\n if (k !== pivotRow) {\n determinant *= -1;\n for (let col = 0; col < n; ++col) {\n const off = lda * col;\n const temp = a[off + k];\n a[off + k] = a[off + pivotRow];\n a[off + pivotRow] = temp;\n }\n\n // Swap `pivots[k]` with `pivots[pivotRow]`.\n {\n const tempPivot = pivots[k];\n pivots[k] = pivots[pivotRow];\n pivots[pivotRow] = tempPivot;\n }\n }\n // Eliminate.\n const pivotValue = a[kColOff + k];\n const pivotInv = 1.0 / pivotValue;\n\n // Divide row `k` by the pivot element.\n determinant *= pivotValue;\n for (let j = 0; j < n; ++j) {\n a[lda * j + k] *= pivotInv;\n }\n // Convert `a(k, k)` to contain the inverse element.\n a[kColOff + k] = pivotInv;\n\n // Subtract a suitable multiple of row `k` from all other rows to ensure column `k` becomes `0`.\n for (let row = 0; row < n; ++row) {\n if (row === k) continue;\n const factor = -a[lda * k + row];\n for (let j = 0; j < n; ++j) {\n const jColOff = lda * j;\n a[jColOff + row] += factor * a[jColOff + k];\n }\n // Convert element in column `k` to contain the inverse element.\n a[lda * k + row] = factor * pivotInv;\n }\n }\n // Permute columns back to correct order.\n for (let col = 0; col < n; ++col) {\n let targetCol = pivots[col];\n while (targetCol !== col) {\n const colOff = lda * col;\n const targetColOff = lda * targetCol;\n for (let i = 0; i < n; ++i) {\n const off1 = colOff + i;\n const off2 = targetColOff + i;\n const temp = a[off1];\n a[off1] = a[off2];\n a[off2] = temp;\n }\n const temp = (pivots[col] = pivots[targetCol]);\n pivots[targetCol] = targetCol;\n targetCol = temp;\n }\n }\n return determinant;\n}\n\n/**\n * Computes the inverse and returns the determinant.\n */\nexport function inverse(\n b: T,\n ldb: number,\n a: T,\n lda: number,\n n: number,\n): number {\n copy(b, ldb, a, lda, n, n);\n return inverseInplace(b, ldb, n);\n}\n\nexport function equal(\n a: T,\n lda: number,\n b: T,\n ldb: number,\n m: number,\n n: number,\n) {\n for (let j = 0; j < n; ++j) {\n const offA = lda * j;\n const offB = ldb * j;\n for (let i = 0; i < m; ++i) {\n if (a[offA + i] !== b[offB + i]) return false;\n }\n }\n return true;\n}\n\nexport function transpose(\n b: T,\n ldb: number,\n a: T,\n lda: number,\n m: number,\n n: number,\n) {\n for (let i = 0; i < m; ++i) {\n for (let j = 0; j < n; ++j) {\n b[j + i * ldb] = a[i + j * lda];\n }\n }\n return b;\n}\n\nexport function transformPoint<\n Out extends TypedArray,\n Matrix extends TypedArray,\n Vector extends TypedArray,\n>(out: Out, mat: Matrix, matrixStride: number, vec: Vector, rank: number): Out {\n for (let i = 0; i < rank; ++i) {\n let sum = mat[matrixStride * rank + i];\n for (let j = 0; j < rank; ++j) {\n sum += mat[matrixStride * j + i] * vec[j];\n }\n out[i] = sum;\n }\n return out;\n}\n\nexport function transformVector<\n Out extends TypedArray,\n Matrix extends TypedArray,\n Vector extends TypedArray,\n>(out: Out, mat: Matrix, matrixStride: number, vec: Vector, rank: number): Out {\n for (let i = 0; i < rank; ++i) {\n let sum = 0;\n for (let j = 0; j < rank; ++j) {\n sum += mat[matrixStride * j + i] * vec[j];\n }\n out[i] = sum;\n }\n return out;\n}\n\nexport function permuteRows<\n Output extends TypedArray,\n Input extends TypedArray,\n>(\n output: Output,\n outputStride: number,\n input: Input,\n inputStride: number,\n outputToInputRow: ReadonlyArray,\n cols: number,\n) {\n const rows = outputToInputRow.length;\n for (let outRow = 0; outRow < rows; ++outRow) {\n const inRow = outputToInputRow[outRow];\n for (let col = 0; col < cols; ++col) {\n output[col * outputStride + outRow] = input[col * inputStride + inRow];\n }\n }\n return output;\n}\n\nexport function permuteCols<\n Output extends TypedArray,\n Input extends TypedArray,\n>(\n output: Output,\n outputStride: number,\n input: Input,\n inputStride: number,\n outputToInputCol: ReadonlyArray,\n rows: number,\n) {\n const cols = outputToInputCol.length;\n for (let outCol = 0; outCol < cols; ++outCol) {\n const inCol = outputToInputCol[outCol];\n for (let row = 0; row < rows; ++row) {\n output[outCol * outputStride + row] = input[inCol * inputStride + row];\n }\n }\n return output;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @file Simple signal dispatch mechanism.\n */\n\n/**\n * This class provides a simple signal dispatch mechanism. Handlers can be added, and then the\n * `dispatch` method calls all of them.\n *\n * If specified, Callable should be an interface containing only a callable signature returning\n * void. Due to limitations in TypeScript, any interface containing a callable signature will be\n * accepted by the compiler, but the resultant signature of `dispatch` will not be correct.\n */\nexport class Signal void> {\n private handlers = new Set();\n\n /**\n * Count of number of times this signal has been dispatched. This is incremented each time\n * `dispatch` is called prior to invoking the handlers.\n */\n count = 0;\n\n constructor() {\n const obj = this;\n this.dispatch = (function (this: any) {\n ++obj.count;\n obj.handlers.forEach((handler) => {\n // eslint-disable-next-line prefer-rest-params\n handler.apply(this, arguments);\n });\n });\n }\n\n /**\n * Add a handler function. If `dispatch` is currently be called, then the new handler will be\n * called before `dispatch` returns.\n *\n * @param handler The handler function to add.\n *\n * @return A function that unregisters the handler.\n */\n add(handler: Callable): () => boolean {\n this.handlers.add(handler);\n return () => {\n return this.remove(handler);\n };\n }\n\n /**\n * Remove a handler function. If `dispatch` is currently be called and the new handler has not\n * yet been called, then it will not be called.\n *\n * @param handler Handler to remove.\n * @return `true` if the handler was present, `false` otherwise.\n */\n remove(handler: Callable): boolean {\n return this.handlers.delete(handler);\n }\n\n /**\n * Invokes each handler function with the same parameters (including `this`) with which it is\n * called. Handlers are invoked in the order in which they were added.\n */\n dispatch: Callable;\n\n /**\n * Disposes of resources. No methods, including `dispatch`, may be invoked afterwards.\n */\n dispose() {\n this.handlers = undefined;\n }\n}\n\nexport function observeSignal(\n callback: () => void,\n ...signals: {\n add(callback: () => void): void;\n remove(callback: () => void): void;\n }[]\n) {\n callback();\n for (let i = 0, count = signals.length; i < count; ++i) {\n signals[i].add(callback);\n }\n return () => {\n for (let i = 0, count = signals.length; i < count; ++i) {\n signals[i].remove(callback);\n }\n };\n}\n\n/**\n * Simple specialization of Signal for the common case of a nullary handler signature.\n */\nexport class NullarySignal extends Signal<() => void> {}\n\n/**\n * Interface for a signal excluding the dispatch method.\n *\n * Unlike Signal, this interface is covariant in the type of Callable.\n */\nexport interface ReadonlySignal {\n readonly count: number;\n add(handler: Callable): () => void;\n remove(handler: Callable): boolean;\n}\n\nexport type NullaryReadonlySignal = ReadonlySignal<() => void>;\n\nexport const neverSignal: NullaryReadonlySignal = {\n count: 0,\n add(_handler: any) {\n return () => {};\n },\n remove(_handler: any) {\n return false;\n },\n};\n","/**\n * @license\n * Copyright 2017 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function hexEncodeByte(x: number) {\n return (\"0\" + x.toString(16)).slice(-2);\n}\n\nexport function hexEncode(arr: Uint8Array) {\n return Array.prototype.map.call(arr, hexEncodeByte).join(\"\");\n}\n\nexport function hexDecode(x: string) {\n if (!/^(?:[0-9a-fA-F]{2})*$/.test(x)) {\n throw new Error(\"Invalid hex-encoded string\");\n }\n const length = x.length / 2;\n const result = new Uint8Array(length);\n for (let i = 0; i < length; ++i) {\n result[i] = parseInt(x.substr(i * 2, 2), 16);\n }\n return result;\n}\n","/**\n * @license\n * Copyright 2018 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @file Facilities for converting between strings and RGB/RGBA colors.\n */\n\nimport { WatchableValue } from \"#src/trackable_value.js\";\nimport { float32ToString } from \"#src/util/float32_to_string.js\";\nimport { vec3, vec4 } from \"#src/util/geom.js\";\nimport { hexEncodeByte } from \"#src/util/hex.js\";\n\n/**\n * Parse the serialization of a color.\n *\n * This is based on the definition here:\n * https://html.spec.whatwg.org/multipage/canvas.html#serialisation-of-a-color\n */\nexport function parseColorSerialization(x: string) {\n const rgbaPattern =\n /^rgba\\(([0-9]+), ([0-9]+), ([0-9]+), (0(?:\\.[0-9]+)?)\\)$/;\n {\n const m = x.match(rgbaPattern);\n if (m !== null) {\n return [\n parseInt(m[1], 10),\n parseInt(m[2], 10),\n parseInt(m[3], 10),\n parseFloat(m[4]),\n ];\n }\n }\n const hexPattern = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/;\n {\n const m = x.match(hexPattern);\n if (m !== null) {\n return [parseInt(m[1], 16), parseInt(m[2], 16), parseInt(m[3], 16), 1.0];\n }\n }\n throw new Error(`Invalid serialized color: ${JSON.stringify(x)}.`);\n}\n\nexport function parseRGBAColorSpecification(x: any) {\n try {\n if (typeof x !== \"string\") {\n throw new Error(`Expected string, but received ${JSON.stringify(x)}.`);\n }\n const context = document.createElement(\"canvas\").getContext(\"2d\")!;\n context.fillStyle = x;\n const result = parseColorSerialization(context.fillStyle);\n return vec4.fromValues(\n result[0] / 255,\n result[1] / 255,\n result[2] / 255,\n result[3],\n );\n } catch (parseError) {\n throw new Error(\n `Failed to parse color specification: ${parseError.message}`,\n );\n }\n}\n\nexport function parseRGBColorSpecification(x: any) {\n const result = parseRGBAColorSpecification(x);\n return result.subarray(0, 3);\n}\n\n/**\n * Returns an integer formed by concatenating the channels of the input color vector.\n * Each channel is clamped to the range [0.0, 1.0] before being converted to 8 bits.\n * An RGB color is packed into 24 bits, and a RGBA into 32 bits.\n */\nexport function packColor(x: vec3 | vec4): number {\n const size = x[3] === undefined ? 3 : 4;\n let result = 0;\n for (let i = 0; i < size; i++) {\n // The \">>> 0\" ensures an unsigned value.\n result =\n ((result << 8) >>> 0) +\n Math.min(255, Math.max(0, Math.round(x[size - 1 - i] * 255)));\n }\n return result;\n}\n\nexport function unpackRGB(value: number) {\n return vec3.fromValues(\n ((value >>> 0) & 0xff) / 255,\n ((value >>> 8) & 0xff) / 255,\n ((value >>> 16) & 0xff) / 255,\n );\n}\n\nexport function unpackRGBA(value: number) {\n return vec4.fromValues(\n ((value >>> 0) & 0xff) / 255,\n ((value >>> 8) & 0xff) / 255,\n ((value >>> 16) & 0xff) / 255,\n ((value >>> 24) & 0xff) / 255,\n );\n}\n\nexport function serializeColor(x: vec3 | vec4) {\n if (x[3] === undefined || x[3] === 1) {\n let result = \"#\";\n for (let i = 0; i < 3; ++i) {\n result += hexEncodeByte(\n Math.min(255, Math.max(0, Math.round(x[i] * 255))),\n );\n }\n return result;\n }\n let result = \"rgba(\";\n for (let i = 0; i < 3; ++i) {\n if (i !== 0) {\n result += \", \";\n }\n result += Math.min(255, Math.max(0, Math.round(x[i] * 255)));\n }\n result += `, ${float32ToString(x[3])})`;\n return result;\n}\n\n// Converts an sRGB color component to the gamma-expanded (\"linear\") value.\nexport function srgbGammaExpand(value: number) {\n return value <= 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;\n}\n\n// Computes the relative luminance according to Web Content Accessibility Guidelines (WCAG) 2.0\n//\n// https://www.w3.org/TR/WCAG20/#relativeluminancedef\n//\n// @param color sRGB color\nexport function getRelativeLuminance(color: vec3 | vec4) {\n const [r, g, b] = color;\n return (\n 0.2126 * srgbGammaExpand(r) +\n 0.7152 * srgbGammaExpand(g) +\n 0.0722 * srgbGammaExpand(b)\n );\n}\n\n// Determines whether a white background would provide higher contrast than a black background for\n// the given foreground color.\n//\n// This is determined according to the Web Content Accessibility Guidelines (WCAG) 2.0:\n// https://www.w3.org/TR/WCAG20/#contrast-ratiodef\n//\n// https://stackoverflow.com/a/3943023\nexport function useWhiteBackground(foregroundColor: vec3 | vec4) {\n return getRelativeLuminance(foregroundColor) <= 0.179;\n}\n\nexport class TrackableRGB extends WatchableValue {\n constructor(public defaultValue: vec3) {\n super(vec3.clone(defaultValue));\n }\n toString() {\n return serializeColor(this.value);\n }\n toJSON() {\n if (vec3.equals(this.value, this.defaultValue)) {\n return undefined;\n }\n return serializeColor(this.value);\n }\n reset() {\n this.value = vec3.clone(this.defaultValue);\n }\n restoreState(x: any) {\n if (x === undefined) {\n this.reset();\n return;\n }\n const { value } = this;\n const newValue = parseRGBColorSpecification(x);\n if (!vec3.equals(value, newValue)) {\n this.value = newValue;\n }\n }\n}\n\nexport class TrackableOptionalRGB extends WatchableValue {\n constructor() {\n super(undefined);\n }\n toJSON() {\n const { value } = this;\n if (value === undefined) return undefined;\n return serializeColor(value);\n }\n reset() {\n this.value = undefined;\n }\n restoreState(x: any) {\n if (x === undefined) {\n this.reset();\n return;\n }\n const { value } = this;\n const newValue = parseRGBColorSpecification(x);\n if (value === undefined || !vec3.equals(value, newValue)) {\n this.value = newValue;\n }\n }\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { TypedArrayConstructor } from \"#src/util/array.js\";\n\n/**\n * If this is updated, DATA_TYPE_BYTES must also be updated.\n */\nexport enum DataType {\n UINT8 = 0,\n INT8 = 1,\n UINT16 = 2,\n INT16 = 3,\n UINT32 = 4,\n INT32 = 5,\n UINT64 = 6,\n FLOAT32 = 7,\n}\n\nexport const DATA_TYPE_SIGNED: Record = {\n [DataType.UINT8]: false,\n [DataType.INT8]: true,\n [DataType.UINT16]: false,\n [DataType.INT16]: true,\n [DataType.UINT32]: false,\n [DataType.INT32]: true,\n [DataType.UINT64]: false,\n [DataType.FLOAT32]: undefined,\n};\n\nexport const DATA_TYPE_BYTES: Record = {\n [DataType.UINT8]: 1,\n [DataType.INT8]: 1,\n [DataType.UINT16]: 2,\n [DataType.INT16]: 2,\n [DataType.UINT32]: 4,\n [DataType.INT32]: 4,\n [DataType.UINT64]: 8,\n [DataType.FLOAT32]: 4,\n};\n\nexport const DATA_TYPE_ARRAY_CONSTRUCTOR: Record<\n DataType,\n TypedArrayConstructor\n> = {\n [DataType.UINT8]: Uint8Array,\n [DataType.INT8]: Int8Array,\n [DataType.UINT16]: Uint16Array,\n [DataType.INT16]: Int16Array,\n [DataType.UINT32]: Uint32Array,\n [DataType.INT32]: Int32Array,\n [DataType.UINT64]: Uint32Array,\n [DataType.FLOAT32]: Float32Array,\n};\n\nexport const DATA_TYPE_JAVASCRIPT_ELEMENTS_PER_ARRAY_ELEMENT: Record<\n DataType,\n number\n> = {\n [DataType.UINT8]: 1,\n [DataType.INT8]: 1,\n [DataType.UINT16]: 1,\n [DataType.INT16]: 1,\n [DataType.UINT32]: 1,\n [DataType.INT32]: 1,\n [DataType.UINT64]: 2,\n [DataType.FLOAT32]: 1,\n};\n\nexport function makeDataTypeArrayView(\n dataType: DataType,\n buffer: ArrayBuffer,\n byteOffset = 0,\n byteLength: number = buffer.byteLength,\n): ArrayBufferView {\n const bytesPerElement = DATA_TYPE_BYTES[dataType];\n const javascriptElementsPerArrayElement =\n DATA_TYPE_JAVASCRIPT_ELEMENTS_PER_ARRAY_ELEMENT[dataType];\n return new DATA_TYPE_ARRAY_CONSTRUCTOR[dataType](\n buffer,\n byteOffset,\n (byteLength / bytesPerElement) * javascriptElementsPerArrayElement,\n );\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Facilities for endianness detection and swapping.\n */\n\nexport enum Endianness {\n LITTLE = 0,\n BIG = 1,\n}\n\nexport function determineEndianness() {\n const a = Uint16Array.of(0x1122);\n const b = new Uint8Array(a.buffer);\n return b[0] === 0x11 ? Endianness.BIG : Endianness.LITTLE;\n}\n\n/**\n * The native endianness of the runtime.\n */\nexport const ENDIANNESS = determineEndianness();\n\n/**\n * Swaps the endianness of an array assumed to contain 16-bit values.\n */\nexport function swapEndian16(array: ArrayBufferView) {\n const view = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);\n for (let i = 0, length = view.length; i < length; i += 2) {\n const temp = view[i];\n view[i] = view[i + 1];\n view[i + 1] = temp;\n }\n}\n\n/**\n * Swaps the endianness of an array assumed to contain 32-bit values.\n */\nexport function swapEndian32(array: ArrayBufferView) {\n const view = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);\n for (let i = 0, length = view.length; i < length; i += 4) {\n let temp = view[i];\n view[i] = view[i + 3];\n view[i + 3] = temp;\n temp = view[i + 1];\n view[i + 1] = view[i + 2];\n view[i + 2] = temp;\n }\n}\n\nexport function swapEndian64(array: ArrayBufferView) {\n const view = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);\n for (let i = 0, length = view.length; i < length; i += 8) {\n let temp = view[i];\n view[i] = view[i + 7];\n view[i + 7] = temp;\n temp = view[i + 1];\n view[i + 1] = view[i + 6];\n view[i + 6] = temp;\n temp = view[i + 2];\n view[i + 2] = view[i + 5];\n view[i + 5] = temp;\n temp = view[i + 3];\n view[i + 3] = view[i + 4];\n view[i + 4] = temp;\n }\n}\n\n/**\n * Converts the endianness of an array assumed to contain 16-bit values from source to target.\n *\n * This does nothing if source === target.\n */\nexport function convertEndian16(\n array: ArrayBufferView,\n source: Endianness,\n target: Endianness = ENDIANNESS,\n) {\n if (source !== target) {\n swapEndian16(array);\n }\n}\n\n/**\n * Converts the endianness of an array assumed to contain 32-bit values from source to target.\n *\n * This does nothing if source === target.\n */\nexport function convertEndian32(\n array: ArrayBufferView,\n source: Endianness,\n target: Endianness = ENDIANNESS,\n) {\n if (source !== target) {\n swapEndian32(array);\n }\n}\n\n/**\n * Converts the endianness of an array assumed to contain 64-bit values from source to target.\n *\n * This does nothing if source === target.\n */\nexport function convertEndian64(\n array: ArrayBufferView,\n source: Endianness,\n target: Endianness = ENDIANNESS,\n) {\n if (source !== target) {\n swapEndian64(array);\n }\n}\n\nexport function convertEndian(\n array: ArrayBufferView,\n source: Endianness,\n elementBytes: number,\n target: Endianness = ENDIANNESS,\n) {\n if (source === target || elementBytes === 1) return;\n switch (elementBytes) {\n case 2:\n swapEndian16(array);\n break;\n case 4:\n swapEndian32(array);\n break;\n case 8:\n swapEndian64(array);\n break;\n }\n}\n","/**\n * @license\n * Copyright 2021 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Endianness, ENDIANNESS } from \"#src/util/endian.js\";\n\nconst denormMin = 2 ** -1074;\n\nconst float64Buf = new Float64Array(1);\nconst uint32Buf = new Uint32Array(float64Buf.buffer);\n\n// The following implementation is derived from:\n// https://github.com/scijs/nextafter/\n//\n// and is subject to the following license:\n//\n// The MIT License (MIT)\n//\n// Copyright (c) 2013 Mikola Lysenko\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\n// Like the C standard library `nextafter` function, returns the next representable JavaScript\n// number (float64) after `x` in the direction of `y`. Returns `y` if `x === y`.\nexport function nextAfterFloat64(x: number, y: number) {\n if (Number.isNaN(x) || Number.isNaN(y)) return NaN;\n if (x === y) return y;\n if (x === 0) {\n return y < 0 ? -denormMin : denormMin;\n }\n float64Buf[0] = x;\n const lowIndex = ENDIANNESS === Endianness.LITTLE ? 0 : 1;\n const highIndex = 1 - lowIndex;\n if (y > x === x > 0) {\n if (uint32Buf[lowIndex] === 0xffffffff) {\n uint32Buf[lowIndex] = 0;\n uint32Buf[highIndex] += 1;\n } else {\n uint32Buf[lowIndex] += 1;\n }\n } else {\n if (uint32Buf[lowIndex] === 0) {\n uint32Buf[lowIndex] = 0xffffffff;\n uint32Buf[highIndex] -= 1;\n } else {\n uint32Buf[lowIndex] -= 1;\n }\n }\n return float64Buf[0];\n}\n","/**\n * @license\n * Copyright 2021 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DataType } from \"#src/util/data_type.js\";\nimport { nextAfterFloat64 } from \"#src/util/float.js\";\nimport { parseFixedLengthArray } from \"#src/util/json.js\";\nimport { Uint64 } from \"#src/util/uint64.js\";\n\nexport type DataTypeInterval = [number, number] | [Uint64, Uint64];\n\nexport type UnknownDataTypeInterval = [number | Uint64, number | Uint64];\n\nexport const defaultDataTypeRange: Record = {\n [DataType.UINT8]: [0, 0xff],\n [DataType.INT8]: [-0x80, 0x7f],\n [DataType.UINT16]: [0, 0xffff],\n [DataType.INT16]: [-0x8000, 0x7fff],\n [DataType.UINT32]: [0, 0xffffffff],\n [DataType.INT32]: [-0x80000000, 0x7fffffff],\n [DataType.UINT64]: [Uint64.ZERO, new Uint64(0xffffffff, 0xffffffff)],\n [DataType.FLOAT32]: [0, 1],\n};\n\n/**\n * Compute inverse linear interpolation on the interval [0, 1].\n * @param range Values at start and end of interval.\n * @param value Value to interpolate at.\n * @returns Coordinate of interpolated point.\n */\nexport function computeInvlerp(\n range: DataTypeInterval,\n value: number | Uint64,\n): number {\n if (typeof value === \"number\") {\n const minValue = range[0] as number;\n const maxValue = range[1] as number;\n return (value - minValue) / (maxValue - minValue);\n }\n const minValue = range[0] as Uint64;\n const maxValue = range[1] as Uint64;\n let numerator: number;\n if (Uint64.compare(value, minValue) < 0) {\n numerator = -Uint64.subtract(tempUint64, minValue, value).toNumber();\n } else {\n numerator = Uint64.subtract(tempUint64, value, minValue).toNumber();\n }\n let denominator = Uint64.absDifference(\n tempUint64,\n maxValue,\n minValue,\n ).toNumber();\n if (Uint64.compare(minValue, maxValue) > 0) denominator *= -1;\n return numerator / denominator;\n}\n\n/**\n * Compute linear interpolation on the interval [0, 1].\n * @param range Values at start and end of interval.\n * @param dataType\n * @param value Coordinate to interpolate at.\n * @returns Interpolated value.\n */\nexport function computeLerp(\n range: DataTypeInterval,\n dataType: DataType,\n value: number,\n): number | Uint64 {\n if (typeof range[0] === \"number\") {\n const minValue = range[0] as number;\n const maxValue = range[1] as number;\n let result = minValue * (1 - value) + maxValue * value;\n if (dataType !== DataType.FLOAT32) {\n const dataTypeRange = defaultDataTypeRange[dataType];\n result = Math.round(result);\n result = Math.max(dataTypeRange[0] as number, result);\n result = Math.min(dataTypeRange[1] as number, result);\n }\n return result;\n }\n let minValue = range[0] as Uint64;\n let maxValue = range[1] as Uint64;\n if (Uint64.compare(minValue, maxValue) > 0) {\n [minValue, maxValue] = [maxValue, minValue];\n value = 1 - value;\n }\n const scalar = Uint64.subtract(tempUint64, maxValue, minValue).toNumber();\n const result = new Uint64();\n if (value <= 0) {\n tempUint64.setFromNumber(scalar * -value);\n Uint64.subtract(result, minValue, Uint64.min(tempUint64, minValue));\n } else if (value >= 1) {\n tempUint64.setFromNumber(scalar * (value - 1));\n Uint64.add(result, maxValue, tempUint64);\n if (Uint64.less(result, maxValue)) {\n result.low = result.high = 0xffffffff;\n }\n } else {\n tempUint64.setFromNumber(scalar * value);\n Uint64.add(result, minValue, tempUint64);\n if (Uint64.less(result, minValue)) {\n result.low = result.high = 0xffffffff;\n }\n }\n return result;\n}\n\nexport function clampToInterval(\n range: DataTypeInterval,\n value: number | Uint64,\n): number | Uint64 {\n if (typeof value === \"number\") {\n return Math.min(Math.max(range[0] as number, value), range[1] as number);\n }\n return Uint64.min(Uint64.max(range[0] as Uint64, value), range[1] as Uint64);\n}\n\nexport function getClampedInterval(\n bounds: DataTypeInterval,\n range: DataTypeInterval,\n): DataTypeInterval {\n return [\n clampToInterval(bounds, range[0]),\n clampToInterval(bounds, range[1]),\n ] as DataTypeInterval;\n}\n\n// Validates that the lower bound is <= the upper bound.\nexport function validateDataTypeInterval(\n interval: DataTypeInterval,\n): DataTypeInterval {\n if (dataTypeCompare(interval[0], interval[1]) <= 0) return interval;\n throw new Error(`Invalid interval: [${interval[0]}, ${interval[1]}]`);\n}\n\n// Ensures the lower bound is <= the upper bound.\nexport function normalizeDataTypeInterval(\n interval: DataTypeInterval,\n): DataTypeInterval {\n if (dataTypeCompare(interval[0], interval[1]) <= 0) return interval;\n return [interval[1], interval[0]] as DataTypeInterval;\n}\n\nexport function dataTypeCompare(a: number | Uint64, b: number | Uint64) {\n if (typeof a === \"number\") {\n return (a as number) - (b as number);\n }\n return Uint64.compare(a as Uint64, b as Uint64);\n}\n\nconst tempUint64 = new Uint64();\nconst temp2Uint64 = new Uint64();\n\nexport function getClosestEndpoint(\n range: DataTypeInterval,\n value: number | Uint64,\n): number {\n if (typeof value === \"number\") {\n return Math.abs(value - (range[0] as number)) <\n Math.abs(value - (range[1] as number))\n ? 0\n : 1;\n }\n return Uint64.less(\n Uint64.absDifference(tempUint64, range[0] as Uint64, value as Uint64),\n Uint64.absDifference(temp2Uint64, range[1] as Uint64, value as Uint64),\n )\n ? 0\n : 1;\n}\n\nexport function parseDataTypeValue(\n dataType: DataType,\n x: unknown,\n): number | Uint64 {\n let s: string;\n if (typeof x !== \"string\") {\n s = \"\" + x;\n } else {\n s = x;\n }\n switch (dataType) {\n case DataType.UINT64:\n return Uint64.parseString(s);\n case DataType.FLOAT32: {\n const value = parseFloat(s);\n if (!Number.isFinite(value)) {\n throw new Error(`Invalid float32 value: ${JSON.stringify(s)}`);\n }\n return value;\n }\n default: {\n const value = parseInt(s);\n const dataTypeRange = defaultDataTypeRange[dataType];\n if (\n !Number.isInteger(value) ||\n value < (dataTypeRange[0] as number) ||\n value > (dataTypeRange[1] as number)\n ) {\n throw new Error(\n `Invalid ${DataType[dataType].toLowerCase()} value: ${JSON.stringify(\n s,\n )}`,\n );\n }\n return value;\n }\n }\n}\n\nexport function parseUnknownDataTypeValue(x: unknown): number | Uint64 {\n if (typeof x === \"number\") return x;\n if (typeof x === \"string\") {\n const num64 = new Uint64();\n const num = Number(x);\n if (num64.tryParseString(x)) {\n if (num.toString() === num64.toString()) {\n return num;\n }\n return num64;\n }\n if (!Number.isFinite(num)) {\n throw new Error(`Invalid value: ${JSON.stringify(x)}`);\n }\n return num;\n }\n throw new Error(`Invalid value: ${JSON.stringify(x)}`);\n}\n\nexport function parseDataTypeInterval(\n obj: unknown,\n dataType: DataType,\n): DataTypeInterval {\n return parseFixedLengthArray(new Array(2), obj, (x) =>\n parseDataTypeValue(dataType, x),\n ) as DataTypeInterval;\n}\n\nexport function parseUnknownDataTypeInterval(\n obj: unknown,\n): UnknownDataTypeInterval {\n return parseFixedLengthArray(new Array(2), obj, (x) =>\n parseUnknownDataTypeValue(x),\n ) as UnknownDataTypeInterval;\n}\n\nexport function dataTypeIntervalEqual(\n dataType: DataType,\n a: DataTypeInterval,\n b: DataTypeInterval,\n) {\n if (dataType === DataType.UINT64) {\n return (\n Uint64.equal(a[0] as Uint64, b[0] as Uint64) &&\n Uint64.equal(a[1] as Uint64, b[1] as Uint64)\n );\n }\n return a[0] === b[0] && a[1] === b[1];\n}\n\nexport function dataTypeIntervalToJson(\n range: DataTypeInterval,\n dataType: DataType,\n defaultRange = defaultDataTypeRange[dataType],\n) {\n if (dataTypeIntervalEqual(dataType, range, defaultRange)) return undefined;\n if (dataType === DataType.UINT64) {\n return [range[0].toString(), range[1].toString()];\n }\n return range;\n}\n\nexport function dataTypeValueNextAfter(\n dataType: DataType,\n value: number | Uint64,\n sign: 1 | -1,\n): number | Uint64 {\n switch (dataType) {\n case DataType.FLOAT32:\n return nextAfterFloat64(value as number, sign * Infinity);\n case DataType.UINT64: {\n const v = value as Uint64;\n if (sign === -1) {\n if (v.low === 0 && v.high === 0) return v;\n return Uint64.decrement(new Uint64(), v);\n }\n if (v.low === 0xffffffff && v.high === 0xffffffff) return v;\n return Uint64.increment(new Uint64(), v);\n }\n default: {\n const range = defaultDataTypeRange[dataType] as [number, number];\n return Math.max(range[0], Math.min(range[1], (value as number) + sign));\n }\n }\n}\n\n// Returns the offset such that within the floating point range `[-offset, 1+offset]`, there is an\n// equal-sized interval corresponding to each number in `interval`.\n//\n// For dataType=FLOAT32, always returns 0. For integer data types, returns:\n//\n// 0.5 / (1 + abs(interval[1] - interval[0]))\nexport function getIntervalBoundsEffectiveOffset(\n dataType: DataType,\n interval: DataTypeInterval,\n) {\n switch (dataType) {\n case DataType.FLOAT32:\n return 0;\n case DataType.UINT64:\n return (\n 0.5 /\n Uint64.absDifference(\n tempUint64,\n interval[0] as Uint64,\n interval[1] as Uint64,\n ).toNumber()\n );\n default:\n return 0.5 / Math.abs((interval[0] as number) - (interval[1] as number));\n }\n}\n\nexport function getIntervalBoundsEffectiveFraction(\n dataType: DataType,\n interval: DataTypeInterval,\n) {\n switch (dataType) {\n case DataType.FLOAT32:\n return 1;\n case DataType.UINT64: {\n const diff = Uint64.absDifference(\n tempUint64,\n interval[0] as Uint64,\n interval[1] as Uint64,\n ).toNumber();\n return diff / (diff + 1);\n }\n default: {\n const diff = Math.abs((interval[0] as number) - (interval[1] as number));\n return diff / (diff + 1);\n }\n }\n}\n\nexport function convertDataTypeInterval(\n interval: UnknownDataTypeInterval | undefined,\n dataType: DataType,\n): DataTypeInterval {\n if (interval === undefined) {\n return defaultDataTypeRange[dataType];\n }\n let [lower, upper] = interval;\n if (dataType === DataType.UINT64) {\n if (typeof lower === \"number\") {\n lower = Uint64.fromNumber(lower);\n }\n if (typeof upper === \"number\") {\n upper = Uint64.fromNumber(upper);\n }\n return [lower, upper];\n }\n // Ensure that neither lower nor upper is a `Uint64`.\n if (typeof lower !== \"number\") {\n lower = lower.toNumber();\n }\n if (typeof upper !== \"number\") {\n upper = upper.toNumber();\n }\n if (dataType !== DataType.FLOAT32) {\n lower = Math.round(lower);\n upper = Math.round(upper);\n const range = defaultDataTypeRange[dataType] as [number, number];\n if (!Number.isFinite(lower)) {\n lower = range[0];\n } else {\n lower = Math.min(Math.max(range[0], lower), range[1]);\n }\n if (!Number.isFinite(upper)) {\n upper = range[1];\n } else {\n upper = Math.min(Math.max(range[0], upper), range[1]);\n }\n }\n return [lower, upper];\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { TypedArray } from \"#src/util/array.js\";\n\nexport function getRandomHexString(numBits = 128) {\n const numValues = Math.ceil(numBits / 32);\n const data = new Uint32Array(numValues);\n crypto.getRandomValues(data);\n let s = \"\";\n for (let i = 0; i < numValues; ++i) {\n s += (\"00000000\" + data[i].toString(16)).slice(-8);\n }\n return s;\n}\n\n/**\n * Calls crypto.getRandomValues as many times as needed to fill array.\n */\nexport function getRandomValues(array: T): T {\n const byteArray = new Uint8Array(\n array.buffer,\n array.byteOffset,\n array.byteLength,\n );\n const blockSize = 65536;\n for (let i = 0, length = byteArray.length; i < length; i += blockSize) {\n crypto.getRandomValues(\n byteArray.subarray(i, Math.min(length, i + blockSize)),\n );\n }\n return array;\n}\n\nexport function getRandomUint32() {\n const data = new Uint32Array(1);\n crypto.getRandomValues(data);\n return data[0];\n}\n","/**\n * @license\n * Copyright 2018 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @file Basic annotation data structures.\n */\n\nimport type {\n BoundingBox,\n CoordinateSpaceTransform,\n WatchableCoordinateSpaceTransform,\n} from \"#src/coordinate_transform.js\";\nimport { WatchableValue } from \"#src/trackable_value.js\";\nimport { arraysEqual } from \"#src/util/array.js\";\nimport {\n packColor,\n parseRGBAColorSpecification,\n parseRGBColorSpecification,\n serializeColor,\n unpackRGB,\n unpackRGBA,\n} from \"#src/util/color.js\";\nimport { DataType } from \"#src/util/data_type.js\";\nimport type { Borrowed } from \"#src/util/disposable.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport { Endianness, ENDIANNESS } from \"#src/util/endian.js\";\nimport {\n expectArray,\n parseArray,\n parseFixedLengthArray,\n verifyEnumString,\n verifyFiniteFloat,\n verifyFiniteNonNegativeFloat,\n verifyFloat,\n verifyInt,\n verifyObject,\n verifyObjectProperty,\n verifyOptionalObjectProperty,\n verifyOptionalString,\n verifyString,\n} from \"#src/util/json.js\";\nimport { parseDataTypeValue } from \"#src/util/lerp.js\";\nimport { getRandomHexString } from \"#src/util/random.js\";\nimport { NullarySignal, Signal } from \"#src/util/signal.js\";\nimport { Uint64 } from \"#src/util/uint64.js\";\n\nexport type AnnotationId = string;\n\nexport class AnnotationReference extends RefCounted {\n changed = new NullarySignal();\n\n /**\n * If `undefined`, we are still waiting to look up the result. If `null`, annotation has been\n * deleted.\n */\n value: Annotation | null | undefined;\n\n constructor(public id: AnnotationId) {\n super();\n }\n}\n\nexport enum AnnotationType {\n POINT = 0,\n LINE = 1,\n AXIS_ALIGNED_BOUNDING_BOX = 2,\n ELLIPSOID = 3,\n}\n\nexport const annotationTypes = [\n AnnotationType.POINT,\n AnnotationType.LINE,\n AnnotationType.AXIS_ALIGNED_BOUNDING_BOX,\n AnnotationType.ELLIPSOID,\n];\n\nexport interface AnnotationPropertySpecBase {\n identifier: string;\n description: string | undefined;\n}\n\nexport interface AnnotationColorPropertySpec\n extends AnnotationPropertySpecBase {\n type: \"rgb\" | \"rgba\";\n default: number;\n}\n\nexport interface AnnotationNumericPropertySpec\n extends AnnotationPropertySpecBase {\n type: \"float32\" | \"uint32\" | \"int32\" | \"uint16\" | \"int16\" | \"uint8\" | \"int8\";\n default: number;\n enumValues?: number[];\n enumLabels?: string[];\n min?: number;\n max?: number;\n step?: number;\n tag?: string;\n}\n\nexport interface AnnotationTagPropertySpec\n extends AnnotationNumericPropertySpec {\n type: \"int8\";\n tag: string;\n}\n\nexport const propertyTypeDataType: Record<\n AnnotationPropertySpec[\"type\"],\n DataType | undefined\n> = {\n float32: DataType.FLOAT32,\n uint32: DataType.UINT32,\n int32: DataType.INT32,\n uint16: DataType.UINT16,\n int16: DataType.INT16,\n uint8: DataType.UINT8,\n int8: DataType.INT8,\n rgb: undefined,\n rgba: undefined,\n};\n\nexport type AnnotationPropertySpec =\n | AnnotationColorPropertySpec\n | AnnotationNumericPropertySpec;\n\nexport function isAnnotationNumericPropertySpec(\n spec: AnnotationPropertySpec,\n): spec is AnnotationNumericPropertySpec {\n return spec.type !== \"rgb\" && spec.type !== \"rgba\";\n}\n\nexport function isAnnotationTagPropertySpec(\n spec: AnnotationPropertySpec,\n): spec is AnnotationTagPropertySpec {\n return spec.type === \"uint8\" && spec.tag !== undefined;\n}\n\nexport interface AnnotationPropertyTypeHandler {\n serializedBytes(rank: number): number;\n alignment(rank: number): number;\n serializeCode(property: string, offset: string, rank: number): string;\n deserializeCode(property: string, offset: string, rank: number): string;\n deserializeJson(obj: unknown): number;\n serializeJson(value: number): any;\n}\n\nexport const annotationPropertyTypeHandlers: {\n [K in AnnotationPropertySpec[\"type\"]]: AnnotationPropertyTypeHandler;\n} = {\n rgb: {\n serializedBytes() {\n return 3;\n },\n alignment() {\n return 1;\n },\n serializeCode(property: string, offset: string) {\n return (\n `dv.setUint16(${offset}, ${property}, true);` +\n `dv.setUint8(${offset} + 2, ${property} >>> 16);`\n );\n },\n deserializeCode(property: string, offset: string) {\n return `${property} = dv.getUint16(${offset}, true) | (dv.getUint8(${offset} + 2) << 16);`;\n },\n deserializeJson(obj: unknown) {\n return packColor(parseRGBColorSpecification(obj));\n },\n serializeJson(value: number) {\n return serializeColor(unpackRGB(value));\n },\n },\n rgba: {\n serializedBytes() {\n return 4;\n },\n alignment() {\n return 1;\n },\n serializeCode(property: string, offset: string) {\n return `dv.setUint32(${offset}, ${property}, true);`;\n },\n deserializeCode(property: string, offset: string) {\n return `${property} = dv.getUint32(${offset}, true);`;\n },\n deserializeJson(obj: unknown) {\n return packColor(parseRGBAColorSpecification(obj));\n },\n serializeJson(value: number) {\n return serializeColor(unpackRGBA(value));\n },\n },\n float32: {\n serializedBytes() {\n return 4;\n },\n alignment() {\n return 4;\n },\n serializeCode(property: string, offset: string) {\n return `dv.setFloat32(${offset}, ${property}, isLittleEndian);`;\n },\n deserializeCode(property: string, offset: string) {\n return `${property} = dv.getFloat32(${offset}, isLittleEndian);`;\n },\n deserializeJson(obj: unknown) {\n return verifyFloat(obj);\n },\n serializeJson(value: number) {\n return value;\n },\n },\n uint32: {\n serializedBytes() {\n return 4;\n },\n alignment() {\n return 4;\n },\n serializeCode(property: string, offset: string) {\n return `dv.setUint32(${offset}, ${property}, isLittleEndian);`;\n },\n deserializeCode(property: string, offset: string) {\n return `${property} = dv.getUint32(${offset}, isLittleEndian);`;\n },\n deserializeJson(obj: unknown) {\n return verifyInt(obj);\n },\n serializeJson(value: number) {\n return value;\n },\n },\n int32: {\n serializedBytes() {\n return 4;\n },\n alignment() {\n return 4;\n },\n serializeCode(property: string, offset: string) {\n return `dv.setInt32(${offset}, ${property}, isLittleEndian);`;\n },\n deserializeCode(property: string, offset: string) {\n return `${property} = dv.getInt32(${offset}, isLittleEndian);`;\n },\n deserializeJson(obj: unknown) {\n return verifyInt(obj);\n },\n serializeJson(value: number) {\n return value;\n },\n },\n uint16: {\n serializedBytes() {\n return 2;\n },\n alignment() {\n return 2;\n },\n serializeCode(property: string, offset: string) {\n return `dv.setUint16(${offset}, ${property}, isLittleEndian);`;\n },\n deserializeCode(property: string, offset: string) {\n return `${property} = dv.getUint16(${offset}, isLittleEndian);`;\n },\n deserializeJson(obj: unknown) {\n return verifyInt(obj);\n },\n serializeJson(value: number) {\n return value;\n },\n },\n int16: {\n serializedBytes() {\n return 2;\n },\n alignment() {\n return 2;\n },\n serializeCode(property: string, offset: string) {\n return `dv.setInt16(${offset}, ${property}, isLittleEndian);`;\n },\n deserializeCode(property: string, offset: string) {\n return `${property} = dv.getInt16(${offset}, isLittleEndian);`;\n },\n deserializeJson(obj: unknown) {\n return verifyInt(obj);\n },\n serializeJson(value: number) {\n return value;\n },\n },\n uint8: {\n serializedBytes() {\n return 1;\n },\n alignment() {\n return 1;\n },\n serializeCode(property: string, offset: string) {\n return `dv.setUint8(${offset}, ${property});`;\n },\n deserializeCode(property: string, offset: string) {\n return `${property} = dv.getUint8(${offset});`;\n },\n deserializeJson(obj: unknown) {\n return verifyInt(obj);\n },\n serializeJson(value: number) {\n return value;\n },\n },\n int8: {\n serializedBytes() {\n return 2;\n },\n alignment() {\n return 1;\n },\n serializeCode(property: string, offset: string) {\n return `dv.setInt8(${offset}, ${property});`;\n },\n deserializeCode(property: string, offset: string) {\n return `${property} = dv.getInt8(${offset});`;\n },\n deserializeJson(obj: unknown) {\n return verifyInt(obj);\n },\n serializeJson(value: number) {\n return value;\n },\n },\n};\n\n// Maximum stride value supported by WebGL.\nconst MAX_BUFFER_STRIDE = 255;\n\nexport function getPropertyOffsets(\n rank: number,\n firstGroupInitialOffset: number,\n propertySpecs: readonly Readonly[],\n): {\n serializedBytes: number;\n offsets: { group: number; offset: number }[];\n propertyGroupBytes: number[];\n} {\n let serializedBytes = 0;\n const numProperties = propertySpecs.length;\n const permutation = new Array(numProperties);\n const propertyGroupBytes: number[] = [];\n for (let i = 0; i < numProperties; ++i) {\n permutation[i] = i;\n }\n const getAlignment = (i: number) =>\n annotationPropertyTypeHandlers[propertySpecs[i].type].alignment(rank);\n permutation.sort((i, j) => getAlignment(j) - getAlignment(i));\n let propertyGroupIndex = 0;\n const offsets = new Array<{ group: number; offset: number }>(numProperties);\n let propertyGroupOffset = firstGroupInitialOffset;\n const nextPropertyGroup = () => {\n propertyGroupOffset += (4 - (propertyGroupOffset % 4)) % 4;\n serializedBytes += propertyGroupOffset;\n propertyGroupBytes[propertyGroupIndex] = propertyGroupOffset;\n propertyGroupOffset = 0;\n ++propertyGroupIndex;\n };\n for (let outputIndex = 0; outputIndex < numProperties; ++outputIndex) {\n const propertyIndex = permutation[outputIndex];\n const spec = propertySpecs[propertyIndex];\n const handler = annotationPropertyTypeHandlers[spec.type];\n const numBytes = handler.serializedBytes(rank);\n const alignment = handler.alignment(rank);\n // Check if the property fits in the current property group.\n const alignmentOffset =\n (alignment - (propertyGroupOffset % alignment)) % alignment;\n const newStartOffset = propertyGroupOffset + alignmentOffset;\n const newEndOffset = newStartOffset + numBytes;\n const newAlignedEndOffset = newEndOffset + ((4 - (newEndOffset % 4)) % 4);\n if (newAlignedEndOffset <= MAX_BUFFER_STRIDE) {\n // Property fits\n propertyGroupOffset += alignmentOffset;\n } else {\n // Property does not fit.\n nextPropertyGroup();\n }\n offsets[propertyIndex] = {\n offset: propertyGroupOffset,\n group: propertyGroupIndex,\n };\n propertyGroupOffset += numBytes;\n }\n nextPropertyGroup();\n return { serializedBytes, offsets, propertyGroupBytes };\n}\n\nexport class AnnotationPropertySerializer {\n serializedBytes: number;\n serialize: (\n buffer: DataView,\n offset: number,\n annotationIndex: number,\n annotationCount: number,\n isLittleEndian: boolean,\n properties: any[],\n ) => void;\n deserialize: (\n buffer: DataView,\n offset: number,\n annotationIndex: number,\n annotationCount: number,\n isLittleEndian: boolean,\n properties: any[],\n ) => void;\n propertyGroupBytes: number[];\n constructor(\n public rank: number,\n public firstGroupInitialOffset: number,\n public propertySpecs: readonly Readonly[],\n ) {\n if (propertySpecs.length === 0) {\n this.serializedBytes = firstGroupInitialOffset;\n this.serialize = this.deserialize = () => {};\n this.propertyGroupBytes = [firstGroupInitialOffset];\n return;\n }\n const { serializedBytes, offsets, propertyGroupBytes } = getPropertyOffsets(\n rank,\n firstGroupInitialOffset,\n propertySpecs,\n );\n this.propertyGroupBytes = propertyGroupBytes;\n let groupOffsetCode = \"let groupOffset0 = offset;\";\n for (\n let groupIndex = 1;\n groupIndex < propertyGroupBytes.length;\n ++groupIndex\n ) {\n groupOffsetCode += `let groupOffset${groupIndex} = groupOffset${\n groupIndex - 1\n } + ${propertyGroupBytes[groupIndex - 1]}*annotationCount;`;\n }\n for (\n let groupIndex = 0;\n groupIndex < propertyGroupBytes.length;\n ++groupIndex\n ) {\n groupOffsetCode += `groupOffset${groupIndex} += ${propertyGroupBytes[groupIndex]}*annotationIndex;`;\n }\n let serializeCode = groupOffsetCode;\n let deserializeCode = groupOffsetCode;\n const numProperties = propertySpecs.length;\n for (\n let propertyIndex = 0;\n propertyIndex < numProperties;\n ++propertyIndex\n ) {\n const { group, offset } = offsets[propertyIndex];\n const spec = propertySpecs[propertyIndex];\n const handler = annotationPropertyTypeHandlers[spec.type];\n const propId = `properties[${propertyIndex}]`;\n const offsetExpr = `groupOffset${group} + ${offset}`;\n serializeCode += handler.serializeCode(propId, offsetExpr, rank);\n deserializeCode += handler.deserializeCode(propId, offsetExpr, rank);\n }\n this.serializedBytes = serializedBytes;\n this.serialize = new Function(\n \"dv\",\n \"offset\",\n \"annotationIndex\",\n \"annotationCount\",\n \"isLittleEndian\",\n \"properties\",\n serializeCode,\n ) as any;\n this.deserialize = new Function(\n \"dv\",\n \"offset\",\n \"annotationIndex\",\n \"annotationCount\",\n \"isLittleEndian\",\n \"properties\",\n deserializeCode,\n ) as any;\n }\n}\n\nexport function makeAnnotationPropertySerializers(\n rank: number,\n propertySpecs: readonly Readonly[],\n) {\n const serializers: AnnotationPropertySerializer[] = [];\n for (const annotationType of annotationTypes) {\n const handler = annotationTypeHandlers[annotationType];\n serializers[annotationType] = new AnnotationPropertySerializer(\n rank,\n handler.serializedBytes(rank),\n propertySpecs,\n );\n }\n return serializers;\n}\n\nexport function formatNumericProperty(\n property: AnnotationNumericPropertySpec,\n value: number,\n): string {\n const formattedValue =\n property.type === \"float32\" ? value.toPrecision(6) : value.toString();\n const { enumValues, enumLabels } = property;\n if (enumValues !== undefined) {\n const enumIndex = enumValues.indexOf(value);\n if (enumIndex !== -1) {\n return `${enumLabels![enumIndex]} (${formattedValue})`;\n }\n }\n return formattedValue;\n}\n\nexport function formatAnnotationPropertyValue(\n property: AnnotationPropertySpec,\n value: any,\n): string {\n switch (property.type) {\n case \"rgb\":\n return serializeColor(unpackRGB(value));\n case \"rgba\":\n return serializeColor(unpackRGBA(value));\n default:\n return formatNumericProperty(property, value);\n }\n}\n\nexport function parseAnnotationPropertyId(obj: unknown) {\n const s = verifyString(obj);\n if (s.match(/^[a-z][a-zA-Z0-9_]*$/) === null) {\n throw new Error(`Invalid property identifier: ${JSON.stringify(obj)}`);\n }\n return s;\n}\n\nexport function parseAnnotationPropertyType(obj: unknown) {\n verifyString(obj);\n if (\n !Object.prototype.hasOwnProperty.call(annotationPropertyTypeHandlers, obj)\n ) {\n throw new Error(\"Unsupported property type: $JSON.stringify(obj)}\");\n }\n return obj as AnnotationPropertySpec[\"type\"];\n}\n\nexport function ensureUniqueAnnotationPropertyIds(\n properties: AnnotationPropertySpec[],\n) {\n const ids = new Set();\n for (const p of properties) {\n if (ids.has(p.identifier)) {\n throw new Error(`Duplicate property identifier: ${p.identifier}`);\n }\n ids.add(p.identifier);\n }\n}\n\nfunction parseAnnotationPropertySpec(obj: unknown): AnnotationPropertySpec {\n verifyObject(obj);\n const identifier = verifyObjectProperty(obj, \"id\", parseAnnotationPropertyId);\n const type = verifyObjectProperty(obj, \"type\", parseAnnotationPropertyType);\n const description = verifyOptionalObjectProperty(\n obj,\n \"description\",\n verifyString,\n );\n const defaultValue = verifyOptionalObjectProperty(\n obj,\n \"default\",\n (x) => annotationPropertyTypeHandlers[type].deserializeJson(x),\n 0,\n );\n let enumValues: number[] | undefined;\n let enumLabels: string[] | undefined;\n let tag: string | undefined;\n switch (type) {\n case \"rgb\":\n case \"rgba\":\n break;\n default: {\n const dataType: DataType = DataType[type.toUpperCase() as any] as any;\n enumValues = verifyOptionalObjectProperty(\n obj,\n \"enum_values\",\n (valuesObj) =>\n parseArray(\n valuesObj,\n (x) => parseDataTypeValue(dataType, x) as number,\n ),\n );\n if (enumValues !== undefined) {\n enumLabels = verifyObjectProperty(obj, \"enum_labels\", (labelsObj) =>\n parseFixedLengthArray(\n new Array(enumValues!.length),\n labelsObj,\n verifyString,\n ),\n );\n }\n tag = verifyOptionalObjectProperty(obj, \"tag\", verifyString);\n }\n }\n return {\n type,\n identifier,\n description,\n default: defaultValue,\n enumValues,\n enumLabels,\n tag,\n } as AnnotationPropertySpec;\n}\n\nfunction annotationPropertySpecToJson(spec: AnnotationPropertySpec) {\n const defaultValue = spec.default;\n const isNumeric = isAnnotationNumericPropertySpec(spec);\n const tag = isNumeric ? spec.tag : undefined;\n const enum_values = isNumeric ? spec.enumValues : undefined;\n const enum_labels = isNumeric ? spec.enumLabels : undefined;\n return {\n id: spec.identifier,\n description: spec.description,\n type: spec.type,\n tag,\n enum_values,\n enum_labels,\n default:\n defaultValue === 0\n ? undefined\n : annotationPropertyTypeHandlers[spec.type].serializeJson(defaultValue),\n };\n}\n\nexport function annotationPropertySpecsToJson(\n specs: AnnotationPropertySpec[] | undefined,\n) {\n if (specs === undefined || specs.length === 0) return undefined;\n return specs.map(annotationPropertySpecToJson);\n}\n\nexport function parseAnnotationPropertySpecs(obj: unknown) {\n if (obj === undefined) return [];\n const properties = parseArray(obj, parseAnnotationPropertySpec);\n ensureUniqueAnnotationPropertyIds(properties);\n return properties;\n}\n\nexport interface AnnotationBase {\n /**\n * If equal to `undefined`, then the description is unknown (possibly still being loaded). If\n * equal to `null`, then there is no description.\n */\n description?: string | undefined | null;\n\n id: AnnotationId;\n type: AnnotationType;\n\n relatedSegments?: Uint64[][];\n properties: any[];\n}\n\nexport interface Line extends AnnotationBase {\n pointA: Float32Array;\n pointB: Float32Array;\n type: AnnotationType.LINE;\n}\n\nexport interface Point extends AnnotationBase {\n point: Float32Array;\n type: AnnotationType.POINT;\n}\n\nexport interface AxisAlignedBoundingBox extends AnnotationBase {\n pointA: Float32Array;\n pointB: Float32Array;\n type: AnnotationType.AXIS_ALIGNED_BOUNDING_BOX;\n}\n\nexport interface Ellipsoid extends AnnotationBase {\n center: Float32Array;\n radii: Float32Array;\n type: AnnotationType.ELLIPSOID;\n}\n\nexport type Annotation = Line | Point | AxisAlignedBoundingBox | Ellipsoid;\n\nexport interface AnnotationTypeHandler {\n icon: string;\n description: string;\n toJSON: (annotation: T, rank: number) => any;\n restoreState: (annotation: T, obj: any, rank: number) => void;\n serializedBytes: (rank: number) => number;\n serialize: (\n buffer: DataView,\n offset: number,\n isLittleEndian: boolean,\n rank: number,\n annotation: T,\n ) => void;\n deserialize: (\n buffer: DataView,\n offset: number,\n isLittleEndian: boolean,\n rank: number,\n id: string,\n ) => T;\n visitGeometry: (\n annotation: T,\n callback: (vec: Float32Array, isVector: boolean) => void,\n ) => void;\n}\n\nfunction serializeFloatVector(\n buffer: DataView,\n offset: number,\n isLittleEndian: boolean,\n rank: number,\n vec: Float32Array,\n) {\n for (let i = 0; i < rank; ++i) {\n buffer.setFloat32(offset, vec[i], isLittleEndian);\n offset += 4;\n }\n return offset;\n}\n\nfunction serializeTwoFloatVectors(\n buffer: DataView,\n offset: number,\n isLittleEndian: boolean,\n rank: number,\n vecA: Float32Array,\n vecB: Float32Array,\n) {\n offset = serializeFloatVector(buffer, offset, isLittleEndian, rank, vecA);\n offset = serializeFloatVector(buffer, offset, isLittleEndian, rank, vecB);\n return offset;\n}\n\nfunction deserializeFloatVector(\n buffer: DataView,\n offset: number,\n isLittleEndian: boolean,\n rank: number,\n vec: Float32Array,\n) {\n for (let i = 0; i < rank; ++i) {\n vec[i] = buffer.getFloat32(offset, isLittleEndian);\n offset += 4;\n }\n return offset;\n}\n\nfunction deserializeTwoFloatVectors(\n buffer: DataView,\n offset: number,\n isLittleEndian: boolean,\n rank: number,\n vecA: Float32Array,\n vecB: Float32Array,\n) {\n offset = deserializeFloatVector(buffer, offset, isLittleEndian, rank, vecA);\n offset = deserializeFloatVector(buffer, offset, isLittleEndian, rank, vecB);\n return offset;\n}\n\nexport const annotationTypeHandlers: Record<\n AnnotationType,\n AnnotationTypeHandler\n> = {\n [AnnotationType.LINE]: {\n icon: \"ꕹ\",\n description: \"Line\",\n toJSON(annotation: Line) {\n return {\n pointA: Array.from(annotation.pointA),\n pointB: Array.from(annotation.pointB),\n };\n },\n restoreState(annotation: Line, obj: any, rank: number) {\n annotation.pointA = verifyObjectProperty(obj, \"pointA\", (x) =>\n parseFixedLengthArray(new Float32Array(rank), x, verifyFiniteFloat),\n );\n annotation.pointB = verifyObjectProperty(obj, \"pointB\", (x) =>\n parseFixedLengthArray(new Float32Array(rank), x, verifyFiniteFloat),\n );\n },\n serializedBytes(rank: number) {\n return 2 * 4 * rank;\n },\n serialize(\n buffer: DataView,\n offset: number,\n isLittleEndian: boolean,\n rank: number,\n annotation: Line,\n ) {\n serializeTwoFloatVectors(\n buffer,\n offset,\n isLittleEndian,\n rank,\n annotation.pointA,\n annotation.pointB,\n );\n },\n deserialize: (\n buffer: DataView,\n offset: number,\n isLittleEndian: boolean,\n rank: number,\n id: string,\n ): Line => {\n const pointA = new Float32Array(rank);\n const pointB = new Float32Array(rank);\n deserializeTwoFloatVectors(\n buffer,\n offset,\n isLittleEndian,\n rank,\n pointA,\n pointB,\n );\n return { type: AnnotationType.LINE, pointA, pointB, id, properties: [] };\n },\n visitGeometry(annotation: Line, callback) {\n callback(annotation.pointA, false);\n callback(annotation.pointB, false);\n },\n },\n [AnnotationType.POINT]: {\n icon: \"⚬\",\n description: \"Point\",\n toJSON: (annotation: Point) => {\n return {\n point: Array.from(annotation.point),\n };\n },\n restoreState: (annotation: Point, obj: any, rank: number) => {\n annotation.point = verifyObjectProperty(obj, \"point\", (x) =>\n parseFixedLengthArray(new Float32Array(rank), x, verifyFiniteFloat),\n );\n },\n serializedBytes: (rank) => rank * 4,\n serialize: (\n buffer: DataView,\n offset: number,\n isLittleEndian: boolean,\n rank: number,\n annotation: Point,\n ) => {\n serializeFloatVector(\n buffer,\n offset,\n isLittleEndian,\n rank,\n annotation.point,\n );\n },\n deserialize: (\n buffer: DataView,\n offset: number,\n isLittleEndian: boolean,\n rank: number,\n id: string,\n ): Point => {\n const point = new Float32Array(rank);\n deserializeFloatVector(buffer, offset, isLittleEndian, rank, point);\n return { type: AnnotationType.POINT, point, id, properties: [] };\n },\n visitGeometry(annotation: Point, callback) {\n callback(annotation.point, false);\n },\n },\n [AnnotationType.AXIS_ALIGNED_BOUNDING_BOX]: {\n icon: \"❑\",\n description: \"Bounding Box\",\n toJSON: (annotation: AxisAlignedBoundingBox) => {\n return {\n pointA: Array.from(annotation.pointA),\n pointB: Array.from(annotation.pointB),\n };\n },\n restoreState: (\n annotation: AxisAlignedBoundingBox,\n obj: any,\n rank: number,\n ) => {\n annotation.pointA = verifyObjectProperty(obj, \"pointA\", (x) =>\n parseFixedLengthArray(new Float32Array(rank), x, verifyFiniteFloat),\n );\n annotation.pointB = verifyObjectProperty(obj, \"pointB\", (x) =>\n parseFixedLengthArray(new Float32Array(rank), x, verifyFiniteFloat),\n );\n },\n serializedBytes: (rank) => 2 * 4 * rank,\n serialize(\n buffer: DataView,\n offset: number,\n isLittleEndian: boolean,\n rank: number,\n annotation: AxisAlignedBoundingBox,\n ) {\n serializeTwoFloatVectors(\n buffer,\n offset,\n isLittleEndian,\n rank,\n annotation.pointA,\n annotation.pointB,\n );\n },\n deserialize: (\n buffer: DataView,\n offset: number,\n isLittleEndian: boolean,\n rank: number,\n id: string,\n ): AxisAlignedBoundingBox => {\n const pointA = new Float32Array(rank);\n const pointB = new Float32Array(rank);\n deserializeTwoFloatVectors(\n buffer,\n offset,\n isLittleEndian,\n rank,\n pointA,\n pointB,\n );\n return {\n type: AnnotationType.AXIS_ALIGNED_BOUNDING_BOX,\n pointA,\n pointB,\n id,\n properties: [],\n };\n },\n visitGeometry(annotation: AxisAlignedBoundingBox, callback) {\n callback(annotation.pointA, false);\n callback(annotation.pointB, false);\n },\n },\n [AnnotationType.ELLIPSOID]: {\n icon: \"◎\",\n description: \"Ellipsoid\",\n toJSON: (annotation: Ellipsoid) => {\n return {\n center: Array.from(annotation.center),\n radii: Array.from(annotation.radii),\n };\n },\n restoreState: (annotation: Ellipsoid, obj: any, rank: number) => {\n annotation.center = verifyObjectProperty(obj, \"center\", (x) =>\n parseFixedLengthArray(new Float32Array(rank), x, verifyFiniteFloat),\n );\n annotation.radii = verifyObjectProperty(obj, \"radii\", (x) =>\n parseFixedLengthArray(\n new Float32Array(rank),\n x,\n verifyFiniteNonNegativeFloat,\n ),\n );\n },\n serializedBytes: (rank) => 2 * 4 * rank,\n serialize(\n buffer: DataView,\n offset: number,\n isLittleEndian: boolean,\n rank: number,\n annotation: Ellipsoid,\n ) {\n serializeTwoFloatVectors(\n buffer,\n offset,\n isLittleEndian,\n rank,\n annotation.center,\n annotation.radii,\n );\n },\n deserialize: (\n buffer: DataView,\n offset: number,\n isLittleEndian: boolean,\n rank: number,\n id: string,\n ): Ellipsoid => {\n const center = new Float32Array(rank);\n const radii = new Float32Array(rank);\n deserializeTwoFloatVectors(\n buffer,\n offset,\n isLittleEndian,\n rank,\n center,\n radii,\n );\n return {\n type: AnnotationType.ELLIPSOID,\n center,\n radii,\n id,\n properties: [],\n };\n },\n visitGeometry(annotation: Ellipsoid, callback) {\n callback(annotation.center, false);\n callback(annotation.radii, true);\n },\n },\n};\n\nexport interface AnnotationSchema {\n rank: number;\n relationships: readonly string[];\n properties: WatchableValue[]>;\n}\n\nexport function annotationToJson(\n annotation: Annotation,\n schema: AnnotationSchema,\n) {\n const result = annotationTypeHandlers[annotation.type].toJSON(\n annotation,\n schema.rank,\n );\n result.type = AnnotationType[annotation.type].toLowerCase();\n result.id = annotation.id;\n result.description = annotation.description || undefined;\n const { relatedSegments } = annotation;\n if (relatedSegments?.some((x) => x.length !== 0)) {\n result.segments = relatedSegments.map((segments) =>\n segments.map((x) => x.toString()),\n );\n }\n const propertySpecs = schema.properties.value;\n if (propertySpecs.length !== 0) {\n result.props = annotation.properties.map((prop, i) =>\n annotationPropertyTypeHandlers[propertySpecs[i].type].serializeJson(prop),\n );\n }\n return result;\n}\n\nfunction restoreAnnotation(\n obj: any,\n schema: AnnotationSchema,\n allowMissingId = false,\n): Annotation {\n verifyObject(obj);\n const type = verifyObjectProperty(obj, \"type\", (x) =>\n verifyEnumString(x, AnnotationType),\n );\n const id =\n verifyObjectProperty(\n obj,\n \"id\",\n allowMissingId ? verifyOptionalString : verifyString,\n ) || makeAnnotationId();\n const relatedSegments = verifyObjectProperty(obj, \"segments\", (relObj) => {\n if (relObj === undefined) {\n return schema.relationships.map(() => []);\n }\n const a = expectArray(relObj);\n if (a.length === 0) {\n return schema.relationships.map(() => []);\n }\n if (schema.relationships.length === 1 && !Array.isArray(a[0])) {\n return [parseArray(a, (x) => Uint64.parseString(x))];\n }\n return parseArray(\n expectArray(relObj, schema.relationships.length),\n (segments) => parseArray(segments, (y) => Uint64.parseString(y)),\n );\n });\n const properties = verifyObjectProperty(obj, \"props\", (propsObj) => {\n const propSpecs = schema.properties.value;\n if (propsObj === undefined) return propSpecs.map((x) => x.default);\n return parseArray(expectArray(propsObj, propSpecs.length), (x, i) =>\n annotationPropertyTypeHandlers[propSpecs[i].type].deserializeJson(x),\n );\n });\n const result: Annotation = {\n id,\n description: verifyObjectProperty(obj, \"description\", verifyOptionalString),\n relatedSegments,\n properties,\n type,\n } as Annotation;\n annotationTypeHandlers[type].restoreState(result, obj, schema.rank);\n return result;\n}\n\nexport interface AnnotationSourceSignals {\n changed: NullarySignal;\n childAdded: Signal<(annotation: Annotation) => void>;\n childUpdated: Signal<(annotation: Annotation) => void>;\n childCommitted: Signal<(annotationId: string) => void>;\n childDeleted: Signal<(annotationId: string) => void>;\n}\n\nexport class AnnotationSource\n extends RefCounted\n implements AnnotationSourceSignals\n{\n protected annotationMap = new Map();\n changed = new NullarySignal();\n readonly = false;\n childAdded = new Signal<(annotation: Annotation) => void>();\n childUpdated = new Signal<(annotation: Annotation) => void>();\n childCommitted = new Signal<(annotationId: string) => void>();\n childDeleted = new Signal<(annotationId: string) => void>();\n\n public pending = new Set();\n\n protected rank_: number;\n\n get rank() {\n return this.rank_;\n }\n\n annotationPropertySerializers: AnnotationPropertySerializer[];\n\n constructor(\n rank: number,\n public readonly relationships: readonly string[] = [],\n public readonly properties: WatchableValue<\n readonly Readonly[]\n > = new WatchableValue([]),\n ) {\n super();\n this.rank_ = rank;\n this.annotationPropertySerializers = makeAnnotationPropertySerializers(\n rank,\n properties.value,\n );\n }\n\n hasNonSerializedProperties() {\n return true;\n }\n\n add(annotation: Annotation, commit = true): AnnotationReference {\n this.ensureUpdated();\n if (!annotation.id) {\n annotation.id = makeAnnotationId();\n } else if (this.annotationMap.has(annotation.id)) {\n throw new Error(\n `Annotation id already exists: ${JSON.stringify(annotation.id)}.`,\n );\n }\n this.annotationMap.set(annotation.id, annotation);\n if (!commit) {\n this.pending.add(annotation.id);\n }\n this.changed.dispatch();\n this.childAdded.dispatch(annotation);\n if (commit) {\n this.childCommitted.dispatch(annotation.id);\n }\n return this.getReference(annotation.id);\n }\n\n commit(reference: AnnotationReference): void {\n this.ensureUpdated();\n const id = reference.id;\n this.pending.delete(id);\n this.changed.dispatch();\n this.childCommitted.dispatch(id);\n }\n\n update(reference: AnnotationReference, annotation: Annotation) {\n this.ensureUpdated();\n if (reference.value === null) {\n throw new Error(\"Annotation already deleted.\");\n }\n reference.value = annotation;\n this.annotationMap.set(annotation.id, annotation);\n reference.changed.dispatch();\n this.changed.dispatch();\n this.childUpdated.dispatch(annotation);\n }\n\n [Symbol.iterator]() {\n this.ensureUpdated();\n return this.annotationMap.values();\n }\n\n get(id: AnnotationId) {\n this.ensureUpdated();\n return this.annotationMap.get(id);\n }\n\n delete(reference: AnnotationReference) {\n if (reference.value === null) {\n return;\n }\n reference.value = null;\n this.annotationMap.delete(reference.id);\n this.pending.delete(reference.id);\n reference.changed.dispatch();\n this.changed.dispatch();\n this.childDeleted.dispatch(reference.id);\n }\n\n getReference(id: AnnotationId): AnnotationReference {\n let existing = this.references.get(id);\n if (existing !== undefined) {\n return existing.addRef();\n }\n existing = new AnnotationReference(id);\n existing.value = this.annotationMap.get(id) || null;\n this.references.set(id, existing);\n existing.registerDisposer(() => {\n this.references.delete(id);\n });\n return existing;\n }\n\n references = new Map>();\n\n protected ensureUpdated() {}\n\n toJSON() {\n this.ensureUpdated();\n const result: any[] = [];\n const { pending } = this;\n for (const annotation of this) {\n if (pending.has(annotation.id)) {\n // Don't serialize uncommitted annotations.\n continue;\n }\n result.push(annotationToJson(annotation, this));\n }\n return result;\n }\n\n clear() {\n this.annotationMap.clear();\n this.pending.clear();\n this.changed.dispatch();\n }\n\n restoreState(obj: any) {\n this.ensureUpdated();\n const { annotationMap } = this;\n annotationMap.clear();\n this.pending.clear();\n if (obj !== undefined) {\n parseArray(obj, (x) => {\n const annotation = restoreAnnotation(x, this);\n annotationMap.set(annotation.id, annotation);\n });\n }\n for (const reference of this.references.values()) {\n const { id } = reference;\n const value = annotationMap.get(id);\n reference.value = value || null;\n reference.changed.dispatch();\n }\n this.changed.dispatch();\n }\n\n reset() {\n this.clear();\n }\n}\n\nexport class LocalAnnotationSource extends AnnotationSource {\n private curCoordinateTransform: CoordinateSpaceTransform;\n\n get rank() {\n this.ensureUpdated();\n return this.rank_;\n }\n\n constructor(\n public watchableTransform: WatchableCoordinateSpaceTransform,\n public readonly properties: WatchableValue<\n AnnotationPropertySpec[]\n > = new WatchableValue([]),\n relationships: string[],\n ) {\n super(watchableTransform.value.sourceRank, relationships, properties);\n this.curCoordinateTransform = watchableTransform.value;\n this.registerDisposer(\n watchableTransform.changed.add(() => this.ensureUpdated()),\n );\n\n this.registerDisposer(\n properties.changed.add(() => {\n this.updateAnnotationPropertySerializers();\n this.changed.dispatch();\n }),\n );\n }\n\n updateAnnotationPropertySerializers() {\n this.annotationPropertySerializers = makeAnnotationPropertySerializers(\n this.rank_,\n this.properties.value,\n );\n }\n\n addProperty(property: AnnotationPropertySpec) {\n this.properties.value.push(property);\n for (const annotation of this) {\n annotation.properties.push(property.default);\n }\n this.properties.changed.dispatch();\n }\n\n removeProperty(identifier: string) {\n const propertyIndex = this.properties.value.findIndex(\n (x) => x.identifier === identifier,\n );\n this.properties.value.splice(propertyIndex, 1);\n for (const annotation of this) {\n annotation.properties.splice(propertyIndex, 1);\n }\n this.properties.changed.dispatch();\n }\n\n getTagProperties = () => {\n const { properties } = this;\n return properties.value.filter(isAnnotationTagPropertySpec);\n };\n\n ensureUpdated() {\n const transform = this.watchableTransform.value;\n const { curCoordinateTransform } = this;\n if (transform === curCoordinateTransform) return;\n this.curCoordinateTransform = transform;\n const sourceRank = transform.sourceRank;\n const oldSourceRank = curCoordinateTransform.sourceRank;\n if (\n oldSourceRank === sourceRank &&\n (curCoordinateTransform.inputSpace === transform.inputSpace ||\n arraysEqual(\n curCoordinateTransform.inputSpace.ids.slice(0, sourceRank),\n transform.inputSpace.ids.slice(0, sourceRank),\n ))\n ) {\n return;\n }\n const { ids: newIds } = transform.inputSpace;\n const oldIds = curCoordinateTransform.inputSpace.ids;\n const newToOldDims: number[] = [];\n for (let newDim = 0; newDim < sourceRank; ++newDim) {\n let oldDim = oldIds.indexOf(newIds[newDim]);\n if (oldDim >= oldSourceRank) {\n oldDim = -1;\n }\n newToOldDims.push(oldDim);\n }\n const mapVector = (radii: Float32Array) => {\n const newRadii = new Float32Array(sourceRank);\n for (let i = 0; i < sourceRank; ++i) {\n const oldDim = newToOldDims[i];\n newRadii[i] = oldDim === -1 ? 0 : radii[i];\n }\n return newRadii;\n };\n\n for (const annotation of this.annotationMap.values()) {\n switch (annotation.type) {\n case AnnotationType.POINT:\n annotation.point = mapVector(annotation.point);\n break;\n case AnnotationType.LINE:\n case AnnotationType.AXIS_ALIGNED_BOUNDING_BOX:\n annotation.pointA = mapVector(annotation.pointA);\n annotation.pointB = mapVector(annotation.pointB);\n break;\n case AnnotationType.ELLIPSOID:\n annotation.center = mapVector(annotation.center);\n annotation.radii = mapVector(annotation.radii);\n break;\n }\n }\n if (this.rank_ !== sourceRank) {\n this.rank_ = sourceRank;\n this.updateAnnotationPropertySerializers();\n }\n this.changed.dispatch();\n }\n}\n\nexport const DATA_BOUNDS_DESCRIPTION = \"Data Bounds\";\n\nexport function makeAnnotationId() {\n return getRandomHexString(160);\n}\n\nexport function makeDataBoundsBoundingBoxAnnotation(\n box: BoundingBox,\n): AxisAlignedBoundingBox {\n return {\n type: AnnotationType.AXIS_ALIGNED_BOUNDING_BOX,\n id: \"data-bounds\",\n description: DATA_BOUNDS_DESCRIPTION,\n pointA: new Float32Array(box.lowerBounds),\n pointB: new Float32Array(box.upperBounds),\n properties: [],\n };\n}\n\nexport function makeDataBoundsBoundingBoxAnnotationSet(\n box: BoundingBox,\n): AnnotationSource {\n const annotationSource = new AnnotationSource(box.lowerBounds.length);\n annotationSource.readonly = true;\n annotationSource.add(makeDataBoundsBoundingBoxAnnotation(box));\n return annotationSource;\n}\n\nexport interface SerializedAnnotations {\n data: Uint8Array;\n typeToIds: string[][];\n typeToOffset: number[];\n typeToIdMaps: Map[];\n}\n\nfunction serializeAnnotations(\n allAnnotations: Annotation[][],\n propertySerializers: AnnotationPropertySerializer[],\n): SerializedAnnotations {\n let totalBytes = 0;\n const typeToOffset: number[] = [];\n for (const annotationType of annotationTypes) {\n const propertySerializer = propertySerializers[annotationType];\n const serializedPropertiesBytes = propertySerializer.serializedBytes;\n typeToOffset[annotationType] = totalBytes;\n const annotations: Annotation[] = allAnnotations[annotationType];\n const count = annotations.length;\n totalBytes += serializedPropertiesBytes * count;\n }\n const typeToIds: string[][] = [];\n const typeToIdMaps: Map[] = [];\n const data = new ArrayBuffer(totalBytes);\n const dataView = new DataView(data);\n const isLittleEndian = ENDIANNESS === Endianness.LITTLE;\n for (const annotationType of annotationTypes) {\n const propertySerializer = propertySerializers[annotationType];\n const { rank } = propertySerializer;\n const serializeProperties = propertySerializer.serialize;\n const annotations: Annotation[] = allAnnotations[annotationType];\n typeToIds[annotationType] = annotations.map((x) => x.id);\n typeToIdMaps[annotationType] = new Map(\n annotations.map((x, i) => [x.id, i]),\n );\n const handler = annotationTypeHandlers[annotationType];\n const serialize = handler.serialize;\n const offset = typeToOffset[annotationType];\n const geometryDataStride = propertySerializer.propertyGroupBytes[0];\n for (let i = 0, count = annotations.length; i < count; ++i) {\n const annotation = annotations[i];\n serialize(\n dataView,\n offset + i * geometryDataStride,\n isLittleEndian,\n rank,\n annotation,\n );\n serializeProperties(\n dataView,\n offset,\n i,\n count,\n isLittleEndian,\n annotation.properties,\n );\n }\n }\n return { data: new Uint8Array(data), typeToIds, typeToOffset, typeToIdMaps };\n}\n\nexport class AnnotationSerializer {\n annotations: [Point[], Line[], AxisAlignedBoundingBox[], Ellipsoid[]] = [\n [],\n [],\n [],\n [],\n ];\n constructor(public propertySerializers: AnnotationPropertySerializer[]) {}\n add(annotation: Annotation) {\n (this.annotations[annotation.type]).push(annotation);\n }\n serialize(): SerializedAnnotations {\n return serializeAnnotations(this.annotations, this.propertySerializers);\n }\n}\n\nexport function fixAnnotationAfterStructuredCloning(obj: Annotation | null) {\n if (obj == null) {\n return obj;\n }\n const { relatedSegments } = obj;\n if (relatedSegments !== undefined) {\n for (\n let i = 0, numRelationships = relatedSegments.length;\n i < numRelationships;\n ++i\n ) {\n const segments = relatedSegments[i];\n if (segments === undefined) continue;\n relatedSegments[i] = segments.map(\n (x: { low: number; high: number }) => new Uint64(x.low, x.high),\n );\n }\n }\n return obj;\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { binarySearchLowerBound } from \"#src/util/array.js\";\n\nexport interface SiPrefix {\n readonly prefix: string;\n readonly exponent: number;\n readonly longPrefix?: string;\n}\n\nexport const preferredSiPrefixes: readonly SiPrefix[] = [\n { prefix: \"Y\", exponent: 24, longPrefix: \"yotta\" },\n { prefix: \"Z\", exponent: 21, longPrefix: \"zetta\" },\n { prefix: \"E\", exponent: 18, longPrefix: \"exa\" },\n { prefix: \"P\", exponent: 15, longPrefix: \"peta\" },\n { prefix: \"T\", exponent: 12, longPrefix: \"tera\" },\n { prefix: \"G\", exponent: 9, longPrefix: \"giga\" },\n { prefix: \"M\", exponent: 6, longPrefix: \"mega\" },\n { prefix: \"k\", exponent: 3, longPrefix: \"kilo\" },\n { prefix: \"\", exponent: 0, longPrefix: \"\" },\n { prefix: \"m\", exponent: -3, longPrefix: \"milli\" },\n { prefix: \"µ\", exponent: -6, longPrefix: \"micro\" },\n { prefix: \"n\", exponent: -9, longPrefix: \"nano\" },\n { prefix: \"p\", exponent: -12, longPrefix: \"pico\" },\n { prefix: \"f\", exponent: -15, longPrefix: \"femto\" },\n { prefix: \"a\", exponent: -18, longPrefix: \"atto\" },\n { prefix: \"z\", exponent: -21, longPrefix: \"zepto\" },\n { prefix: \"y\", exponent: -24, longPrefix: \"yocto\" },\n];\n\nexport const allSiPrefixes: readonly SiPrefix[] = [\n ...preferredSiPrefixes,\n { prefix: \"h\", exponent: 2, longPrefix: \"hecto\" },\n { prefix: \"da\", exponent: 1, longPrefix: \"deca\" },\n { prefix: \"d\", exponent: -1, longPrefix: \"deci\" },\n { prefix: \"c\", exponent: -2, longPrefix: \"centi\" },\n];\n\nconst siPrefixesWithAlternatives: readonly SiPrefix[] = [\n { prefix: \"u\", exponent: -6 }, // Also allow \"u\" for micro\n ...allSiPrefixes,\n];\n\nexport const supportedUnits = new Map<\n string,\n { unit: string; exponent: number }\n>();\nsupportedUnits.set(\"\", { unit: \"\", exponent: 0 });\nexport const exponentToPrefix = new Map();\nfor (const { prefix, exponent } of siPrefixesWithAlternatives) {\n exponentToPrefix.set(exponent, prefix);\n for (const unit of [\"m\", \"s\", \"Hz\", \"rad/s\"]) {\n supportedUnits.set(`${prefix}${unit}`, { unit, exponent });\n }\n}\n\nexport function pickSiPrefix(x: number): SiPrefix {\n const exponent = Math.log10(x);\n const numPrefixes = preferredSiPrefixes.length;\n const i = binarySearchLowerBound(\n 0,\n numPrefixes,\n (i) => preferredSiPrefixes[i].exponent <= exponent,\n );\n return preferredSiPrefixes[Math.min(i, numPrefixes - 1)];\n}\n\ninterface FormatScaleWithUnitOptions {\n precision?: number;\n elide1?: boolean;\n}\n\nexport function formatScaleWithUnit(\n scale: number,\n unit: string,\n options: FormatScaleWithUnitOptions = {},\n): { scale: string; prefix: string; unit: string } {\n const { precision = 6, elide1 = true } = options;\n let adjustedScale = scale;\n let prefix = \"\";\n if (unit !== \"\") {\n const result = pickSiPrefix(scale);\n prefix = result.prefix;\n adjustedScale = scaleByExp10(scale, -result.exponent);\n }\n if (elide1 && adjustedScale === 1) {\n return { scale: \"\", unit, prefix };\n }\n let scaleString: string;\n if (precision !== 0) {\n if (adjustedScale < 1 || adjustedScale >= 1000) {\n scaleString = adjustedScale.toPrecision(precision);\n } else {\n scaleString = adjustedScale.toFixed(precision);\n }\n const eIndex = scaleString.indexOf(\"e\");\n let numString: string;\n let exponentString: string;\n if (eIndex !== -1) {\n numString = scaleString.substring(0, eIndex);\n exponentString = scaleString.substring(eIndex);\n } else {\n numString = scaleString;\n exponentString = \"\";\n }\n const m = numString.match(/.*\\.(?:[0-9]*[1-9])?(0+)$/);\n if (m !== null) {\n numString = numString.substring(0, numString.length - m[1].length);\n if (numString.endsWith(\".\")) {\n numString = numString.substring(0, numString.length - 1);\n }\n scaleString = numString + exponentString;\n }\n } else {\n scaleString = adjustedScale.toString();\n }\n return {\n scale: scaleString,\n unit,\n prefix,\n };\n}\n\nexport function formatScaleWithUnitAsString(\n scale: number,\n unit: string,\n options?: FormatScaleWithUnitOptions,\n): string {\n const {\n scale: formattedScale,\n unit: formattedUnit,\n prefix,\n } = formatScaleWithUnit(scale, unit, options);\n return `${formattedScale}${prefix}${formattedUnit}`;\n}\n\nexport function parseScale(s: string) {\n if (s === \"\") {\n return { scale: 1, unit: \"\" };\n }\n const match = s.match(\n /^((?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)?([µa-zA-Z]+)?$/,\n );\n if (match === null) return undefined;\n const scaleString = match[1];\n let scale = scaleString === undefined ? 1 : Number(scaleString);\n if (Number.isNaN(scale)) return undefined;\n let unit = \"\";\n if (match[2] !== undefined) {\n const result = supportedUnits.get(match[2]);\n if (result === undefined) {\n return undefined;\n }\n unit = result.unit;\n if (result.exponent > 0) {\n scale *= 10 ** result.exponent;\n } else {\n scale /= 10 ** -result.exponent;\n }\n }\n if (scale <= 0 || !Number.isFinite(scale)) return undefined;\n return { scale, unit };\n}\n\nexport function unitFromJson(x: unknown) {\n const result = supportedUnits.get(x as string);\n if (result === undefined) {\n throw new Error(`Invalid unit: ${JSON.stringify(x)}`);\n }\n return result;\n}\n\n/**\n * Returns `scale * 10**exponent`, but uses division for negative exponents to reduce loss of\n * precision.\n */\nexport function scaleByExp10(scale: number, exponent: number) {\n if (exponent >= 0) return scale * 10 ** exponent;\n return scale / 10 ** -exponent;\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { TypedArray } from \"#src/util/array.js\";\n\nexport function equal(a: T, b: U) {\n const n = a.length;\n for (let i = 0; i < n; ++i) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n}\n\nexport function add<\n Out extends TypedArray,\n A extends TypedArray,\n B extends TypedArray,\n>(out: Out, a: A, b: B) {\n const rank = out.length;\n for (let i = 0; i < rank; ++i) {\n out[i] = a[i] + b[i];\n }\n return out;\n}\nexport function subtract<\n Out extends TypedArray,\n A extends TypedArray,\n B extends TypedArray,\n>(out: Out, a: A, b: B) {\n const rank = out.length;\n for (let i = 0; i < rank; ++i) {\n out[i] = a[i] - b[i];\n }\n return out;\n}\nexport function multiply<\n Out extends TypedArray,\n A extends TypedArray,\n B extends TypedArray,\n>(out: Out, a: A, b: B) {\n const rank = out.length;\n for (let i = 0; i < rank; ++i) {\n out[i] = a[i] * b[i];\n }\n return out;\n}\nexport function divide<\n Out extends TypedArray,\n A extends TypedArray,\n B extends TypedArray,\n>(out: Out, a: A, b: B) {\n const rank = out.length;\n for (let i = 0; i < rank; ++i) {\n out[i] = a[i] / b[i];\n }\n return out;\n}\nexport function scaleAndAdd<\n Out extends TypedArray,\n A extends TypedArray,\n B extends TypedArray,\n>(out: Out, a: A, b: B, scale: number) {\n const rank = out.length;\n for (let i = 0; i < rank; ++i) {\n out[i] = a[i] + b[i] * scale;\n }\n return out;\n}\nexport function scale(\n out: Out,\n a: A,\n scale: number,\n) {\n const rank = out.length;\n for (let i = 0; i < rank; ++i) {\n out[i] = a[i] * scale;\n }\n return out;\n}\n\nexport function prod(array: ArrayLike) {\n let result = 1;\n for (let i = 0, length = array.length; i < length; ++i) {\n result *= array[i];\n }\n return result;\n}\n\nexport function min<\n Out extends TypedArray,\n A extends TypedArray,\n B extends TypedArray,\n>(out: Out, a: A, b: B) {\n const rank = out.length;\n for (let i = 0; i < rank; ++i) {\n out[i] = Math.min(a[i], b[i]);\n }\n return out;\n}\n\nexport function max<\n Out extends TypedArray,\n A extends TypedArray,\n B extends TypedArray,\n>(out: Out, a: A, b: B) {\n const rank = out.length;\n for (let i = 0; i < rank; ++i) {\n out[i] = Math.max(a[i], b[i]);\n }\n return out;\n}\n\nexport const kEmptyFloat32Vec = new Float32Array(0);\nexport const kEmptyFloat64Vec = new Float64Array(0);\nexport const kFloat64Vec3Of1 = Float64Array.of(1, 1, 1);\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { WatchableValueInterface } from \"#src/trackable_value.js\";\nimport { WatchableValue } from \"#src/trackable_value.js\";\nimport type { TypedArray } from \"#src/util/array.js\";\nimport {\n arraysEqual,\n arraysEqualWithPredicate,\n getInsertPermutation,\n} from \"#src/util/array.js\";\nimport {\n getDependentTransformInputDimensions,\n mat4,\n quat,\n vec3,\n} from \"#src/util/geom.js\";\nimport {\n expectArray,\n parseArray,\n parseFiniteVec,\n parseFixedLengthArray,\n verifyFiniteFloat,\n verifyFinitePositiveFloat,\n verifyIntegerArray,\n verifyObject,\n verifyObjectProperty,\n verifyOptionalObjectProperty,\n verifyString,\n verifyStringArray,\n} from \"#src/util/json.js\";\nimport * as matrix from \"#src/util/matrix.js\";\nimport {\n scaleByExp10,\n supportedUnits,\n unitFromJson,\n} from \"#src/util/si_units.js\";\nimport { NullarySignal } from \"#src/util/signal.js\";\nimport type { Trackable } from \"#src/util/trackable.js\";\nimport * as vector from \"#src/util/vector.js\";\n\nexport type DimensionId = number;\n\nlet nextDimensionId = 0;\n\nexport function newDimensionId(): DimensionId {\n return ++nextDimensionId;\n}\n\nexport interface CoordinateArray {\n // Indicates whether this coordinate array was specified explicitly, in which case it will be\n // encoded in the JSON representation.\n explicit: boolean;\n // Specifies the coordinates. Must be montonically increasing integers.\n coordinates: number[];\n // Specifies the label for each coordinate in `coordinates`.\n labels: string[];\n}\n\nexport interface CoordinateSpace {\n /**\n * If `true`, has been fully initialized (i.e. based on at least one data source). If `false`,\n * may be partially initialized.\n */\n readonly valid: boolean;\n\n readonly rank: number;\n\n /**\n * Specifies the name of each dimension.\n */\n readonly names: readonly string[];\n\n readonly ids: readonly DimensionId[];\n\n /**\n * Timestamp of last user action that changed the name, scale, or unit of each dimension, or\n * `undefined` if there was no user action.\n */\n readonly timestamps: readonly number[];\n\n /**\n * Specifies the physical units corresponding to this dimension. May be empty to indicate\n * unitless.\n */\n readonly units: readonly string[];\n\n /**\n * Specifies a scale for this dimension.\n */\n readonly scales: Float64Array;\n\n readonly bounds: CoordinateSpaceBounds;\n readonly boundingBoxes: readonly TransformedBoundingBox[];\n\n readonly coordinateArrays: (CoordinateArray | undefined)[];\n}\n\nexport function boundingBoxesEqual(a: BoundingBox, b: BoundingBox) {\n return (\n arraysEqual(a.lowerBounds, b.lowerBounds) &&\n arraysEqual(a.upperBounds, b.upperBounds)\n );\n}\n\nexport function coordinateArraysEqual(\n a: CoordinateArray | undefined,\n b: CoordinateArray | undefined,\n) {\n if (a === undefined) return b === undefined;\n if (b === undefined) return false;\n return (\n a.explicit === b.explicit &&\n arraysEqual(a.coordinates, b.coordinates) &&\n arraysEqual(a.labels, b.labels)\n );\n}\n\nexport function normalizeCoordinateArray(\n coordinates: number[],\n labels: string[],\n) {\n const map = new Map();\n for (let i = 0, length = coordinates.length; i < length; ++i) {\n map.set(coordinates[i], labels[i]);\n }\n coordinates = Array.from(map.keys());\n coordinates.sort((a, b) => a - b);\n labels = Array.from(coordinates, (x) => map.get(x)!);\n return { coordinates, labels };\n}\n\nexport function mergeCoordinateArrays(\n coordinateArrays: ReadonlyArray,\n): CoordinateArray {\n if (coordinateArrays.length === 1) return coordinateArrays[0];\n const map = new Map();\n let explicit = false;\n for (const x of coordinateArrays) {\n if (x.explicit) explicit = true;\n const { coordinates, labels } = x;\n for (let i = 0, length = coordinates.length; i < length; ++i) {\n map.set(coordinates[i], labels[i]);\n }\n }\n const coordinates = Array.from(map.keys());\n coordinates.sort((a, b) => a - b);\n const labels = Array.from(coordinates, (x) => map.get(x)!);\n return { explicit, coordinates, labels };\n}\n\nexport function mergeOptionalCoordinateArrays(\n coordinateArrays: ReadonlyArray,\n): CoordinateArray | undefined {\n coordinateArrays = coordinateArrays.filter((x) => x !== undefined);\n if (coordinateArrays.length === 0) return undefined;\n return mergeCoordinateArrays(\n coordinateArrays as ReadonlyArray,\n );\n}\n\nexport function transformedBoundingBoxesEqual(\n a: TransformedBoundingBox,\n b: TransformedBoundingBox,\n) {\n return (\n arraysEqual(a.transform, b.transform) && boundingBoxesEqual(a.box, b.box)\n );\n}\n\nexport function coordinateSpacesEqual(a: CoordinateSpace, b: CoordinateSpace) {\n return (\n a.valid === b.valid &&\n a.rank === b.rank &&\n arraysEqual(a.names, b.names) &&\n arraysEqual(a.ids, b.ids) &&\n arraysEqual(a.timestamps, b.timestamps) &&\n arraysEqual(a.units, b.units) &&\n arraysEqual(a.scales, b.scales) &&\n arraysEqualWithPredicate(\n a.boundingBoxes,\n b.boundingBoxes,\n transformedBoundingBoxesEqual,\n ) &&\n arraysEqualWithPredicate(\n a.coordinateArrays,\n b.coordinateArrays,\n coordinateArraysEqual,\n )\n );\n}\n\nexport function unitsFromJson(\n units: string[],\n scaleExponents: Float64Array,\n obj: any,\n) {\n parseFixedLengthArray(units, obj, (x: any, index: number) => {\n const result = unitFromJson(x);\n scaleExponents[index] = result.exponent;\n return result.unit;\n });\n}\n\nexport function makeCoordinateSpace(space: {\n readonly valid?: boolean;\n readonly names: readonly string[];\n readonly units: readonly string[];\n readonly scales: Float64Array;\n readonly rank?: number;\n readonly timestamps?: readonly number[];\n readonly ids?: readonly DimensionId[];\n readonly boundingBoxes?: readonly TransformedBoundingBox[];\n readonly bounds?: CoordinateSpaceBounds;\n readonly coordinateArrays?: (CoordinateArray | undefined)[];\n}): CoordinateSpace {\n const { names, units, scales } = space;\n const {\n valid = true,\n rank = names.length,\n timestamps = names.map(() => Number.NEGATIVE_INFINITY),\n ids = names.map((_, i) => -i),\n boundingBoxes = [],\n } = space;\n const { coordinateArrays = new Array(rank) } =\n space;\n const { bounds = computeCombinedBounds(boundingBoxes, rank) } = space;\n return {\n valid,\n rank,\n names,\n timestamps,\n ids,\n units,\n scales,\n boundingBoxes,\n bounds,\n coordinateArrays,\n };\n}\n\nexport const emptyInvalidCoordinateSpace = makeCoordinateSpace({\n valid: false,\n names: [],\n units: [],\n scales: vector.kEmptyFloat64Vec,\n boundingBoxes: [],\n});\n\nexport const emptyValidCoordinateSpace = makeCoordinateSpace({\n valid: true,\n names: [],\n units: [],\n scales: vector.kEmptyFloat64Vec,\n boundingBoxes: [],\n});\n\nfunction unitAndScaleFromJson(obj: unknown) {\n const [scaleObj, unitObj] = expectArray(obj, 2);\n const scale = verifyFinitePositiveFloat(scaleObj);\n const unitString = verifyString(unitObj);\n const result = supportedUnits.get(unitString);\n if (result === undefined)\n throw new Error(`Invalid unit: ${JSON.stringify(unitString)}`);\n return { unit: result.unit, scale: scaleByExp10(scale, result.exponent) };\n}\n\nexport function coordinateSpaceFromJson(\n obj: any,\n allowNumericalDimensions = false,\n): CoordinateSpace {\n if (obj === undefined) return emptyInvalidCoordinateSpace;\n verifyObject(obj);\n const names = dimensionNamesFromJson(\n Object.keys(obj),\n allowNumericalDimensions,\n );\n const rank = names.length;\n const units = new Array(rank);\n const scales = new Float64Array(rank);\n const coordinateArrays = new Array(rank);\n for (let i = 0; i < rank; ++i) {\n verifyObjectProperty(obj, names[i], (mem) => {\n if (Array.isArray(mem)) {\n // Normal unit-scale dimension.\n const { unit, scale } = unitAndScaleFromJson(mem);\n units[i] = unit;\n scales[i] = scale;\n } else {\n // Coordinate array dimension.\n verifyObject(mem);\n const coordinates = verifyObjectProperty(\n mem,\n \"coordinates\",\n verifyIntegerArray,\n );\n const labels = verifyObjectProperty(mem, \"labels\", verifyStringArray);\n const length = coordinates.length;\n if (length !== labels.length) {\n throw new Error(\n `Length of coordinates array (${length}) ` +\n `does not match length of labels array (${labels.length})`,\n );\n }\n units[i] = \"\";\n scales[i] = 1;\n coordinateArrays[i] = {\n explicit: true,\n ...normalizeCoordinateArray(coordinates, labels),\n };\n }\n });\n }\n return makeCoordinateSpace({\n valid: false,\n names,\n units,\n scales,\n coordinateArrays,\n });\n}\n\nexport function coordinateSpaceToJson(coordinateSpace: CoordinateSpace): any {\n const { rank } = coordinateSpace;\n if (rank === 0) return undefined;\n const { names, units, scales, coordinateArrays } = coordinateSpace;\n const json: any = {};\n for (let i = 0; i < rank; ++i) {\n const name = names[i];\n const coordinateArray = coordinateArrays[i];\n if (coordinateArray?.explicit) {\n json[name] = {\n coordinates: Array.from(coordinateArray.coordinates),\n labels: coordinateArray.labels,\n };\n } else {\n json[name] = [scales[i], units[i]];\n }\n }\n return json;\n}\n\nexport class TrackableCoordinateSpace extends WatchableValue {\n constructor() {\n super(emptyInvalidCoordinateSpace);\n }\n\n toJSON() {\n return coordinateSpaceToJson(this.value);\n }\n reset() {\n this.value = emptyInvalidCoordinateSpace;\n }\n restoreState(obj: any) {\n this.value = coordinateSpaceFromJson(obj);\n }\n}\n\nexport interface BoundingBox {\n lowerBounds: Float64Array;\n upperBounds: Float64Array;\n}\n\nexport interface CoordinateSpaceBounds extends BoundingBox {\n voxelCenterAtIntegerCoordinates: boolean[];\n}\n\nexport function roundCoordinateToVoxelCenter(\n bounds: CoordinateSpaceBounds,\n dimIndex: number,\n coordinate: number,\n) {\n if (bounds.voxelCenterAtIntegerCoordinates[dimIndex]) {\n coordinate = Math.round(coordinate);\n } else {\n coordinate = Math.floor(coordinate) + 0.5;\n }\n return coordinate;\n}\n\nexport function getDisplayLowerUpperBounds(\n bounds: CoordinateSpaceBounds,\n dimIndex: number,\n) {\n let lower = bounds.lowerBounds[dimIndex];\n let upper = bounds.upperBounds[dimIndex];\n if (bounds.voxelCenterAtIntegerCoordinates[dimIndex]) {\n lower += 0.5;\n upper += 0.5;\n }\n return [lower, upper];\n}\n\n// Clamps `coordinate` to `[lower, upper - 1]`. This is intended to be used with\n// `roundCoordinateToVoxelCenter`. If not rounding, it may be desirable to instead\n// clamp to `[lower upper]`.\nexport function clampCoordinateToBounds(\n bounds: CoordinateSpaceBounds,\n dimIndex: number,\n coordinate: number,\n) {\n const upperBound = bounds.upperBounds[dimIndex];\n if (Number.isFinite(upperBound)) {\n coordinate = Math.min(coordinate, upperBound - 1);\n }\n\n const lowerBound = bounds.lowerBounds[dimIndex];\n if (Number.isFinite(lowerBound)) {\n coordinate = Math.max(coordinate, lowerBound);\n }\n return coordinate;\n}\n\nexport function clampAndRoundCoordinateToVoxelCenter(\n bounds: CoordinateSpaceBounds,\n dimIndex: number,\n coordinate: number,\n): number {\n coordinate = clampCoordinateToBounds(bounds, dimIndex, coordinate);\n return roundCoordinateToVoxelCenter(bounds, dimIndex, coordinate);\n}\n\nexport function getCenterBound(lower: number, upper: number) {\n let x = (lower + upper) / 2;\n if (!Number.isFinite(x)) x = Math.min(Math.max(0, lower), upper);\n return x;\n}\n\nexport function getBoundingBoxCenter(\n out: Float32Array,\n bounds: BoundingBox,\n): Float32Array {\n const { lowerBounds, upperBounds } = bounds;\n const rank = out.length;\n for (let i = 0; i < rank; ++i) {\n out[i] = getCenterBound(lowerBounds[i], upperBounds[i]);\n }\n return out;\n}\n\nexport interface TransformedBoundingBox {\n box: BoundingBox;\n\n /**\n * Transform from \"box\" coordinate space to target coordinate space.\n */\n transform: Float64Array;\n}\n\nexport function makeIdentityTransformedBoundingBox(box: BoundingBox) {\n const rank = box.lowerBounds.length;\n return {\n box,\n transform: matrix.createIdentity(Float64Array, rank, rank + 1),\n };\n}\n\nexport function computeCombinedLowerUpperBound(\n boundingBox: TransformedBoundingBox,\n outputDimension: number,\n outputRank: number,\n): { lower: number; upper: number } | undefined {\n const {\n box: { lowerBounds: baseLowerBounds, upperBounds: baseUpperBounds },\n transform,\n } = boundingBox;\n const inputRank = baseLowerBounds.length;\n const stride = outputRank;\n const offset = transform[stride * inputRank + outputDimension];\n let targetLower = offset;\n let targetUpper = offset;\n let hasCoefficient = false;\n for (let inputDim = 0; inputDim < inputRank; ++inputDim) {\n const c = transform[stride * inputDim + outputDimension];\n if (c === 0) continue;\n const lower = c * baseLowerBounds[inputDim];\n const upper = c * baseUpperBounds[inputDim];\n targetLower += Math.min(lower, upper);\n targetUpper += Math.max(lower, upper);\n hasCoefficient = true;\n }\n if (!hasCoefficient) return undefined;\n return { lower: targetLower, upper: targetUpper };\n}\n\nexport function computeCombinedBounds(\n boundingBoxes: readonly TransformedBoundingBox[],\n outputRank: number,\n): CoordinateSpaceBounds {\n const lowerBounds = new Float64Array(outputRank);\n const upperBounds = new Float64Array(outputRank);\n lowerBounds.fill(Number.NEGATIVE_INFINITY);\n upperBounds.fill(Number.POSITIVE_INFINITY);\n\n // Number of bounding boxes for which both lower and upper bound has a fractional part of `0.5`.\n const halfIntegerBounds = new Array(outputRank);\n halfIntegerBounds.fill(0);\n\n // Number of bounding boxes for which both lower and upper bound has a fractional part of `0.0`.\n const integerBounds = new Array(outputRank);\n integerBounds.fill(0);\n\n for (const boundingBox of boundingBoxes) {\n for (let outputDim = 0; outputDim < outputRank; ++outputDim) {\n const result = computeCombinedLowerUpperBound(\n boundingBox,\n outputDim,\n outputRank,\n );\n if (result === undefined) continue;\n const { lower: targetLower, upper: targetUpper } = result;\n if (Number.isFinite(targetLower) && Number.isFinite(targetUpper)) {\n const lowerFloor = Math.floor(targetLower);\n const upperFloor = Math.floor(targetUpper);\n if (lowerFloor === targetLower && upperFloor === targetUpper) {\n ++integerBounds[outputDim];\n } else if (\n targetLower - lowerFloor === 0.5 &&\n targetUpper - upperFloor === 0.5\n ) {\n ++halfIntegerBounds[outputDim];\n }\n }\n lowerBounds[outputDim] =\n lowerBounds[outputDim] === Number.NEGATIVE_INFINITY\n ? targetLower\n : Math.min(lowerBounds[outputDim], targetLower);\n upperBounds[outputDim] =\n upperBounds[outputDim] === Number.POSITIVE_INFINITY\n ? targetUpper\n : Math.max(upperBounds[outputDim], targetUpper);\n }\n }\n\n const voxelCenterAtIntegerCoordinates = integerBounds.map(\n (integerCount, i) => {\n const halfIntegerCount = halfIntegerBounds[i];\n // If all bounding boxes have half-integer bounds, assume voxel center is at integer\n // coordinates. Otherwise, assume voxel center is at half-integer coordinates.\n return halfIntegerCount > 0 && integerCount === 0;\n },\n );\n return { lowerBounds, upperBounds, voxelCenterAtIntegerCoordinates };\n}\n\nexport function extendTransformedBoundingBox(\n boundingBox: TransformedBoundingBox,\n newOutputRank: number,\n newOutputDims: readonly number[],\n): TransformedBoundingBox {\n const { transform: oldTransform, box } = boundingBox;\n const oldOutputRank = newOutputDims.length;\n const inputRank = box.lowerBounds.length;\n const newTransform = new Float64Array((inputRank + 1) * newOutputRank);\n for (let oldOutputDim = 0; oldOutputDim < oldOutputRank; ++oldOutputDim) {\n const newOutputDim = newOutputDims[oldOutputDim];\n if (newOutputDim === -1) continue;\n for (let inputDim = 0; inputDim <= inputRank; ++inputDim) {\n newTransform[inputDim * newOutputRank + newOutputDim] =\n oldTransform[inputDim * oldOutputRank + oldOutputDim];\n }\n }\n return {\n transform: newTransform,\n box,\n };\n}\n\nexport function makeSingletonDimTransformedBoundingBox(\n outputRank: number,\n outputDim: number,\n) {\n const box = {\n lowerBounds: Float64Array.of(0),\n upperBounds: Float64Array.of(1),\n };\n const transform = new Float64Array(2 * outputRank);\n transform[outputDim] = 1;\n return { transform, box };\n}\n\nexport function extendTransformedBoundingBoxUpToRank(\n boundingBox: TransformedBoundingBox,\n oldOutputRank: number,\n newOutputRank: number,\n): TransformedBoundingBox {\n if (oldOutputRank === newOutputRank) return boundingBox;\n const { box } = boundingBox;\n const inputRank = box.lowerBounds.length;\n const transform = new Float64Array((inputRank + 1) * newOutputRank);\n matrix.copy(\n transform,\n newOutputRank,\n boundingBox.transform,\n oldOutputRank,\n oldOutputRank,\n inputRank + 1,\n );\n return { box, transform };\n}\n\nexport interface CoordinateSpaceTransform {\n /**\n * Equal to `outputSpace.rank`.\n */\n readonly rank: number;\n\n /**\n * The source rank, which is <= rank. Input dimensions >= sourceRank are synthetic and serve only\n * to embed the source data in a larger view space.\n */\n readonly sourceRank: number;\n\n /**\n * May have rank less than `outputSpace.rank`, in which case additional unnamed dimensions with\n * range `[0, 1)` are implicitly added.\n */\n readonly inputSpace: CoordinateSpace;\n\n readonly outputSpace: CoordinateSpace;\n\n /**\n * `(rank + 1) * (rank + 1)` homogeneous column-major transformation matrix, where columns\n * correspond to input dimensions and rows correspond to output dimensions.\n */\n readonly transform: Float64Array;\n}\n\nexport function coordinateSpaceTransformsEquivalent(\n defaultTransform: CoordinateSpaceTransform,\n transform: CoordinateSpaceTransform,\n) {\n const { rank, sourceRank } = defaultTransform;\n if (rank !== transform.rank || sourceRank !== transform.sourceRank)\n return false;\n const { inputSpace: defaultInputSpace } = defaultTransform;\n const { inputSpace } = transform;\n if (\n !arraysEqual(inputSpace.scales, defaultInputSpace.scales) ||\n !arraysEqual(inputSpace.units, defaultInputSpace.units) ||\n !arraysEqual(\n transform.outputSpace.names,\n defaultTransform.outputSpace.names,\n )\n ) {\n return false;\n }\n return isTransformDerivableFromDefault(\n defaultTransform.transform,\n rank,\n defaultTransform.outputSpace.scales,\n transform.transform,\n rank,\n transform.outputSpace.scales,\n );\n}\n\nexport function makeIdentityTransform(\n inputSpace: CoordinateSpace,\n): CoordinateSpaceTransform {\n return {\n rank: inputSpace.rank,\n sourceRank: inputSpace.rank,\n inputSpace,\n outputSpace: inputSpace,\n transform: matrix.createIdentity(Float64Array, inputSpace.rank + 1),\n };\n}\n\nfunction transformBoundingBox(\n boundingBox: TransformedBoundingBox,\n transform: Float64Array,\n sourceScales: Float64Array,\n targetScales: Float64Array,\n): TransformedBoundingBox {\n const { transform: oldBoxTransform, box } = boundingBox;\n const inputRank = boundingBox.box.lowerBounds.length;\n const targetRank = targetScales.length;\n // transform is a column-major homogeneous `(rows=targetRank+1, cols=targetRank+1)` matrix.\n // oldBoxTransform is a column-major `(rows=targetRank, cols=inputRank+1)` matrix.\n // newBoxTransform is a column-major `(rows=targetRank, cols=inputRank+1)` matrix.\n const newBoxTransform = new Float64Array((inputRank + 1) * targetRank);\n for (let targetDim = 0; targetDim < targetRank; ++targetDim) {\n const targetScale = targetScales[targetDim];\n // Compute the rotation/scaling components\n for (let inputDim = 0; inputDim < inputRank; ++inputDim) {\n let sum = 0;\n for (let sourceDim = 0; sourceDim < targetRank; ++sourceDim) {\n const sourceScale = sourceScales[sourceDim];\n sum +=\n transform[(targetRank + 1) * sourceDim + targetDim] *\n oldBoxTransform[targetRank * inputDim + sourceDim] *\n (sourceScale / targetScale);\n }\n newBoxTransform[targetRank * inputDim + targetDim] = sum;\n }\n // Compute the translation component\n let sum = transform[(targetRank + 1) * targetRank + targetDim];\n for (let sourceDim = 0; sourceDim < targetRank; ++sourceDim) {\n const sourceScale = sourceScales[sourceDim];\n sum +=\n transform[(targetRank + 1) * sourceDim + targetDim] *\n oldBoxTransform[targetRank * inputRank + sourceDim] *\n (sourceScale / targetScale);\n }\n newBoxTransform[inputRank * targetRank + targetDim] = sum;\n }\n return {\n transform: newBoxTransform,\n box,\n };\n}\n\nfunction getTransformedBoundingBoxes(\n inputSpace: CoordinateSpace,\n transform: Float64Array,\n outputScales: Float64Array,\n) {\n return inputSpace.boundingBoxes.map((boundingBox) =>\n transformBoundingBox(\n boundingBox,\n transform,\n inputSpace.scales,\n outputScales,\n ),\n );\n}\n\nexport function getOutputSpaceWithTransformedBoundingBoxes(\n inputSpace: CoordinateSpace,\n transform: Float64Array,\n oldOutputSpace: CoordinateSpace,\n) {\n const newSpace = makeCoordinateSpace({\n valid: inputSpace.valid,\n rank: oldOutputSpace.rank,\n ids: oldOutputSpace.ids,\n names: oldOutputSpace.names,\n timestamps: oldOutputSpace.timestamps,\n scales: oldOutputSpace.scales,\n units: oldOutputSpace.units,\n boundingBoxes: getTransformedBoundingBoxes(\n inputSpace,\n transform,\n oldOutputSpace.scales,\n ),\n coordinateArrays: oldOutputSpace.coordinateArrays,\n });\n if (coordinateSpacesEqual(newSpace, oldOutputSpace)) return oldOutputSpace;\n return newSpace;\n}\n\nexport function isValidDimensionName(\n name: string,\n allowNumericalNames = false,\n) {\n if (allowNumericalNames) {\n const n = Number(name);\n if (Number.isInteger(n) && n >= 0) return true;\n }\n return name.match(/^[a-zA-Z][a-zA-Z_0-9]*['^]?$/) !== null;\n}\n\nexport function validateDimensionNames(\n names: string[],\n allowNumericalNames = false,\n) {\n const seenNames = new Set();\n for (const name of names) {\n if (!isValidDimensionName(name, allowNumericalNames)) return false;\n if (seenNames.has(name)) return false;\n seenNames.add(name);\n }\n return true;\n}\n\nexport function getDimensionNameValidity(names: readonly string[]): boolean[] {\n const rank = names.length;\n const isValid = new Array(rank);\n isValid.fill(true);\n for (let i = 0; i < rank; ++i) {\n const name = names[i];\n if (!isValidDimensionName(name)) {\n isValid[i] = false;\n continue;\n }\n const otherIndex = names.indexOf(name, i + 1);\n if (otherIndex !== -1) {\n isValid[i] = false;\n isValid[otherIndex] = false;\n }\n }\n return isValid;\n}\n\nexport function isLocalDimension(name: string) {\n return name.endsWith(\"'\");\n}\n\nexport function isLocalOrChannelDimension(name: string) {\n return name.endsWith(\"'\") || name.endsWith(\"^\");\n}\n\nexport function isChannelDimension(name: string) {\n return name.endsWith(\"^\");\n}\n\nexport function isGlobalDimension(name: string) {\n return !isLocalOrChannelDimension(name);\n}\n\nexport function convertTransformOutputScales(\n existingTransform: Float64Array,\n existingOutputScales: Float64Array,\n newOutputScales: Float64Array,\n) {\n const newTransform = new Float64Array(existingTransform);\n const rank = existingOutputScales.length;\n const baseIndex = (rank + 1) * rank;\n for (let i = 0; i < rank; ++i) {\n newTransform[baseIndex + i] *= existingOutputScales[i] / newOutputScales[i];\n }\n return newTransform;\n}\n\nfunction isTransformDerivableFromDefault(\n defaultTransform: Float64Array,\n defaultRank: number,\n defaultOutputScales: Float64Array,\n newTransform: Float64Array,\n newRank: number,\n newOutputScales: Float64Array,\n) {\n // Verify that matched linear portion is equal.\n if (\n !matrix.equal(\n defaultTransform,\n defaultRank + 1,\n newTransform,\n newRank + 1,\n defaultRank,\n defaultRank,\n )\n )\n return false;\n\n // Verify that common translation is equivalent.\n for (let i = 0; i < defaultRank; ++i) {\n const aValue = defaultTransform[(defaultRank + 1) * defaultRank + i];\n const bValue = newTransform[(newRank + 1) * newRank + i];\n if (aValue * (defaultOutputScales[i] / newOutputScales[i]) !== bValue)\n return false;\n }\n\n // Verify that extended translation is 0.\n for (let i = defaultRank; i < newRank; ++i) {\n if (newTransform[(newRank + 1) * newRank + i] !== 0) return false;\n }\n\n // Verify that extended linear portion is identity.\n for (let i = defaultRank; i < newRank; ++i) {\n for (let j = 0; j < defaultRank; ++j) {\n if (newTransform[(newRank + 1) * j + i] !== 0) return false;\n }\n for (let j = 0; j < newRank; ++j) {\n const coeff = newTransform[(newRank + 1) * i + j];\n if (i === j) {\n if (coeff !== 1) return false;\n } else {\n if (coeff !== 0) return false;\n }\n }\n }\n return true;\n}\n\nexport function makeDimensionNameUnique(\n name: string,\n existingNames: readonly string[],\n) {\n if (!existingNames.includes(name)) return name;\n const [, prefix, suffix] = name.match(/^([^']*)('?)$/)!;\n for (let i = 0; ; ++i) {\n const newName = `${prefix}${i}${suffix}`;\n if (!existingNames.includes(newName)) return newName;\n }\n}\n\nexport function remapTransformInputSpace(\n old: CoordinateSpaceTransform,\n inputSpace: CoordinateSpace,\n): CoordinateSpaceTransform {\n const { inputSpace: oldInputSpace, transform: oldTransform } = old;\n const { ids: oldInputDimensionIds, rank: oldRank } = oldInputSpace;\n const {\n rank: newRank,\n names: newInputDimensionNames,\n units: newInputUnits,\n scales: newInputScales,\n } = inputSpace;\n const removedOldInputIndices = new Array(oldRank);\n removedOldInputIndices.fill(true);\n const addedInputDimensionIndices: number[] = [];\n const newToOldInputDimensionIndices: number[] = inputSpace.ids.map(\n (id, i) => {\n const oldIndex = oldInputDimensionIds.indexOf(id);\n if (oldIndex !== -1) {\n removedOldInputIndices[oldIndex] = false;\n } else {\n addedInputDimensionIndices.push(i);\n }\n return oldIndex;\n },\n );\n const { outputSpace: oldOutputSpace } = old;\n const {\n names: oldOutputDimensionNames,\n units: oldOutputUnits,\n scales: oldOutputScales,\n ids: oldOutputDimensionIds,\n timestamps: oldOutputTimestamps,\n coordinateArrays: oldOutputCoordinateArrays,\n } = oldOutputSpace;\n // For now just use a simple mapping.\n const removedOldOutputIndices = removedOldInputIndices;\n const outputDimensionNames: string[] = [];\n const outputUnits: string[] = [];\n const outputScales = new Float64Array(newRank);\n const outputDimensionIds: DimensionId[] = [];\n const outputDimensionTimestamps: number[] = [];\n const outputCoordinateArrays = new Array(\n newRank,\n );\n let newOutputDim = 0;\n const newTransform = new Float64Array((newRank + 1) ** 2);\n newTransform[newTransform.length - 1] = 1;\n for (let oldOutputDim = 0; oldOutputDim < oldRank; ++oldOutputDim) {\n if (removedOldOutputIndices[oldOutputDim]) continue;\n outputDimensionNames[newOutputDim] = oldOutputDimensionNames[oldOutputDim];\n outputDimensionIds[newOutputDim] = oldOutputDimensionIds[oldOutputDim];\n outputUnits[newOutputDim] = oldOutputUnits[oldOutputDim];\n outputScales[newOutputDim] = oldOutputScales[oldOutputDim];\n outputDimensionTimestamps[newOutputDim] = oldOutputTimestamps[oldOutputDim];\n outputCoordinateArrays[newOutputDim] =\n oldOutputCoordinateArrays[oldOutputDim];\n for (let newInputDim = 0; newInputDim < newRank; ++newInputDim) {\n const oldInputDim = newToOldInputDimensionIndices[newInputDim];\n if (oldInputDim === -1) continue;\n newTransform[newInputDim * (newRank + 1) + newOutputDim] =\n oldTransform[oldInputDim * (oldRank + 1) + oldOutputDim];\n }\n newTransform[newRank * (newRank + 1) + newOutputDim] =\n oldTransform[oldRank * (oldRank + 1) + oldOutputDim];\n ++newOutputDim;\n }\n for (const newInputDim of addedInputDimensionIndices) {\n outputDimensionIds[newOutputDim] = newDimensionId();\n outputDimensionNames[newOutputDim] = makeDimensionNameUnique(\n newInputDimensionNames[newInputDim],\n outputDimensionNames,\n );\n outputScales[newOutputDim] = newInputScales[newInputDim];\n outputUnits[newOutputDim] = newInputUnits[newInputDim];\n newTransform[newInputDim * (newRank + 1) + newOutputDim] = 1;\n ++newOutputDim;\n }\n const outputSpace = makeCoordinateSpace({\n valid: inputSpace.valid,\n rank: newRank,\n names: outputDimensionNames,\n ids: outputDimensionIds,\n timestamps: outputDimensionTimestamps,\n units: outputUnits,\n scales: outputScales,\n boundingBoxes: getTransformedBoundingBoxes(\n inputSpace,\n newTransform,\n outputScales,\n ),\n coordinateArrays: outputCoordinateArrays,\n });\n return {\n rank: newRank,\n sourceRank: old.sourceRank,\n inputSpace,\n outputSpace,\n transform: newTransform,\n };\n}\n\nfunction normalizeCoordinateSpaceTransform(value: CoordinateSpaceTransform) {\n const outputSpace = getOutputSpaceWithTransformedBoundingBoxes(\n value.inputSpace,\n value.transform,\n value.outputSpace,\n );\n if (outputSpace === value.outputSpace) return value;\n return {\n rank: value.rank,\n sourceRank: value.sourceRank,\n inputSpace: value.inputSpace,\n transform: value.transform,\n outputSpace,\n };\n}\n\nexport class WatchableCoordinateSpaceTransform\n implements Trackable, WatchableValueInterface\n{\n private value_: CoordinateSpaceTransform | undefined = undefined;\n readonly outputSpace: WatchableValueInterface;\n readonly inputSpace: WatchableValueInterface;\n changed = new NullarySignal();\n private inputSpaceChanged = new NullarySignal();\n readonly defaultTransform: CoordinateSpaceTransform;\n\n constructor(\n defaultTransform: CoordinateSpaceTransform,\n public readonly mutableSourceRank: boolean = false,\n ) {\n this.defaultTransform = normalizeCoordinateSpaceTransform(defaultTransform);\n const self = this;\n this.outputSpace = {\n changed: self.changed,\n get value() {\n return self.value.outputSpace;\n },\n set value(newOutputSpace: CoordinateSpace) {\n const { value } = self;\n if (coordinateSpacesEqual(value.outputSpace, newOutputSpace)) return;\n if (value.rank !== newOutputSpace.rank) return;\n const transform = convertTransformOutputScales(\n value.transform,\n value.outputSpace.scales,\n newOutputSpace.scales,\n );\n self.value_ = {\n sourceRank: value.sourceRank,\n rank: value.rank,\n inputSpace: value.inputSpace,\n outputSpace: getOutputSpaceWithTransformedBoundingBoxes(\n value.inputSpace,\n transform,\n newOutputSpace,\n ),\n transform,\n };\n self.changed.dispatch();\n },\n };\n this.inputSpace = {\n changed: self.inputSpaceChanged,\n get value() {\n return self.value.inputSpace;\n },\n set value(newInputSpace: CoordinateSpace) {\n const { value } = self;\n if (coordinateSpacesEqual(value.inputSpace, newInputSpace)) return;\n self.value_ = remapTransformInputSpace(value, newInputSpace);\n self.inputSpaceChanged.dispatch();\n self.changed.dispatch();\n },\n };\n }\n\n set value(value: CoordinateSpaceTransform) {\n const existingValue = this.value;\n if (value === existingValue) return;\n this.value_ = normalizeCoordinateSpaceTransform(value);\n if (value.inputSpace !== existingValue.inputSpace) {\n this.inputSpaceChanged.dispatch();\n }\n this.changed.dispatch();\n }\n\n get value(): CoordinateSpaceTransform {\n let { value_: value } = this;\n if (value === undefined) {\n value = this.value_ = this.defaultTransform;\n }\n return value;\n }\n\n reset() {\n if (this.value_ === this.defaultTransform) return;\n this.value_ = this.defaultTransform;\n this.inputSpaceChanged.dispatch();\n this.changed.dispatch();\n }\n\n get defaultInputSpace() {\n return this.defaultTransform.inputSpace;\n }\n\n get spec(): Readonly | undefined {\n const { value } = this;\n const { rank, transform, inputSpace, outputSpace, sourceRank } = value;\n const { defaultTransform, mutableSourceRank } = this;\n const {\n inputSpace: defaultInputSpace,\n rank: defaultRank,\n transform: defaultTransformMatrix,\n outputSpace: defaultOutputSpace,\n } = defaultTransform;\n const { units, scales } = inputSpace;\n const inputSpaceSame =\n sourceRank === rank &&\n arraysEqual(\n scales,\n mutableSourceRank ? outputSpace.scales : defaultInputSpace.scales,\n ) &&\n arraysEqual(\n units,\n mutableSourceRank ? outputSpace.units : defaultInputSpace.units,\n );\n const transformSame = isTransformDerivableFromDefault(\n defaultTransformMatrix,\n defaultRank,\n defaultOutputSpace.scales,\n transform,\n rank,\n outputSpace.scales,\n );\n const outputNamesSame = arraysEqual(\n defaultOutputSpace.names,\n outputSpace.names,\n );\n if (transformSame && outputNamesSame && inputSpaceSame) {\n return undefined;\n }\n return {\n sourceRank,\n transform: transformSame ? undefined : transform,\n outputSpace: value.outputSpace,\n inputSpace: inputSpaceSame ? undefined : inputSpace,\n };\n }\n\n set transform(transform: Float64Array) {\n const { value } = this;\n const { inputSpace } = value;\n this.value_ = {\n rank: value.rank,\n sourceRank: value.sourceRank,\n inputSpace,\n transform,\n outputSpace: getOutputSpaceWithTransformedBoundingBoxes(\n inputSpace,\n transform,\n value.outputSpace,\n ),\n };\n this.changed.dispatch();\n }\n\n set spec(spec: Readonly | undefined) {\n if (spec === undefined) {\n this.reset();\n return;\n }\n if (this.mutableSourceRank) {\n const origInputSpace = spec.inputSpace || spec.outputSpace;\n const rank = origInputSpace.rank;\n const inputSpace = makeCoordinateSpace({\n rank,\n names: origInputSpace.names.map((_, i) => `${i}`),\n units: origInputSpace.units,\n scales: origInputSpace.scales,\n coordinateArrays: origInputSpace.coordinateArrays,\n });\n this.value = {\n rank,\n transform:\n spec.transform || matrix.createIdentity(Float64Array, rank + 1),\n sourceRank: spec.sourceRank,\n outputSpace: spec.outputSpace,\n inputSpace,\n };\n return;\n }\n const {\n inputSpace: defaultInputSpace,\n sourceRank: defaultSourceRank,\n outputSpace: defaultOutputSpace,\n transform: defaultTransformMatrix,\n rank: defaultRank,\n } = this.defaultTransform;\n const {\n inputSpace: specInputSpace,\n sourceRank: specSourceRank,\n outputSpace: specOutputSpace,\n transform: specTransformMatrix,\n } = spec;\n const specRank = spec.outputSpace.rank;\n const defaultInputNames = defaultInputSpace.names;\n const specInputNames =\n specInputSpace !== undefined ? specInputSpace.names : defaultInputNames;\n const newToSpecDimensionIndices = new Array(defaultSourceRank);\n for (let defaultDim = 0; defaultDim < defaultSourceRank; ++defaultDim) {\n let specDim = specInputNames.indexOf(defaultInputNames[defaultDim]);\n if (specDim >= specSourceRank) specDim = -1;\n newToSpecDimensionIndices[defaultDim] = specDim;\n }\n const newRank = specRank - specSourceRank + defaultSourceRank;\n for (let i = specSourceRank; i < specRank; ++i) {\n newToSpecDimensionIndices[defaultSourceRank + i - specSourceRank] = i;\n }\n const newInputScales = new Float64Array(newRank);\n const newInputCoordinateArrays = new Array(\n newRank,\n );\n const newInputUnits: string[] = [];\n for (let newDim = 0; newDim < defaultSourceRank; ++newDim) {\n const specDim = newToSpecDimensionIndices[newDim];\n if (specDim === -1 || specInputSpace === undefined) {\n newInputScales[newDim] = defaultInputSpace.scales[newDim];\n newInputUnits[newDim] = defaultInputSpace.units[newDim];\n newInputCoordinateArrays[newDim] =\n defaultInputSpace.coordinateArrays[newDim];\n } else {\n newInputScales[newDim] = specInputSpace.scales[specDim];\n newInputUnits[newDim] = specInputSpace.units[specDim];\n newInputCoordinateArrays[newDim] = mergeOptionalCoordinateArrays([\n defaultInputSpace.coordinateArrays[newDim],\n specInputSpace.coordinateArrays[specDim],\n ]);\n }\n }\n const specInputOrOutputSpace = specInputSpace || specOutputSpace;\n const newInputNames = defaultInputNames.slice(0, defaultSourceRank);\n const newOutputNames = defaultOutputSpace.names.slice(0, defaultSourceRank);\n const newOutputCoordinateArrays = defaultOutputSpace.coordinateArrays.slice(\n 0,\n defaultSourceRank,\n );\n const newOutputScales = new Float64Array(newRank);\n const newOutputUnits: string[] = [];\n for (let newDim = 0; newDim < newRank; ++newDim) {\n const specDim = newToSpecDimensionIndices[newDim];\n if (specDim === -1) {\n newOutputScales[newDim] = defaultOutputSpace.scales[newDim];\n newOutputUnits[newDim] = defaultOutputSpace.units[newDim];\n newOutputCoordinateArrays[newDim] =\n defaultOutputSpace.coordinateArrays[newDim];\n } else {\n newOutputNames[newDim] = specOutputSpace.names[specDim];\n newOutputUnits[newDim] = specOutputSpace.units[specDim];\n newOutputScales[newDim] = specOutputSpace.scales[specDim];\n newOutputCoordinateArrays[newDim] =\n specOutputSpace.coordinateArrays[specDim];\n }\n }\n if (!validateDimensionNames(newOutputNames)) {\n // Spec is incompatible, ignore it.\n this.reset();\n return;\n }\n // Handle singleton dimensions.\n for (let newDim = defaultSourceRank; newDim < newRank; ++newDim) {\n const specDim = newDim - defaultSourceRank + specSourceRank;\n newInputScales[newDim] = specInputOrOutputSpace.scales[specDim];\n newInputUnits[newDim] = specInputOrOutputSpace.units[specDim];\n newInputNames[newDim] = `${newDim}`;\n }\n\n const newTransform = new Float64Array((newRank + 1) ** 2);\n newTransform[newTransform.length - 1] = 1;\n for (let newRow = 0; newRow < newRank; ++newRow) {\n const specRow = newToSpecDimensionIndices[newRow];\n let value: number;\n if (specRow === -1 || specTransformMatrix === undefined) {\n if (newRow >= defaultSourceRank) {\n value = 0;\n } else {\n value =\n defaultTransformMatrix[defaultRank * (defaultRank + 1) + newRow] *\n (defaultOutputSpace.scales[newRow] / newOutputScales[newRow]);\n }\n } else {\n value = specTransformMatrix[specRank * (specRank + 1) + specRow];\n }\n newTransform[newRank * (newRank + 1) + newRow] = value;\n for (let newCol = 0; newCol < newRank; ++newCol) {\n const specCol = newToSpecDimensionIndices[newCol];\n let value: number;\n if ((specRow === -1) !== (specCol === -1)) {\n value = 0;\n } else if (specRow === -1 || specTransformMatrix === undefined) {\n if (specRow >= defaultSourceRank || specCol >= defaultSourceRank) {\n value = specRow === specCol ? 1 : 0;\n } else {\n value = defaultTransformMatrix[newCol * (defaultRank + 1) + newRow];\n }\n } else {\n value = specTransformMatrix[specCol * (specRank + 1) + specRow];\n }\n newTransform[newCol * (newRank + 1) + newRow] = value;\n }\n }\n const boundingBoxes = defaultInputSpace.boundingBoxes.map((boundingBox) =>\n extendTransformedBoundingBoxUpToRank(boundingBox, defaultRank, newRank),\n );\n for (let i = defaultSourceRank; i < newRank; ++i) {\n boundingBoxes.push(makeSingletonDimTransformedBoundingBox(newRank, i));\n }\n // Propagate coordinate arrays from input dimensions to output dimensions.\n for (let outputDim = 0; outputDim < newRank; ++outputDim) {\n // Check if this output dimension is identity mapped from a single input dimension.\n const translation = newTransform[newRank * (newRank + 1) + outputDim];\n if (translation !== 0) continue;\n let singleInputDim: number | undefined | null = undefined;\n for (let inputDim = 0; inputDim < newRank; ++inputDim) {\n const factor = newTransform[inputDim * (newRank + 1) + outputDim];\n if (factor === 0) continue;\n if (factor === 1) {\n if (singleInputDim === undefined) {\n // First input dimension that maps to this output dimension.\n singleInputDim = inputDim;\n } else {\n // Multiple input dimensions map to this output dimension.\n singleInputDim = null;\n break;\n }\n } else {\n // Non-identity mapping.\n singleInputDim = null;\n break;\n }\n }\n if (singleInputDim == null) continue;\n let coordinateArray = newInputCoordinateArrays[singleInputDim];\n if (coordinateArray === undefined) continue;\n if (coordinateArray.explicit) {\n coordinateArray = { ...coordinateArray, explicit: false };\n }\n newOutputCoordinateArrays[outputDim] = mergeOptionalCoordinateArrays([\n coordinateArray,\n newOutputCoordinateArrays[outputDim],\n ]);\n }\n this.value = {\n rank: newRank,\n transform: newTransform,\n sourceRank: defaultSourceRank,\n outputSpace: makeCoordinateSpace({\n rank: newRank,\n names: newOutputNames,\n scales: newOutputScales,\n units: newOutputUnits,\n coordinateArrays: newOutputCoordinateArrays,\n }),\n inputSpace: makeCoordinateSpace({\n rank: newRank,\n names: newInputNames,\n scales: newInputScales,\n units: newInputUnits,\n coordinateArrays: newInputCoordinateArrays,\n boundingBoxes,\n }),\n };\n }\n\n toJSON() {\n return coordinateTransformSpecificationToJson(this.spec);\n }\n\n restoreState(obj: unknown) {\n this.spec = coordinateTransformSpecificationFromJson(obj);\n }\n}\n\nexport function expectDimensionName(\n obj: unknown,\n allowNumericalNames = false,\n): string {\n const name = verifyString(obj);\n if (!isValidDimensionName(name, allowNumericalNames)) {\n throw new Error(`Invalid dimension name: ${JSON.stringify(name)}`);\n }\n return name;\n}\n\nexport function dimensionNamesFromJson(obj: any, allowNumericalNames = false) {\n const dimensions = parseArray(obj, (x) =>\n expectDimensionName(x, allowNumericalNames),\n );\n if (!validateDimensionNames(dimensions, allowNumericalNames)) {\n throw new Error(`Invalid dimensions: ${JSON.stringify(dimensions)}`);\n }\n return dimensions;\n}\n\ninterface BoundCoordinateSpace {\n space: WatchableValueInterface;\n prevValue: CoordinateSpace | undefined;\n mappedDimensionIds: (DimensionId | undefined)[];\n}\n\nexport class CoordinateSpaceCombiner {\n private bindings = new Set();\n\n private retainCount = 0;\n\n private prevCombined: CoordinateSpace | undefined = this.combined.value;\n\n dimensionRefCounts = new Map();\n\n getRenameValidity(newNames: readonly string[]): boolean[] {\n const existingNames = this.combined.value.names;\n const validity = getDimensionNameValidity(newNames);\n const rank = newNames.length;\n for (let i = 0; i < rank; ++i) {\n if (!validity[i]) continue;\n const newName = newNames[i];\n if (existingNames.includes(newName)) continue;\n let valid = true;\n for (const binding of this.bindings) {\n const otherNames = binding.space.value.names;\n if (otherNames.includes(newName)) {\n valid = false;\n break;\n }\n }\n validity[i] = valid;\n }\n return validity;\n }\n\n private includeDimensionPredicate_: (name: string) => boolean;\n\n get includeDimensionPredicate() {\n return this.includeDimensionPredicate_;\n }\n set includeDimensionPredicate(value: (name: string) => boolean) {\n this.includeDimensionPredicate_ = value;\n this.update();\n }\n\n constructor(\n public combined: WatchableValueInterface,\n includeDimensionPredicate: (name: string) => boolean,\n ) {\n this.includeDimensionPredicate_ = includeDimensionPredicate;\n }\n\n private update() {\n const { combined, bindings } = this;\n const retainExisting = this.retainCount > 0 ? 1 : 0;\n if (bindings.size === 0 && !retainExisting) {\n combined.value = emptyInvalidCoordinateSpace;\n return;\n }\n const include = this.includeDimensionPredicate_;\n const existing = combined.value;\n let mergedNames = Array.from(existing.names);\n let mergedUnits = Array.from(existing.units);\n let mergedScales = Array.from(existing.scales);\n let mergedIds = Array.from(existing.ids);\n let mergedTimestamps = Array.from(existing.timestamps);\n let dimensionRefs: number[] = existing.names.map(() =>\n retainExisting ? 1 : 0,\n );\n const bindingCombinedIndices: (number | undefined)[][] = [];\n let valid = false;\n for (const binding of bindings) {\n const {\n space: { value: space },\n prevValue,\n mappedDimensionIds,\n } = binding;\n valid = valid || space.valid;\n const { names, units, scales, ids, timestamps } = space;\n const newMappedDimensionIds: (DimensionId | undefined)[] = [];\n const combinedIndices: (number | undefined)[] = [];\n bindingCombinedIndices.push(combinedIndices);\n binding.mappedDimensionIds = newMappedDimensionIds;\n binding.prevValue = space;\n const rank = names.length;\n for (let i = 0; i < rank; ++i) {\n const name = names[i];\n if (!include(name)) continue;\n if (prevValue !== undefined) {\n const id = ids[i];\n const prevIndex = prevValue.ids.indexOf(id);\n if (prevIndex !== -1) {\n const combinedId = mappedDimensionIds[prevIndex];\n if (combinedId !== undefined) {\n const combinedIndex = mergedIds.indexOf(combinedId);\n if (combinedIndex !== -1) {\n newMappedDimensionIds[i] = combinedId;\n ++dimensionRefs[combinedIndex];\n combinedIndices[i] = combinedIndex;\n const timestamp = timestamps[i];\n if (\n timestamp !== undefined &&\n !(timestamp <= mergedTimestamps[combinedIndex])\n ) {\n mergedNames[combinedIndex] = name;\n mergedScales[combinedIndex] = scales[i];\n mergedUnits[combinedIndex] = units[i];\n mergedTimestamps[combinedIndex] = timestamp;\n }\n continue;\n }\n }\n }\n }\n let combinedIndex = mergedNames.indexOf(name);\n if (combinedIndex !== -1) {\n newMappedDimensionIds[i] = mergedIds[combinedIndex];\n ++dimensionRefs[combinedIndex];\n combinedIndices[i] = combinedIndex;\n continue;\n }\n combinedIndex = mergedNames.length;\n combinedIndices[i] = combinedIndex;\n dimensionRefs[combinedIndex] = 1 + retainExisting;\n mergedNames[combinedIndex] = name;\n mergedUnits[combinedIndex] = units[i];\n mergedScales[combinedIndex] = scales[i];\n mergedTimestamps[combinedIndex] = timestamps[i];\n const combinedId = newDimensionId();\n mergedIds[combinedIndex] = combinedId;\n newMappedDimensionIds[i] = combinedId;\n }\n }\n // Propagate names, units, and scales back\n const { dimensionRefCounts } = this;\n dimensionRefCounts.clear();\n let bindingIndex = 0;\n let newRank = mergedNames.length;\n for (const binding of bindings) {\n const {\n space: { value: space },\n } = binding;\n const combinedIndices = bindingCombinedIndices[bindingIndex++];\n const { rank } = space;\n const names = Array.from(space.names);\n const timestamps = Array.from(space.timestamps);\n const scales = Float64Array.from(space.scales);\n const units = Array.from(space.units);\n for (let i = 0; i < rank; ++i) {\n const combinedIndex = combinedIndices[i];\n if (combinedIndex === undefined) continue;\n units[i] = mergedUnits[combinedIndex];\n scales[i] = mergedScales[combinedIndex];\n timestamps[i] = mergedTimestamps[combinedIndex];\n names[i] = mergedNames[combinedIndex];\n }\n for (const name of names) {\n let count = dimensionRefCounts.get(name);\n if (count === undefined) {\n count = 1;\n } else {\n ++count;\n }\n dimensionRefCounts.set(name, count);\n }\n if (\n !arraysEqual(units, space.units) ||\n !arraysEqual(scales, space.scales) ||\n !arraysEqual(names, space.names) ||\n !arraysEqual(timestamps, space.timestamps)\n ) {\n const newSpace = makeCoordinateSpace({\n valid: space.valid,\n ids: space.ids,\n scales,\n units,\n names,\n timestamps,\n boundingBoxes: space.boundingBoxes,\n coordinateArrays: space.coordinateArrays,\n });\n binding.prevValue = newSpace;\n binding.space.value = newSpace;\n }\n }\n\n {\n for (let i = 0; i < newRank; ++i) {\n if (!include(mergedNames[i])) {\n dimensionRefs[i] = 0;\n }\n }\n const hasRefs = (_: any, i: number) => dimensionRefs[i] !== 0;\n mergedNames = mergedNames.filter(hasRefs);\n mergedUnits = mergedUnits.filter(hasRefs);\n mergedScales = mergedScales.filter(hasRefs);\n mergedIds = mergedIds.filter(hasRefs);\n mergedTimestamps = mergedTimestamps.filter(hasRefs);\n dimensionRefs = dimensionRefs.filter(hasRefs);\n newRank = mergedNames.length;\n }\n\n const mergedBoundingBoxes: TransformedBoundingBox[] = [];\n const allCoordinateArrays = new Array(\n newRank,\n );\n // Include any explicit coordinate arrays from `existing`.\n for (let i = 0, existingRank = existing.rank; i < existingRank; ++i) {\n const coordinateArray = existing.coordinateArrays[i];\n if (!coordinateArray?.explicit) continue;\n const newDim = mergedIds.indexOf(existing.ids[i]);\n if (newDim === -1) continue;\n allCoordinateArrays[newDim] = [coordinateArray];\n }\n for (const binding of bindings) {\n const {\n space: { value: space },\n } = binding;\n const { rank, boundingBoxes, coordinateArrays } = space;\n const newDims = space.names.map((x) => mergedNames.indexOf(x));\n for (const oldBoundingBox of boundingBoxes) {\n mergedBoundingBoxes.push(\n extendTransformedBoundingBox(oldBoundingBox, newRank, newDims),\n );\n }\n for (let i = 0; i < rank; ++i) {\n const coordinateArray = coordinateArrays[i];\n if (coordinateArray === undefined) continue;\n const newDim = newDims[i];\n const mergedList = allCoordinateArrays[newDim];\n if (mergedList === undefined) {\n allCoordinateArrays[newDim] = [coordinateArray];\n } else {\n mergedList.push(coordinateArray);\n }\n }\n }\n const mergedCoordinateArrays = new Array(\n newRank,\n );\n for (let i = 0; i < newRank; ++i) {\n const mergedList = allCoordinateArrays[i];\n if (mergedList === undefined) continue;\n mergedCoordinateArrays[i] = mergeCoordinateArrays(mergedList);\n }\n const newCombined = makeCoordinateSpace({\n valid,\n ids: mergedIds,\n names: mergedNames,\n units: mergedUnits,\n scales: new Float64Array(mergedScales),\n boundingBoxes: mergedBoundingBoxes,\n coordinateArrays: mergedCoordinateArrays,\n });\n if (retainExisting) {\n for (let i = 0; i < newRank; ++i) {\n --dimensionRefs[i];\n }\n }\n if (!coordinateSpacesEqual(existing, newCombined)) {\n this.prevCombined = newCombined;\n combined.value = newCombined;\n }\n }\n\n private handleCombinedChanged = () => {\n if (this.combined.value === this.prevCombined) return;\n this.update();\n };\n\n retain() {\n ++this.retainCount;\n return () => {\n if (--this.retainCount === 0) {\n this.update();\n }\n };\n }\n\n bind(space: WatchableValueInterface) {\n const binding = { space, mappedDimensionIds: [], prevValue: undefined };\n const { bindings } = this;\n if (bindings.size === 0) {\n this.combined.changed.add(this.handleCombinedChanged);\n }\n bindings.add(binding);\n\n const changedDisposer = space.changed.add(() => {\n if (space.value === binding.prevValue) return;\n this.update();\n });\n const disposer = () => {\n changedDisposer();\n const { bindings } = this;\n bindings.delete(binding);\n if (bindings.size === 0) {\n this.combined.changed.remove(this.handleCombinedChanged);\n }\n this.update();\n };\n this.update();\n return disposer;\n }\n}\n\nexport function homogeneousTransformSubmatrix(\n arrayConstructor: { new (n: number): T },\n oldTransform: TypedArray,\n oldRank: number,\n oldRows: readonly number[],\n oldCols: readonly number[],\n): T {\n const newRank = oldCols.length;\n const newTransform = new arrayConstructor((newRank + 1) ** 2);\n newTransform[newTransform.length - 1] = 1;\n for (let newRow = 0; newRow < newRank; ++newRow) {\n const oldRow = oldRows[newRow];\n newTransform[(newRank + 1) * newRank + newRow] =\n oldTransform[(oldRank + 1) * oldRank + oldRow];\n for (let newCol = 0; newCol < newRank; ++newCol) {\n const oldCol = oldCols[newCol];\n newTransform[(newRank + 1) * newCol + newRow] =\n oldTransform[(oldRank + 1) * oldCol + oldRow];\n }\n }\n return newTransform;\n}\n\nexport interface CoordinateTransformSpecification {\n sourceRank: number;\n transform: Float64Array | undefined;\n inputSpace: CoordinateSpace | undefined;\n outputSpace: CoordinateSpace;\n}\n\nexport function coordinateTransformSpecificationFromLegacyJson(\n obj: unknown,\n): CoordinateTransformSpecification | undefined {\n if (obj === undefined) return undefined;\n const transform = new Float64Array(16);\n if (Array.isArray(obj)) {\n if (obj.length === 16) {\n for (let i = 0; i < 4; ++i) {\n for (let j = 0; j < 4; ++j) {\n transform[i * 4 + j] = verifyFiniteFloat(obj[j * 4 + i]);\n }\n }\n } else {\n expectArray(obj, 4);\n for (let i = 0; i < 4; ++i) {\n const row = expectArray(obj[i], 4);\n for (let j = 0; j < 4; ++j) {\n transform[j * 4 + i] = verifyFiniteFloat(row[j]);\n }\n }\n }\n } else {\n verifyObject(obj);\n const rotation = quat.create();\n const translation = vec3.create();\n const scale = vec3.fromValues(1, 1, 1);\n verifyOptionalObjectProperty(obj, \"rotation\", (x) => {\n parseFiniteVec(rotation, x);\n quat.normalize(rotation, rotation);\n });\n verifyOptionalObjectProperty(obj, \"translation\", (x) => {\n parseFiniteVec(translation, x);\n });\n verifyOptionalObjectProperty(obj, \"scale\", (x) => {\n parseFiniteVec(scale, x);\n });\n const tempMat4 = mat4.create();\n mat4.fromRotationTranslationScale(tempMat4, rotation, translation, scale);\n transform.set(tempMat4);\n }\n return {\n sourceRank: 3,\n transform,\n outputSpace: makeCoordinateSpace({\n valid: true,\n names: [\"x\", \"y\", \"z\"],\n units: [\"m\", \"m\", \"m\"],\n scales: Float64Array.of(1e-9, 1e-9, 1e-9),\n }),\n inputSpace: undefined,\n };\n}\n\nexport function coordinateTransformSpecificationFromJson(\n j: unknown,\n): CoordinateTransformSpecification | undefined {\n if (j === undefined) return undefined;\n const obj = verifyObject(j);\n const outputSpace = verifyObjectProperty(\n obj,\n \"outputDimensions\",\n coordinateSpaceFromJson,\n );\n const rank = outputSpace.rank;\n const sourceRank = verifyObjectProperty(obj, \"sourceRank\", (rankObj) => {\n if (rankObj === undefined) return rank;\n if (!Number.isInteger(rankObj) || rankObj < 0 || rankObj > rank) {\n throw new Error(\n `Expected integer in range [0, ${rank}] but received: ${JSON.stringify(\n rankObj,\n )}`,\n );\n }\n return rankObj as number;\n });\n const inputSpace = verifyOptionalObjectProperty(\n obj,\n \"inputDimensions\",\n (inputSpaceObj) => {\n const space = coordinateSpaceFromJson(inputSpaceObj, true);\n if (space.rank !== rank) {\n throw new Error(\n `Expected rank of ${rank}, but received rank of: ${space.rank}`,\n );\n }\n return space;\n },\n );\n const transform = verifyOptionalObjectProperty(obj, \"matrix\", (x) => {\n const transform = new Float64Array((rank + 1) ** 2);\n const a = expectArray(x, rank);\n transform[transform.length - 1] = 1;\n for (let i = 0; i < rank; ++i) {\n try {\n const row = expectArray(a[i], rank + 1);\n for (let j = 0; j <= rank; ++j) {\n transform[(rank + 1) * j + i] = verifyFiniteFloat(row[j]);\n }\n } catch (e) {\n throw new Error(`Error in row ${i}: ${e.message}`);\n }\n }\n return transform;\n });\n return { transform, outputSpace, inputSpace, sourceRank };\n}\n\nexport function coordinateTransformSpecificationToJson(\n spec: CoordinateTransformSpecification | undefined,\n) {\n if (spec === undefined) return undefined;\n const { transform, outputSpace, inputSpace, sourceRank } = spec;\n let m: number[][] | undefined;\n const rank = outputSpace.rank;\n if (transform !== undefined) {\n m = [];\n for (let i = 0; i < rank; ++i) {\n const row: number[] = [];\n m[i] = row;\n for (let j = 0; j <= rank; ++j) {\n row[j] = transform[(rank + 1) * j + i];\n }\n }\n }\n return {\n sourceRank: sourceRank === rank ? undefined : sourceRank,\n matrix: m,\n outputDimensions: coordinateSpaceToJson(outputSpace),\n inputDimensions:\n inputSpace === undefined ? undefined : coordinateSpaceToJson(inputSpace),\n };\n}\n\nexport function permuteTransformedBoundingBox(\n boundingBox: TransformedBoundingBox,\n newToOld: readonly number[],\n oldOutputRank: number,\n): TransformedBoundingBox | undefined {\n const { box, transform } = boundingBox;\n const inputRank = boundingBox.box.lowerBounds.length;\n const outputRank = newToOld.length;\n const newTransform = new Float64Array((inputRank + 1) * outputRank);\n matrix.permuteRows(\n newTransform,\n outputRank,\n transform,\n oldOutputRank,\n newToOld,\n inputRank + 1,\n );\n if (newTransform.every((x) => x === 0)) return undefined;\n return {\n transform: newTransform,\n box,\n };\n}\n\nexport function permuteCoordinateSpace(\n existing: CoordinateSpace,\n newToOld: readonly number[],\n) {\n const { ids, names, scales, units, timestamps, coordinateArrays } = existing;\n return makeCoordinateSpace({\n rank: newToOld.length,\n valid: existing.valid,\n ids: newToOld.map((i) => ids[i]),\n names: newToOld.map((i) => names[i]),\n timestamps: newToOld.map((i) => timestamps[i]),\n scales: Float64Array.from(newToOld, (i) => scales[i]),\n units: newToOld.map((i) => units[i]),\n coordinateArrays: newToOld.map((i) => coordinateArrays[i]),\n boundingBoxes: existing.boundingBoxes\n .map((b) => permuteTransformedBoundingBox(b, newToOld, existing.rank))\n .filter((b) => b !== undefined) as TransformedBoundingBox[],\n });\n}\n\nexport function insertDimensionAt(\n existing: CoordinateSpace,\n targetIndex: number,\n sourceIndex: number,\n) {\n if (targetIndex === sourceIndex) return existing;\n return permuteCoordinateSpace(\n existing,\n getInsertPermutation(existing.rank, sourceIndex, targetIndex),\n );\n}\n\nexport function getInferredOutputScale(\n transform: CoordinateSpaceTransform,\n outputDim: number,\n): { scale: number; unit: string } | undefined {\n const { transform: transformMatrix, rank } = transform;\n const inputDims = getDependentTransformInputDimensions(\n transformMatrix,\n rank,\n [outputDim],\n );\n if (inputDims.length !== 1) return undefined;\n const [inputDim] = inputDims;\n const coeff = Math.abs(transformMatrix[(rank + 1) * inputDim + outputDim]);\n const { inputSpace } = transform;\n return {\n scale: inputSpace.scales[inputDim] * coeff,\n unit: inputSpace.units[inputDim],\n };\n}\n\nexport function getDefaultInputScale(\n transform: WatchableCoordinateSpaceTransform,\n inputDim: number,\n): { scale: number; unit: string } | undefined {\n const { scales: defaultScales, units: defaultUnits } =\n transform.defaultInputSpace;\n return inputDim < defaultScales.length\n ? { scale: defaultScales[inputDim], unit: defaultUnits[inputDim] }\n : undefined;\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n CoordinateSpace,\n CoordinateSpaceTransform,\n} from \"#src/coordinate_transform.js\";\nimport {\n emptyValidCoordinateSpace,\n homogeneousTransformSubmatrix,\n} from \"#src/coordinate_transform.js\";\nimport type { DisplayDimensionRenderInfo } from \"#src/navigation_state.js\";\nimport type {\n CachedWatchableValue,\n WatchableValueInterface,\n} from \"#src/trackable_value.js\";\nimport {\n constantWatchableValue,\n makeCachedDerivedWatchableValue,\n} from \"#src/trackable_value.js\";\nimport { arraysEqual, scatterUpdate } from \"#src/util/array.js\";\nimport type { ValueOrError } from \"#src/util/error.js\";\nimport type { vec3 } from \"#src/util/geom.js\";\nimport { mat4, getDependentTransformInputDimensions } from \"#src/util/geom.js\";\nimport * as matrix from \"#src/util/matrix.js\";\nimport * as vector from \"#src/util/vector.js\";\nimport { prod } from \"#src/util/vector.js\";\n\n/**\n * Specifies coordinate transform information for a RenderLayer.\n */\nexport interface RenderLayerTransform {\n /**\n * Rank of chunk/model/layer subspace used by this RenderLayer, including any additional `[0,1)`\n * padding dimensions.\n */\n rank: number;\n\n /**\n * Rank of chunk/model/layer space, excluding any padding dimensions.\n */\n unpaddedRank: number;\n\n /**\n * Specifies for each local user layer dimension the corresponding \"render layer\" dimension. A\n * value of `-1` indicates there is no corresponding \"render layer\" dimension. The combined\n * values of `localToRenderLayerDimensions` and `globalToRenderLayerDimensions` that are not `-1`\n * must be distinct and partition `[0, ..., rank)`, where `rank` is the rank of the \"model\"\n * coordinate space.\n */\n localToRenderLayerDimensions: readonly number[];\n\n /**\n * Specifies for each global dimension the corresponding \"render layer\" dimension. A value of\n * `-1` indicates there is no corresponding \"render layer\" dimension.\n */\n globalToRenderLayerDimensions: readonly number[];\n\n /**\n * Specifies for each channel dimension the corresponding \"render layer\" dimension. A value of\n * `-1` indicates there is no corresponding \"render layer\" dimension.\n */\n channelToRenderLayerDimensions: readonly number[];\n\n channelToModelDimensions: readonly number[];\n\n channelSpaceShape: Uint32Array;\n\n /**\n * Homogeneous transform from \"model\" coordinate space to \"render layer\" coordinate space.\n */\n modelToRenderLayerTransform: Float32Array;\n\n modelDimensionNames: readonly string[];\n layerDimensionNames: readonly string[];\n}\n\nexport interface ChannelSpace {\n channelCoordinateSpace: CoordinateSpace;\n // Shape of multi-dimensional channel space.\n shape: Uint32Array;\n // Total number of channels, equal to product of `shape`.\n numChannels: number;\n // Row-major array of shape `[count, rank]` specifying the coordinates for each flattened channel.\n // Channels are ordered in Fortran order.\n coordinates: Uint32Array;\n}\n\nexport const zeroRankChannelSpace: ChannelSpace = {\n channelCoordinateSpace: emptyValidCoordinateSpace,\n shape: new Uint32Array(0),\n numChannels: 1,\n coordinates: new Uint32Array(0),\n};\n\nexport function getChannelSpace(\n channelCoordinateSpace: CoordinateSpace,\n): ChannelSpace {\n const { rank } = channelCoordinateSpace;\n const {\n bounds: { lowerBounds, upperBounds },\n } = channelCoordinateSpace;\n if (lowerBounds.some((x) => x !== 0)) {\n throw new Error(\"Lower bounds of channel coordinate space must all be 0\");\n }\n if (upperBounds.some((x) => !Number.isInteger(x) || x <= 0 || x >= 2 ** 32)) {\n throw new Error(\n \"Upper bounds of channel coordinate space must all be positive integers\",\n );\n }\n const shape = new Uint32Array(upperBounds);\n const numChannels = prod(shape);\n const coordinates = new Uint32Array(numChannels * rank);\n for (let flatIndex = 0; flatIndex < numChannels; ++flatIndex) {\n let remainder = flatIndex;\n for (let dim = 0; dim < rank; ++dim) {\n const coordinate = remainder % shape[dim];\n remainder = (remainder - coordinate) / shape[dim];\n coordinates[flatIndex * rank + dim] = coordinate;\n }\n }\n return { channelCoordinateSpace, shape, numChannels, coordinates };\n}\n\nexport type RenderLayerTransformOrError = ValueOrError;\nexport type WatchableRenderLayerTransform =\n WatchableValueInterface;\n\nfunction scaleTransformSubmatrix(\n transform: Float32Array,\n rank: number,\n baseInputSpace: CoordinateSpace,\n inputToBaseDimensions: readonly number[],\n baseOutputSpace: CoordinateSpace,\n baseToOutputDimensions: readonly number[],\n) {\n const { scales: baseInputScales } = baseInputSpace;\n const { scales: baseOutputScales, rank: baseOutputRank } = baseOutputSpace;\n const stride = rank + 1;\n for (let baseOutputDim = 0; baseOutputDim < baseOutputRank; ++baseOutputDim) {\n const outputDim = baseToOutputDimensions[baseOutputDim];\n if (outputDim === -1) continue;\n const baseOutputScale = baseOutputScales[baseOutputDim];\n for (let inputDim = 0; inputDim < rank; ++inputDim) {\n const baseInputDim = inputToBaseDimensions[inputDim];\n const baseInputScale = baseInputScales[baseInputDim];\n transform[stride * inputDim + outputDim] *=\n baseInputScale / baseOutputScale;\n }\n }\n}\n\nexport function getRenderLayerTransform(\n globalCoordinateSpace: CoordinateSpace,\n localCoordinateSpace: CoordinateSpace,\n modelToLayerTransform: CoordinateSpaceTransform,\n subsourceEntry:\n | {\n subsourceToModelSubspaceTransform: Float32Array;\n modelSubspaceDimensionIndices: readonly number[];\n }\n | undefined,\n channelCoordinateSpace: CoordinateSpace = emptyValidCoordinateSpace,\n): RenderLayerTransformOrError {\n const {\n inputSpace: modelSpace,\n rank: fullRank,\n sourceRank,\n outputSpace: layerSpace,\n transform: oldTransform,\n } = modelToLayerTransform;\n const { names: modelDimensionNames } = modelSpace;\n const { names: transformOutputDimensions } = layerSpace;\n let requiredInputDims: number[];\n if (subsourceEntry !== undefined) {\n requiredInputDims = Array.from(\n subsourceEntry.modelSubspaceDimensionIndices,\n );\n } else {\n requiredInputDims = [];\n for (let i = 0; i < sourceRank; ++i) {\n requiredInputDims[i] = i;\n }\n }\n const unpaddedRank = requiredInputDims.length;\n for (let i = sourceRank; i < fullRank; ++i) {\n requiredInputDims.push(i);\n }\n const requiredOutputDims = getDependentTransformInputDimensions(\n modelToLayerTransform.transform,\n fullRank,\n requiredInputDims,\n true,\n );\n const subspaceRank = requiredInputDims.length;\n const modelSubspaceDimensionNames = requiredInputDims.map(\n (i) => modelDimensionNames[i] || `${i}`,\n );\n const layerSubspaceDimensionNames = requiredOutputDims.map(\n (i) => transformOutputDimensions[i],\n );\n if (subspaceRank !== requiredOutputDims.length) {\n return {\n error:\n \"Rank mismatch between model subspace dimensions (\" +\n modelSubspaceDimensionNames.join(\", \") +\n \") and corresponding layer/global dimensions (\" +\n layerSubspaceDimensionNames.join(\", \") +\n \")\",\n };\n }\n let newTransform = homogeneousTransformSubmatrix(\n Float32Array,\n oldTransform,\n fullRank,\n requiredOutputDims,\n requiredInputDims,\n );\n const renderLayerDimensions = requiredOutputDims.map(\n (i) => transformOutputDimensions[i],\n );\n const localToRenderLayerDimensions = localCoordinateSpace.names.map((x) =>\n renderLayerDimensions.indexOf(x),\n );\n const globalToRenderLayerDimensions = globalCoordinateSpace.names.map((x) =>\n renderLayerDimensions.indexOf(x),\n );\n scaleTransformSubmatrix(\n newTransform,\n subspaceRank,\n modelSpace,\n requiredInputDims,\n globalCoordinateSpace,\n globalToRenderLayerDimensions,\n );\n scaleTransformSubmatrix(\n newTransform,\n subspaceRank,\n modelSpace,\n requiredInputDims,\n localCoordinateSpace,\n localToRenderLayerDimensions,\n );\n const channelToRenderLayerDimensions = channelCoordinateSpace.names.map((x) =>\n renderLayerDimensions.indexOf(x),\n );\n scaleTransformSubmatrix(\n newTransform,\n subspaceRank,\n modelSpace,\n requiredInputDims,\n channelCoordinateSpace,\n channelToRenderLayerDimensions,\n );\n const channelToModelSubspaceDimensions: number[] = [];\n const channelRank = channelCoordinateSpace.rank;\n if (subsourceEntry !== undefined) {\n let { subsourceToModelSubspaceTransform } = subsourceEntry;\n if (unpaddedRank !== subspaceRank) {\n subsourceToModelSubspaceTransform = matrix.extendHomogeneousTransform(\n new Float32Array((subspaceRank + 1) ** 2),\n subspaceRank,\n subsourceToModelSubspaceTransform,\n unpaddedRank,\n );\n }\n newTransform = matrix.multiply(\n new Float32Array((subspaceRank + 1) ** 2),\n subspaceRank + 1,\n newTransform,\n subspaceRank + 1,\n subsourceToModelSubspaceTransform,\n subspaceRank + 1,\n subspaceRank + 1,\n subspaceRank + 1,\n subspaceRank + 1,\n );\n }\n const channelSpaceShape = new Uint32Array(channelRank);\n const {\n lowerBounds: channelLowerBounds,\n upperBounds: channelUpperBounds,\n voxelCenterAtIntegerCoordinates: channelVoxelCenterAtIntegerCoordinates,\n } = channelCoordinateSpace.bounds;\n for (let channelDim = 0; channelDim < channelRank; ++channelDim) {\n let lower = channelLowerBounds[channelDim];\n let upper = channelUpperBounds[channelDim];\n if (channelVoxelCenterAtIntegerCoordinates[channelDim]) {\n lower += 0.5;\n upper += 0.5;\n }\n if (\n lower !== 0 ||\n !Number.isInteger(upper) ||\n upper <= 0 ||\n upper >= 2 ** 32\n ) {\n return {\n error:\n `Channel dimension ${channelCoordinateSpace.names[channelDim]} must have ` +\n `lower bound of 0 and positive integer upper bound; current bounds are [${lower}, ${upper}]`,\n };\n }\n channelSpaceShape[channelDim] = upper;\n const layerDim = channelToRenderLayerDimensions[channelDim];\n let correspondingModelSubspaceDim = -1;\n if (layerDim !== -1) {\n for (let chunkDim = 0; chunkDim < subspaceRank; ++chunkDim) {\n const coeff = newTransform[layerDim + chunkDim * (subspaceRank + 1)];\n if (coeff === 0) continue;\n if (coeff !== 1 || correspondingModelSubspaceDim !== -1) {\n return {\n error:\n `Channel dimension ${layerSubspaceDimensionNames[layerDim]} ` +\n \"must map to a single source dimension\",\n };\n }\n correspondingModelSubspaceDim = chunkDim;\n }\n }\n channelToModelSubspaceDimensions[channelDim] =\n correspondingModelSubspaceDim;\n }\n return {\n rank: subspaceRank,\n unpaddedRank,\n modelDimensionNames: modelSubspaceDimensionNames,\n layerDimensionNames: layerSubspaceDimensionNames,\n localToRenderLayerDimensions,\n globalToRenderLayerDimensions,\n channelToRenderLayerDimensions,\n modelToRenderLayerTransform: newTransform,\n channelToModelDimensions: channelToModelSubspaceDimensions,\n channelSpaceShape,\n };\n}\n\nexport function renderLayerTransformsEqual(\n a: RenderLayerTransformOrError,\n b: RenderLayerTransformOrError,\n) {\n if (a === b) return true;\n if (a.error !== undefined || b.error !== undefined) return false;\n return (\n arraysEqual(a.modelDimensionNames, b.modelDimensionNames) &&\n arraysEqual(a.layerDimensionNames, b.layerDimensionNames) &&\n arraysEqual(\n a.globalToRenderLayerDimensions,\n b.globalToRenderLayerDimensions,\n ) &&\n arraysEqual(\n a.localToRenderLayerDimensions,\n b.localToRenderLayerDimensions,\n ) &&\n arraysEqual(\n a.channelToRenderLayerDimensions,\n b.channelToRenderLayerDimensions,\n ) &&\n arraysEqual(a.modelToRenderLayerTransform, b.modelToRenderLayerTransform) &&\n arraysEqual(a.channelSpaceShape, b.channelSpaceShape)\n );\n}\n\nexport function getWatchableRenderLayerTransform(\n globalCoordinateSpace: WatchableValueInterface,\n localCoordinateSpace: WatchableValueInterface,\n modelToLayerTransform: WatchableValueInterface,\n subsourceEntry:\n | {\n subsourceToModelSubspaceTransform: Float32Array;\n modelSubspaceDimensionIndices: readonly number[];\n }\n | undefined,\n channelCoordinateSpace?: WatchableValueInterface,\n): CachedWatchableValue {\n return makeCachedDerivedWatchableValue(\n (\n globalCoordinateSpace: CoordinateSpace,\n localCoordinateSpace: CoordinateSpace,\n modelToLayerTransform: CoordinateSpaceTransform,\n channelCoordinateSpace: CoordinateSpace | undefined,\n ) =>\n getRenderLayerTransform(\n globalCoordinateSpace,\n localCoordinateSpace,\n modelToLayerTransform,\n subsourceEntry,\n channelCoordinateSpace,\n ),\n [\n globalCoordinateSpace,\n localCoordinateSpace,\n modelToLayerTransform,\n channelCoordinateSpace === undefined\n ? constantWatchableValue(undefined)\n : channelCoordinateSpace,\n ],\n renderLayerTransformsEqual,\n );\n}\n\nexport interface LayerDisplayDimensionMapping {\n /**\n * List of indices of layer dimensions that correspond to display dimensions.\n */\n layerDisplayDimensionIndices: number[];\n\n /**\n * Maps each display dimension index to the corresponding layer dimension index, or `-1`.\n */\n displayToLayerDimensionIndices: number[];\n}\n\nexport interface ChunkChannelAccessParameters {\n channelSpaceShape: Uint32Array;\n\n /**\n * Equal to the values in `channelToChunkDimensionIndices` not equal to `-1`.\n */\n chunkChannelDimensionIndices: readonly number[];\n\n /**\n * Product of `modelTransform.channelSpaceShape`.\n */\n numChannels: number;\n\n /**\n * Row-major array of shape `[numChannels, chunkChannelDimensionIndices.length]`, specifies the\n * coordinates within the chunk channel dimensions corresponding to each flat channel index.\n */\n chunkChannelCoordinates: Uint32Array;\n}\n\nexport interface ChunkTransformParameters extends ChunkChannelAccessParameters {\n modelTransform: RenderLayerTransform;\n chunkToLayerTransform: Float32Array;\n layerToChunkTransform: Float32Array;\n chunkToLayerTransformDet: number;\n /**\n * Maps channel dimension indices in the layer channel coordinate space to the corresponding chunk\n * dimension index, or `-1` if there is no correpsonding chunk dimension.\n */\n channelToChunkDimensionIndices: readonly number[];\n combinedGlobalLocalToChunkTransform: Float32Array;\n combinedGlobalLocalRank: number;\n layerRank: number;\n}\n\nexport function layerToDisplayCoordinates(\n displayPosition: vec3,\n layerPosition: Float32Array,\n modelTransform: RenderLayerTransform,\n displayDimensionIndices: Int32Array,\n) {\n const { globalToRenderLayerDimensions } = modelTransform;\n for (let displayDim = 0; displayDim < 3; ++displayDim) {\n let v = 0;\n const globalDim = displayDimensionIndices[displayDim];\n if (globalDim !== -1) {\n const layerDim = globalToRenderLayerDimensions[globalDim];\n if (layerDim !== -1) {\n v = layerPosition[layerDim];\n }\n }\n displayPosition[displayDim] = v;\n }\n}\n\nexport function displayToLayerCoordinates(\n layerPosition: Float32Array,\n displayPosition: vec3,\n modelTransform: RenderLayerTransform,\n displayDimensionIndices: Int32Array,\n) {\n const { globalToRenderLayerDimensions } = modelTransform;\n for (let displayDim = 0; displayDim < 3; ++displayDim) {\n const globalDim = displayDimensionIndices[displayDim];\n if (globalDim !== -1) {\n const layerDim = globalToRenderLayerDimensions[globalDim];\n if (layerDim !== -1) {\n layerPosition[layerDim] = displayPosition[displayDim];\n }\n }\n }\n}\n\nexport function chunkToDisplayCoordinates(\n displayPosition: vec3,\n chunkPosition: Float32Array,\n chunkTransform: ChunkTransformParameters,\n displayDimensionIndices: Int32Array,\n): vec3 {\n const { globalToRenderLayerDimensions } = chunkTransform.modelTransform;\n const { layerRank, chunkToLayerTransform } = chunkTransform;\n const stride = layerRank + 1;\n for (let displayDim = 0; displayDim < 3; ++displayDim) {\n let sum = 0;\n const globalDim = displayDimensionIndices[displayDim];\n if (globalDim !== -1) {\n const layerDim = globalToRenderLayerDimensions[globalDim];\n if (layerDim !== -1) {\n sum = chunkToLayerTransform[stride * layerRank + layerDim];\n for (let chunkDim = 0; chunkDim < layerRank; ++chunkDim) {\n sum +=\n chunkToLayerTransform[stride * chunkDim + layerDim] *\n chunkPosition[chunkDim];\n }\n }\n }\n displayPosition[displayDim] = sum;\n }\n return displayPosition;\n}\n\nexport interface ChunkDisplayTransformParameters {\n modelTransform: RenderLayerTransform;\n chunkTransform: ChunkTransformParameters;\n displaySubspaceModelMatrix: mat4;\n displaySubspaceInvModelMatrix: mat4;\n chunkDisplayDimensionIndices: number[];\n numChunkDisplayDims: number;\n}\n\nexport function getChunkTransformParameters(\n modelTransform: RenderLayerTransform,\n chunkToModelTransform?: Float32Array,\n): ChunkTransformParameters {\n const layerRank = modelTransform.rank;\n const unpaddedRank = modelTransform.unpaddedRank;\n let chunkToLayerTransform: Float32Array;\n if (unpaddedRank !== layerRank && chunkToModelTransform !== undefined) {\n chunkToModelTransform = matrix.extendHomogeneousTransform(\n new Float32Array((layerRank + 1) ** 2),\n layerRank,\n chunkToModelTransform,\n unpaddedRank,\n );\n }\n if (chunkToModelTransform !== undefined) {\n chunkToLayerTransform = new Float32Array((layerRank + 1) * (layerRank + 1));\n matrix.multiply(\n chunkToLayerTransform,\n layerRank + 1,\n modelTransform.modelToRenderLayerTransform,\n layerRank + 1,\n chunkToModelTransform,\n layerRank + 1,\n layerRank + 1,\n layerRank + 1,\n layerRank + 1,\n );\n } else {\n chunkToLayerTransform = modelTransform.modelToRenderLayerTransform;\n }\n const layerToChunkTransform = new Float32Array(\n (layerRank + 1) * (layerRank + 1),\n );\n const det = matrix.inverse(\n layerToChunkTransform,\n layerRank + 1,\n chunkToLayerTransform,\n layerRank + 1,\n layerRank + 1,\n );\n if (det === 0) {\n throw new Error(\"Transform is singular\");\n }\n const {\n globalToRenderLayerDimensions,\n localToRenderLayerDimensions,\n channelToRenderLayerDimensions,\n } = modelTransform;\n const globalRank = globalToRenderLayerDimensions.length;\n const localRank = localToRenderLayerDimensions.length;\n const combinedGlobalLocalRank = globalRank + localRank;\n\n // Compute `combinedGlobalLocalToChunkTransform`.\n const combinedGlobalLocalToChunkTransform = new Float32Array(\n (combinedGlobalLocalRank + 1) * layerRank,\n );\n for (let chunkDim = 0; chunkDim < layerRank; ++chunkDim) {\n for (let globalDim = 0; globalDim < globalRank; ++globalDim) {\n const layerDim = globalToRenderLayerDimensions[globalDim];\n if (layerDim === -1) continue;\n combinedGlobalLocalToChunkTransform[chunkDim + globalDim * layerRank] =\n layerToChunkTransform[chunkDim + layerDim * (layerRank + 1)];\n }\n for (let localDim = 0; localDim < localRank; ++localDim) {\n const layerDim = localToRenderLayerDimensions[localDim];\n if (layerDim === -1) continue;\n combinedGlobalLocalToChunkTransform[\n chunkDim + (globalRank + localDim) * layerRank\n ] = layerToChunkTransform[chunkDim + layerDim * (layerRank + 1)];\n }\n combinedGlobalLocalToChunkTransform[\n chunkDim + combinedGlobalLocalRank * layerRank\n ] = layerToChunkTransform[chunkDim + layerRank * (layerRank + 1)];\n }\n\n const channelRank = channelToRenderLayerDimensions.length;\n const channelToChunkDimensionIndices = new Array(channelRank);\n const chunkChannelDimensionIndices: number[] = [];\n for (let channelDim = 0; channelDim < channelRank; ++channelDim) {\n const layerDim = channelToRenderLayerDimensions[channelDim];\n let correspondingChunkDim = -1;\n if (layerDim !== -1) {\n for (let chunkDim = 0; chunkDim < layerRank; ++chunkDim) {\n const coeff =\n chunkToLayerTransform[layerDim + chunkDim * (layerRank + 1)];\n if (coeff === 0) continue;\n if (coeff !== 1 || correspondingChunkDim !== -1) {\n throw new Error(\n `Channel dimension ${modelTransform.layerDimensionNames[layerDim]} ` +\n \"must map with stride 1 to a single data chunk dimensions\",\n );\n }\n correspondingChunkDim = chunkDim;\n }\n if (correspondingChunkDim !== -1) {\n const offset =\n chunkToLayerTransform[layerDim + layerRank * (layerRank + 1)];\n if (offset !== 0 && offset !== -0.5) {\n throw new Error(\n `Channel dimension ${modelTransform.layerDimensionNames[layerDim]} ` +\n `must have an offset of 0 in the chunk coordinate space; current offset is ${offset}`,\n );\n }\n chunkChannelDimensionIndices.push(correspondingChunkDim);\n }\n }\n channelToChunkDimensionIndices[channelDim] = correspondingChunkDim;\n }\n const { channelSpaceShape } = modelTransform;\n const numChannels = vector.prod(channelSpaceShape);\n const chunkChannelRank = chunkChannelDimensionIndices.length;\n const chunkChannelCoordinates = new Uint32Array(\n numChannels * chunkChannelRank,\n );\n for (let channelIndex = 0; channelIndex < numChannels; ++channelIndex) {\n let remainder = channelIndex;\n let chunkChannelDim = 0;\n for (let channelDim = 0; channelDim < channelRank; ++channelDim) {\n const coordinate = remainder % channelSpaceShape[channelDim];\n remainder = (remainder - coordinate) / channelSpaceShape[channelDim];\n const chunkDim = channelToChunkDimensionIndices[channelDim];\n if (chunkDim !== -1) {\n chunkChannelCoordinates[\n channelIndex * chunkChannelRank + chunkChannelDim\n ] = coordinate;\n ++chunkChannelDim;\n }\n }\n }\n return {\n layerRank: layerRank,\n modelTransform,\n chunkToLayerTransform,\n layerToChunkTransform,\n chunkToLayerTransformDet: det,\n combinedGlobalLocalRank,\n combinedGlobalLocalToChunkTransform,\n channelToChunkDimensionIndices,\n chunkChannelDimensionIndices,\n numChannels,\n chunkChannelCoordinates,\n channelSpaceShape,\n };\n}\n\nexport function getLayerDisplayDimensionMapping(\n transform: RenderLayerTransform,\n displayDimensionIndices: Int32Array,\n): LayerDisplayDimensionMapping {\n const { globalToRenderLayerDimensions } = transform;\n\n // List of layer dimension indices corresponding to global display dimensions.\n const layerDisplayDimensionIndices: number[] = [];\n\n // Maps global display dimension (in {0, 1, 2}) to the corresponding layer dimension index, or\n // `-1`.\n const displayToLayerDimensionIndices: number[] = [];\n\n for (let displayDim = 0; displayDim < 3; ++displayDim) {\n const globalDim = displayDimensionIndices[displayDim];\n if (globalDim === -1) continue;\n const layerDim = globalToRenderLayerDimensions[globalDim];\n displayToLayerDimensionIndices.push(layerDim);\n if (layerDim === -1) continue;\n layerDisplayDimensionIndices.push(layerDim);\n }\n for (let i = displayToLayerDimensionIndices.length; i < 3; ++i) {\n displayToLayerDimensionIndices[i] = -1;\n }\n return { layerDisplayDimensionIndices, displayToLayerDimensionIndices };\n}\n\nexport function getChunkDisplayTransformParameters(\n chunkTransform: ChunkTransformParameters,\n layerDisplayDimensionMapping: LayerDisplayDimensionMapping,\n): ChunkDisplayTransformParameters {\n const { chunkToLayerTransform, modelTransform } = chunkTransform;\n const rank = modelTransform.rank;\n const { layerDisplayDimensionIndices, displayToLayerDimensionIndices } =\n layerDisplayDimensionMapping;\n const numLayerDisplayDims = layerDisplayDimensionIndices.length;\n const chunkDisplayDimensionIndices = getDependentTransformInputDimensions(\n chunkToLayerTransform,\n rank,\n layerDisplayDimensionIndices,\n );\n if (chunkDisplayDimensionIndices.length !== numLayerDisplayDims) {\n const { modelDimensionNames, layerDimensionNames } = modelTransform;\n throw new Error(\n \"Rank mismatch between displayed layer dimensions \" +\n `(${Array.from(\n layerDisplayDimensionIndices,\n (i) => layerDimensionNames[i],\n ).join(\",\\u00a0\")}) ` +\n \"and corresponding chunk dimensions \" +\n `(${Array.from(\n chunkDisplayDimensionIndices,\n (i) => modelDimensionNames[i],\n ).join(\",\\u00a0\")})`,\n );\n }\n // Compute \"model matrix\" (transform from the displayed subspace of the chunk space) to the global\n // display coordinate space.\n const displaySubspaceModelMatrix = mat4.create();\n for (let displayDim = 0; displayDim < 3; ++displayDim) {\n const layerDim = displayToLayerDimensionIndices[displayDim];\n if (layerDim === -1) continue;\n for (\n let chunkDisplayDimIndex = 0;\n chunkDisplayDimIndex < numLayerDisplayDims;\n ++chunkDisplayDimIndex\n ) {\n const chunkDim = chunkDisplayDimensionIndices[chunkDisplayDimIndex];\n displaySubspaceModelMatrix[chunkDisplayDimIndex * 4 + displayDim] =\n chunkToLayerTransform[chunkDim * (rank + 1) + layerDim];\n }\n displaySubspaceModelMatrix[12 + displayDim] =\n chunkToLayerTransform[rank * (rank + 1) + layerDim];\n }\n const displaySubspaceInvModelMatrix = mat4.create();\n mat4.invert(displaySubspaceInvModelMatrix, displaySubspaceModelMatrix);\n\n for (let i = chunkDisplayDimensionIndices.length; i < 3; ++i) {\n chunkDisplayDimensionIndices[i] = -1;\n }\n return {\n modelTransform: chunkTransform.modelTransform,\n chunkTransform,\n displaySubspaceModelMatrix,\n displaySubspaceInvModelMatrix,\n chunkDisplayDimensionIndices,\n numChunkDisplayDims: numLayerDisplayDims,\n };\n}\n\nexport function getChunkPositionFromCombinedGlobalLocalPositions(\n chunkPosition: Float32Array,\n globalPosition: Float32Array,\n localPosition: Float32Array,\n layerRank: number,\n combinedGlobalLocalToChunkTransform: Float32Array,\n) {\n const globalRank = globalPosition.length;\n const localRank = localPosition.length;\n const rank = chunkPosition.length;\n let valid = true;\n for (let chunkDim = 0; chunkDim < layerRank; ++chunkDim) {\n let off = chunkDim;\n let sum = 0;\n for (let globalDim = 0; globalDim < globalRank; ++globalDim) {\n sum +=\n combinedGlobalLocalToChunkTransform[off + globalDim * layerRank] *\n globalPosition[globalDim];\n }\n off += globalRank * layerRank;\n for (let localDim = 0; localDim < localRank; ++localDim) {\n sum +=\n combinedGlobalLocalToChunkTransform[off + localDim * layerRank] *\n localPosition[localDim];\n }\n sum += combinedGlobalLocalToChunkTransform[off + localRank * layerRank];\n if (chunkDim < rank) {\n chunkPosition[chunkDim] = sum;\n } else {\n // Handle clipping\n if (sum < 0 || sum >= 1) {\n valid = false;\n }\n }\n }\n return valid;\n}\n\nexport function getLayerPositionFromCombinedGlobalLocalPositions(\n layerPosition: Float32Array,\n globalPosition: Float32Array,\n localPosition: Float32Array,\n modelTransform: RenderLayerTransform,\n) {\n scatterUpdate(\n layerPosition,\n globalPosition,\n modelTransform.globalToRenderLayerDimensions,\n );\n scatterUpdate(\n layerPosition,\n localPosition,\n modelTransform.localToRenderLayerDimensions,\n );\n return layerPosition;\n}\n\nexport function get3dModelToDisplaySpaceMatrix(\n out: mat4,\n displayDimensionRenderInfo: DisplayDimensionRenderInfo,\n transform: RenderLayerTransform,\n) {\n out.fill(0);\n out[15] = 1;\n let fullRank = true;\n const { displayDimensionIndices } = displayDimensionRenderInfo;\n const { globalToRenderLayerDimensions, modelToRenderLayerTransform } =\n transform;\n const layerRank = transform.rank;\n for (let displayDim = 0; displayDim < 3; ++displayDim) {\n const globalDim = displayDimensionIndices[displayDim];\n if (globalDim === -1) {\n fullRank = false;\n continue;\n }\n const layerDim = globalToRenderLayerDimensions[globalDim];\n if (layerDim === -1) {\n fullRank = false;\n continue;\n }\n out[displayDim + 12] =\n modelToRenderLayerTransform[layerDim + layerRank * (layerRank + 1)];\n for (let modelDim = 0; modelDim < 3; ++modelDim) {\n out[displayDim + 4 * modelDim] =\n modelToRenderLayerTransform[layerDim + (layerRank + 1) * modelDim];\n }\n }\n if (!fullRank) {\n const { globalDimensionNames } = displayDimensionRenderInfo;\n const displayDimDesc = Array.from(\n displayDimensionIndices.filter((i) => i !== -1),\n (i) => globalDimensionNames[i],\n ).join(\",\\u00a0\");\n throw new Error(\n `Transform from model dimensions (${transform.modelDimensionNames.join(\n \",\\u00a0\",\n )}) ` +\n `to display dimensions (${displayDimDesc}) does not have full rank`,\n );\n }\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport enum ChunkState {\n // Chunk is stored in GPU memory in addition to system memory.\n GPU_MEMORY = 0,\n // Chunk is stored only in system memory but not in GPU memory.\n SYSTEM_MEMORY = 1,\n\n // Chunk is stored in system memory on worker.\n SYSTEM_MEMORY_WORKER = 2,\n\n // Chunk is downloading.\n DOWNLOADING = 3,\n // Chunk is not yet downloading.\n QUEUED = 4,\n\n // Chunk has just been added.\n NEW = 5,\n\n // Download failed.\n FAILED = 6,\n\n EXPIRED = 7,\n\n // If new states are added, keep numChangeStates in sync.\n}\n\nexport const numChunkStates = 8;\n\nexport enum ChunkPriorityTier {\n FIRST_TIER = 0,\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n FIRST_ORDERED_TIER = 0,\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n VISIBLE = 0,\n PREFETCH = 1,\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n LAST_ORDERED_TIER = 1,\n RECENT = 2,\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n LAST_TIER = 2,\n}\n\nexport const numChunkPriorityTiers = 3;\n\nexport enum ChunkDownloadStatistics {\n totalTime = 0,\n totalChunks = 1,\n}\n\nexport enum ChunkMemoryStatistics {\n numChunks = 0,\n systemMemoryBytes = 1,\n gpuMemoryBytes = 2,\n}\n\nexport const numChunkMemoryStatistics = 3;\n\nexport const numChunkDownloadStatistics = 2;\n\nexport const numChunkStatistics =\n numChunkStates * numChunkPriorityTiers * numChunkMemoryStatistics +\n numChunkDownloadStatistics;\n\nexport function getChunkStateStatisticIndex(\n state: ChunkState,\n priorityTier: ChunkPriorityTier,\n) {\n return state * numChunkPriorityTiers + priorityTier;\n}\n\nexport function getChunkDownloadStatisticIndex(\n statistic: ChunkDownloadStatistics,\n) {\n return (\n numChunkStates * numChunkPriorityTiers * numChunkMemoryStatistics +\n statistic\n );\n}\n\nexport const PREFETCH_PRIORITY_MULTIPLIER = 1e13;\n\nexport const CHUNK_QUEUE_MANAGER_RPC_ID = \"ChunkQueueManager\";\nexport const CHUNK_MANAGER_RPC_ID = \"ChunkManager\";\nexport const CHUNK_SOURCE_INVALIDATE_RPC_ID = \"ChunkSource.invalidate\";\n\nexport const REQUEST_CHUNK_STATISTICS_RPC_ID =\n \"ChunkQueueManager.requestChunkStatistics\";\n\n// Used for sending per-layer visible/prefetch chunk statistics from backend to frontend.\nexport const CHUNK_LAYER_STATISTICS_RPC_ID =\n \"ChunkManager.chunkLayerStatistics\";\n\nexport interface ChunkSourceParametersConstructor {\n new (): T;\n RPC_ID: string;\n}\n\nexport class LayerChunkProgressInfo {\n numVisibleChunksNeeded = 0;\n numVisibleChunksAvailable = 0;\n numPrefetchChunksNeeded = 0;\n numPrefetchChunksAvailable = 0;\n}\n","/**\n * @license\n * Copyright 2024 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport enum FrameTimingMethod {\n MEDIAN = 0,\n MEAN = 1,\n MAX = 2,\n}\n\nexport class FramerateMonitor {\n private timeElapsedQueries: (WebGLQuery | null)[] = [];\n private warnedAboutMissingExtension = false;\n private storedTimeDeltas: number[] = [];\n\n constructor(\n private numStoredTimes: number = 10,\n private queryPoolSize: number = 10,\n ) {\n if (this.queryPoolSize < 1) {\n throw new Error(\n `Query pool size must be at least 1, but got ${queryPoolSize}.`,\n );\n }\n }\n\n getTimingExtension(gl: WebGL2RenderingContext) {\n const ext = gl.getExtension(\"EXT_disjoint_timer_query_webgl2\");\n if (ext === null && !this.warnedAboutMissingExtension) {\n console.log(\n \"EXT_disjoint_timer_query_webgl2 extension not available. \" +\n \"Cannot measure frame time.\",\n );\n this.warnedAboutMissingExtension = true;\n }\n return ext;\n }\n\n startFrameTimeQuery(gl: WebGL2RenderingContext, ext: any) {\n if (ext === null) {\n return null;\n }\n const query = gl.createQuery();\n if (query !== null) {\n gl.beginQuery(ext.TIME_ELAPSED_EXT, query);\n }\n return query;\n }\n\n endFrameTimeQuery(\n gl: WebGL2RenderingContext,\n ext: any,\n query: WebGLQuery | null,\n ) {\n if (ext !== null && query !== null) {\n gl.endQuery(ext.TIME_ELAPSED_EXT);\n }\n if (this.timeElapsedQueries.length >= this.queryPoolSize) {\n const oldestQuery = this.timeElapsedQueries.shift();\n if (oldestQuery !== null && oldestQuery !== undefined) {\n gl.deleteQuery(oldestQuery);\n }\n }\n this.timeElapsedQueries.push(query);\n }\n\n grabAnyFinishedQueryResults(gl: WebGL2RenderingContext) {\n const deletedQueryIndices: number[] = [];\n for (let i = 0; i < this.timeElapsedQueries.length; i++) {\n const query = this.timeElapsedQueries[i];\n if (query !== null) {\n const available = gl.getQueryParameter(\n query,\n gl.QUERY_RESULT_AVAILABLE,\n );\n if (available) {\n const result = gl.getQueryParameter(query, gl.QUERY_RESULT) / 1e6;\n this.storedTimeDeltas.push(result);\n gl.deleteQuery(query);\n deletedQueryIndices.push(i);\n }\n }\n }\n for (let i = deletedQueryIndices.length - 1; i >= 0; i--) {\n this.timeElapsedQueries.splice(i, 1);\n }\n if (this.storedTimeDeltas.length > this.numStoredTimes) {\n this.storedTimeDeltas = this.storedTimeDeltas.slice(-this.numStoredTimes);\n }\n }\n\n getLastFrameTimesInMs(numberOfFrames: number = 10) {\n return this.storedTimeDeltas.slice(-numberOfFrames);\n }\n\n getQueries() {\n return this.timeElapsedQueries;\n }\n}\n\nexport class DownsamplingBasedOnFrameRateCalculator {\n private lastFrameTime: number | null = null;\n private frameDeltas: number[] = [];\n private downsamplingRates: Map = new Map();\n private frameCount = 0;\n\n /**\n * @param numberOfStoredFrameDeltas The number of frame deltas to store. Oldest frame deltas are removed. Must be at least 1.\n * @param maxDownsamplingFactor The maximum factor for downsampling. Must be at least 2.\n * @param desiredFrameTimingMs The desired frame timing in milliseconds. The downsampling rate is based on a comparison of the actual frame timing to this value.\n * @param downsamplingPersistenceDurationInFrames The max number of frames over which a high downsampling rate persists.\n */\n constructor(\n public numberOfStoredFrameDeltas: number = 10,\n private maxDownsamplingFactor: number = 8,\n private desiredFrameTimingMs = 1000 / 60,\n private downsamplingPersistenceDurationInFrames = 15,\n ) {\n this.validateConstructorArguments();\n for (let i = 1; i <= this.maxDownsamplingFactor; i *= 2) {\n this.downsamplingRates.set(i, -Infinity);\n }\n }\n\n private validateConstructorArguments() {\n this.numberOfStoredFrameDeltas = Math.max(\n 1,\n Math.round(this.numberOfStoredFrameDeltas),\n );\n this.maxDownsamplingFactor = Math.max(\n 2,\n Math.round(this.maxDownsamplingFactor),\n );\n }\n\n private storeFrameDelta(frameDelta: number) {\n this.frameDeltas.push(frameDelta);\n if (this.frameDeltas.length > this.numberOfStoredFrameDeltas) {\n this.frameDeltas.shift();\n }\n }\n\n private calculateMeanFrameTime(): number {\n return (\n this.frameDeltas.reduce((a, b) => a + b, 0) / this.frameDeltas.length\n );\n }\n\n private calculateMedianFrameTime(): number {\n const sortedFrameDeltas = this.frameDeltas.slice().sort((a, b) => a - b);\n const midpoint = Math.floor(sortedFrameDeltas.length / 2);\n return sortedFrameDeltas.length % 2 === 1\n ? sortedFrameDeltas[midpoint]\n : (sortedFrameDeltas[midpoint - 1] + sortedFrameDeltas[midpoint]) / 2;\n }\n\n private calculateMaxFrameTime(): number {\n return Math.max(...this.frameDeltas);\n }\n\n private updateMaxTrackedDownsamplingRate(downsampleFactor: number) {\n this.downsamplingRates.set(downsampleFactor, this.frameCount);\n let maxTrackedDownsamplingRate = 1;\n for (const [downsamplingRate, frameCount] of this.downsamplingRates) {\n if (\n this.frameCount - frameCount <=\n this.downsamplingPersistenceDurationInFrames\n ) {\n maxTrackedDownsamplingRate = downsamplingRate;\n }\n }\n return maxTrackedDownsamplingRate;\n }\n\n /* This doesn't reset stored frame deltas. Is usually called on a new continous camera move */\n resetForNewFrameSet() {\n this.lastFrameTime = null;\n this.frameCount = 0;\n this.downsamplingRates.forEach((_, key) => {\n this.downsamplingRates.set(key, -Infinity);\n });\n }\n\n addFrame(timestamp: number = Date.now()) {\n if (this.lastFrameTime !== null) {\n const frameDelta = timestamp - this.lastFrameTime;\n if (frameDelta > 0) {\n this.storeFrameDelta(frameDelta);\n }\n }\n this.lastFrameTime = timestamp;\n this.frameCount++;\n }\n\n calculateFrameTimeInMs(\n method: FrameTimingMethod = FrameTimingMethod.MAX,\n ): number {\n if (this.frameDeltas.length === 0) {\n return 0;\n }\n switch (method) {\n case FrameTimingMethod.MEDIAN:\n return this.calculateMedianFrameTime();\n case FrameTimingMethod.MEAN:\n return this.calculateMeanFrameTime();\n case FrameTimingMethod.MAX:\n return this.calculateMaxFrameTime();\n }\n }\n\n /** Should be called once per frame for proper downsampling persistence */\n calculateDownsamplingRate(\n method: FrameTimingMethod = FrameTimingMethod.MEAN,\n ): number {\n const calculatedFrameTime = this.calculateFrameTimeInMs(method);\n if (calculatedFrameTime === 0) {\n // Don't add this one to tracking, it's just to start the process\n return Math.min(4, this.maxDownsamplingFactor);\n }\n let downsampleFactorBasedOnFramerate = Math.max(\n calculatedFrameTime / this.desiredFrameTimingMs,\n 1,\n );\n // Round to the nearest power of 2.\n downsampleFactorBasedOnFramerate = Math.min(\n Math.pow(2, Math.round(Math.log2(downsampleFactorBasedOnFramerate))),\n this.maxDownsamplingFactor,\n );\n return this.updateMaxTrackedDownsamplingRate(\n downsampleFactorBasedOnFramerate,\n );\n }\n\n getFrameDeltas(): number[] {\n return this.frameDeltas;\n }\n\n getFrameCount(): number {\n return this.frameCount;\n }\n\n getDownsamplingRates(): Map {\n return this.downsamplingRates;\n }\n\n setFrameDeltas(frameDeltas: number[], incrementFrameCount = true) {\n this.frameDeltas = frameDeltas.slice(-this.numberOfStoredFrameDeltas);\n if (incrementFrameCount) {\n this.frameCount++;\n }\n }\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { debounce } from \"lodash-es\";\n\nimport type { FrameNumberCounter } from \"#src/chunk_manager/frontend.js\";\nimport { TrackableValue } from \"#src/trackable_value.js\";\nimport { animationFrameDebounce } from \"#src/util/animation_frame_debounce.js\";\nimport type { Borrowed } from \"#src/util/disposable.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport { FramerateMonitor } from \"#src/util/framerate.js\";\nimport type { mat4 } from \"#src/util/geom.js\";\nimport { parseFixedLengthArray, verifyFloat01 } from \"#src/util/json.js\";\nimport { NullarySignal } from \"#src/util/signal.js\";\nimport type { WatchableVisibilityPriority } from \"#src/visibility_priority/frontend.js\";\nimport type { GL } from \"#src/webgl/context.js\";\nimport { initializeWebGL } from \"#src/webgl/context.js\";\n\nconst DELAY_AFTER_CONTINUOUS_CAMERA_MOTION_MS = 300;\n\nexport class RenderViewport {\n // Width of visible portion of panel in canvas pixels.\n width = 0;\n\n // Height of visible portion of panel in canvas pixels.\n height = 0;\n\n // Width in canvas pixels, including portions outside of the canvas (i.e. outside the \"viewport\"\n // window).\n logicalWidth = 0;\n\n // Height in canvas pixels, including portions outside of the canvas (i.e. outside the \"viewport\"\n // window).\n logicalHeight = 0;\n\n // Left edge of visible region within full (logical) panel, as fraction in [0, 1].\n visibleLeftFraction = 0;\n\n // Top edge of visible region within full (logical) panel, as fraction in [0, 1].\n visibleTopFraction = 0;\n\n // Fraction of logical width that is visible, equal to `widthInCanvasPixels / logicalWidth`.\n visibleWidthFraction = 0;\n\n // Fraction of logical height that is visible, equal to `heightInCanvasPixels / logicalHeight`.\n visibleHeightFraction = 0;\n}\n\nexport function applyRenderViewportToProjectionMatrix(\n viewport: RenderViewport,\n projectionMatrix: mat4,\n) {\n const xScale = 1 / viewport.visibleWidthFraction;\n const yScale = 1 / viewport.visibleHeightFraction;\n const xOffset = -1 - (-1 + 2 * viewport.visibleLeftFraction) * xScale;\n let yOffset = -1 - (-1 + 2 * viewport.visibleTopFraction) * yScale;\n yOffset = -yOffset;\n projectionMatrix[0] =\n projectionMatrix[0] * xScale + projectionMatrix[3] * xOffset;\n projectionMatrix[4] =\n projectionMatrix[4] * xScale + projectionMatrix[7] * xOffset;\n projectionMatrix[8] =\n projectionMatrix[8] * xScale + projectionMatrix[11] * xOffset;\n projectionMatrix[12] =\n projectionMatrix[12] * xScale + projectionMatrix[15] * xOffset;\n\n projectionMatrix[1] =\n projectionMatrix[1] * yScale + projectionMatrix[3] * yOffset;\n projectionMatrix[5] =\n projectionMatrix[5] * yScale + projectionMatrix[7] * yOffset;\n projectionMatrix[9] =\n projectionMatrix[9] * yScale + projectionMatrix[11] * yOffset;\n projectionMatrix[13] =\n projectionMatrix[13] * yScale + projectionMatrix[15] * yOffset;\n}\n\nexport function renderViewportsEqual(a: RenderViewport, b: RenderViewport) {\n return (\n a.width === b.width &&\n a.height === b.height &&\n a.logicalWidth === b.logicalWidth &&\n a.logicalHeight === b.logicalHeight &&\n a.visibleLeftFraction === b.visibleLeftFraction &&\n a.visibleTopFraction === b.visibleTopFraction\n );\n}\n\nexport abstract class RenderedPanel extends RefCounted {\n gl: GL;\n\n // Generation used to check whether the following bounds-related fields are up to date.\n boundsGeneration = -1;\n\n // Offset of visible portion of panel in canvas pixels from left side of canvas.\n canvasRelativeClippedLeft = 0;\n\n // Offset of visible portion of panel in canvas pixels from top of canvas.\n canvasRelativeClippedTop = 0;\n\n canvasRelativeLogicalLeft = 0;\n canvasRelativeLogicalTop = 0;\n\n renderViewport = new RenderViewport();\n\n private monitorState: PanelMonitorState = {};\n\n constructor(\n public context: Borrowed,\n public element: HTMLElement,\n public visibility: WatchableVisibilityPriority,\n ) {\n super();\n this.gl = context.gl;\n context.addPanel(this);\n }\n\n scheduleRedraw() {\n if (this.visible) {\n this.context.scheduleRedraw();\n }\n }\n\n abstract isReady(): boolean;\n\n ensureBoundsUpdated() {\n const { context } = this;\n context.ensureBoundsUpdated();\n const { boundsGeneration } = context;\n if (boundsGeneration === this.boundsGeneration) return;\n this.boundsGeneration = boundsGeneration;\n const { element } = this;\n const clientRect = element.getBoundingClientRect();\n context.ensureMonitorPanel(element, this.monitorState, clientRect);\n const root = context.container;\n const canvasRect = context.canvasRect!;\n const { canvas } = context;\n const { width: canvasPixelWidth, height: canvasPixelHeight } = canvas;\n const screenToCanvasPixelScaleX = canvasPixelWidth / canvasRect.width;\n const screenToCanvasPixelScaleY = canvasPixelHeight / canvasRect.height;\n // Logical bounding rectangle in canvas/WebGL pixels (which may be a different size than screen\n // pixels when using a fixed canvas size via the Python integration).\n const canvasLeft = canvasRect.left;\n const canvasTop = canvasRect.top;\n const logicalLeft = (this.canvasRelativeLogicalLeft = Math.round(\n (clientRect.left - canvasLeft) * screenToCanvasPixelScaleX +\n element.clientLeft,\n ));\n const logicalTop = (this.canvasRelativeLogicalTop = Math.round(\n (clientRect.top - canvasTop) * screenToCanvasPixelScaleY +\n element.clientTop,\n ));\n const logicalWidth = element.clientWidth;\n const logicalHeight = element.clientHeight;\n const logicalRight = logicalLeft + logicalWidth;\n const logicalBottom = logicalTop + logicalHeight;\n // Clipped bounding rectangle in canvas/WebGL pixels. The clipped bounding rectangle is the\n // portion actually visible and overlapping the canvas.\n let clippedTop = logicalTop;\n let clippedLeft = logicalLeft;\n let clippedRight = logicalRight;\n let clippedBottom = logicalBottom;\n for (\n let parent = element.parentElement;\n parent !== null && parent !== root;\n parent = parent.parentElement\n ) {\n const rect = parent.getBoundingClientRect();\n if (\n rect.x === 0 &&\n rect.y === 0 &&\n rect.width === 0 &&\n rect.height === 0\n ) {\n // Assume this is a `display: contents;` element.\n continue;\n }\n clippedLeft = Math.max(\n clippedLeft,\n (rect.left - canvasLeft) * screenToCanvasPixelScaleX,\n );\n clippedTop = Math.max(\n clippedTop,\n (rect.top - canvasTop) * screenToCanvasPixelScaleY,\n );\n clippedRight = Math.min(\n clippedRight,\n (rect.right - canvasLeft) * screenToCanvasPixelScaleX,\n );\n clippedBottom = Math.min(\n clippedBottom,\n (rect.bottom - canvasTop) * screenToCanvasPixelScaleY,\n );\n }\n clippedTop = this.canvasRelativeClippedTop = Math.round(\n Math.max(clippedTop, 0),\n );\n clippedLeft = this.canvasRelativeClippedLeft = Math.round(\n Math.max(clippedLeft, 0),\n );\n clippedRight = Math.round(Math.min(clippedRight, canvasPixelWidth));\n clippedBottom = Math.round(Math.min(clippedBottom, canvasPixelHeight));\n const viewport = this.renderViewport;\n const clippedWidth = (viewport.width = Math.max(\n 0,\n clippedRight - clippedLeft,\n ));\n const clippedHeight = (viewport.height = Math.max(\n 0,\n clippedBottom - clippedTop,\n ));\n viewport.logicalWidth = logicalWidth;\n viewport.logicalHeight = logicalHeight;\n viewport.visibleLeftFraction = (clippedLeft - logicalLeft) / logicalWidth;\n viewport.visibleTopFraction = (clippedTop - logicalTop) / logicalHeight;\n viewport.visibleWidthFraction = clippedWidth / logicalWidth;\n viewport.visibleHeightFraction = clippedHeight / logicalHeight;\n }\n\n // Sets the viewport to the clipped viewport. Any drawing must take\n // `visible{Left,Top,Width,Height}Fraction` into account. setGLClippedViewport() {\n setGLClippedViewport() {\n const {\n gl,\n canvasRelativeClippedTop,\n canvasRelativeClippedLeft,\n renderViewport: { width, height },\n } = this;\n const bottom = canvasRelativeClippedTop + height;\n gl.enable(WebGL2RenderingContext.SCISSOR_TEST);\n const glBottom = this.context.canvas.height - bottom;\n gl.viewport(canvasRelativeClippedLeft, glBottom, width, height);\n gl.scissor(canvasRelativeClippedLeft, glBottom, width, height);\n }\n\n // Sets the viewport to the logical viewport, using the scissor test to constrain drawing to the\n // clipped viewport. Drawing does not need to take `visible{Left,Top,Width,Height}Fraction` into\n // account.\n setGLLogicalViewport() {\n const {\n gl,\n renderViewport: { width, height, logicalWidth, logicalHeight },\n } = this;\n const canvasHeight = this.context.canvas.height;\n gl.enable(WebGL2RenderingContext.SCISSOR_TEST);\n gl.viewport(\n this.canvasRelativeLogicalLeft,\n canvasHeight - (this.canvasRelativeLogicalTop + logicalHeight),\n logicalWidth,\n logicalHeight,\n );\n gl.scissor(\n this.canvasRelativeClippedLeft,\n canvasHeight - (this.canvasRelativeClippedTop + height),\n width,\n height,\n );\n }\n\n abstract draw(): void;\n\n disposed() {\n this.context.unmonitorPanel(this.element, this.monitorState);\n this.context.removePanel(this);\n super.disposed();\n }\n\n get visible() {\n return this.visibility.visible;\n }\n\n getDepthArray(): Float32Array | undefined {\n return undefined;\n }\n\n get shouldDraw() {\n if (!this.visible) return false;\n const { element } = this;\n if (\n element.clientWidth === 0 ||\n element.clientHeight === 0 ||\n element.offsetWidth === 0 ||\n element.offsetHeight === 0\n ) {\n // Skip drawing if the panel has zero client area.\n return false;\n }\n return true;\n }\n\n // Returns a number that determine the order in which panels are drawn. This is used by CdfPanel\n // to ensure it is drawn after other panels that update the histogram.\n //\n // A higher number -> later draw.\n get drawOrder() {\n return 0;\n }\n}\n\nexport abstract class IndirectRenderedPanel extends RenderedPanel {\n canvas = document.createElement(\"canvas\");\n canvasRenderingContext = this.canvas.getContext(\"2d\");\n constructor(\n context: Borrowed,\n element: HTMLElement,\n visibility: WatchableVisibilityPriority,\n ) {\n super(context, element, visibility);\n const { canvas } = this;\n element.appendChild(canvas);\n element.style.position = \"relative\";\n canvas.style.position = \"absolute\";\n canvas.style.left = \"0\";\n canvas.style.right = \"0\";\n canvas.style.top = \"0\";\n canvas.style.bottom = \"0\";\n }\n\n abstract drawIndirect(): void;\n\n draw() {\n this.drawIndirect();\n const { renderViewport, canvas } = this;\n const { logicalWidth, logicalHeight } = renderViewport;\n canvas.width = logicalWidth;\n canvas.height = logicalHeight;\n const { canvasRenderingContext } = this;\n canvasRenderingContext?.drawImage(\n this.context.canvas,\n this.canvasRelativeLogicalLeft,\n this.canvasRelativeLogicalTop,\n logicalWidth,\n logicalHeight,\n 0,\n 0,\n logicalWidth,\n logicalHeight,\n );\n }\n}\n\n// Specifies a rectangular sub-region of the full viewer area to actually be rendered on the canvas.\n// This is used by the Python integration to produce large screenshots by tiling multiple\n// screenshots.\n//\n// The value is: `[left, top, width, height]` where all values are in [0, 1].\nexport class TrackableWindowedViewport extends TrackableValue {\n constructor() {\n super(Float64Array.of(0, 0, 1, 1), (obj) =>\n parseFixedLengthArray(new Float64Array(4), obj, verifyFloat01),\n );\n }\n toJSON() {\n const { value } = this;\n const [left, top, width, height] = value;\n if (left === 0 && top === 0 && width === 1 && height === 1)\n return undefined;\n return Array.from(value);\n }\n}\n\n// Size/position monitoring state for a single panel.\ninterface PanelMonitorState {\n // Intersection observer used to detect movement of a panel. The root element is always the root\n // container element.\n intersectionObserver?: IntersectionObserver;\n\n // Margin within the root element chosen to exactly match the bounds\n // of the panel element when the IntersectionObserver was created.\n // When the bounds of either the root element or the panel element\n // have possibly changed, the new margin is computed and compared to\n // this value. This is stored separately, rather than just relying\n // on `intersectionObserver?.rootMargin`, to avoid spuriously change\n // detections due to normalization that the browser may do.\n intersectionObserverMargin?: string;\n\n // Indicates that the panel element was added to the resize observer.\n addedToResizeObserver?: boolean;\n}\n\nexport class DisplayContext extends RefCounted implements FrameNumberCounter {\n canvas = document.createElement(\"canvas\");\n gl: GL;\n updateStarted = new NullarySignal();\n updateFinished = new NullarySignal();\n continuousCameraMotionStarted = new NullarySignal();\n continuousCameraMotionFinished = new NullarySignal();\n changed = this.updateFinished;\n panels = new Set();\n canvasRect: DOMRect | undefined;\n rootRect: DOMRect | undefined;\n resizeGeneration = 0;\n boundsGeneration = -1;\n private framerateMonitor = new FramerateMonitor();\n\n private continuousCameraMotionInProgress = false;\n\n // Panels ordered by `drawOrder`. If length is 0, needs to be recomputed.\n private orderedPanels: RenderedPanel[] = [];\n\n /**\n * Unique number of the next frame. Incremented once each time a frame is drawn.\n */\n frameNumber = 0;\n\n resizeCallback = () => {\n ++this.resizeGeneration;\n this.scheduleRedraw();\n };\n\n ensureMonitorPanel(\n element: HTMLElement,\n state: PanelMonitorState,\n elementClientRect: DOMRect,\n ) {\n if (!state.addedToResizeObserver) {\n this.resizeObserver.observe(element);\n state.addedToResizeObserver = true;\n }\n const rootRect = this.rootRect!;\n const marginTop = rootRect.top - elementClientRect.top;\n const marginLeft = rootRect.left - elementClientRect.left;\n const marginRight = elementClientRect.right - rootRect.right;\n const marginBottom = elementClientRect.bottom - rootRect.bottom;\n const margin = `${marginTop}px ${marginRight}px ${marginBottom}px ${marginLeft}px`;\n if (state.intersectionObserverMargin !== margin) {\n state.intersectionObserverMargin = margin;\n state.intersectionObserver?.disconnect();\n const intersectionObserver = (state.intersectionObserver =\n new IntersectionObserver(this.resizeCallback, {\n root: this.container,\n rootMargin: margin,\n threshold: [0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99, 1],\n }));\n intersectionObserver.observe(element);\n }\n }\n\n unmonitorPanel(element: HTMLElement, state: PanelMonitorState) {\n if (state.addedToResizeObserver) {\n this.resizeObserver.unobserve(element);\n }\n state.intersectionObserver?.disconnect();\n }\n\n private resizeObserver = new ResizeObserver(this.resizeCallback);\n\n private debouncedEndContinuousCameraMotion = this.registerCancellable(\n debounce(() => {\n this.continuousCameraMotionInProgress = false;\n this.continuousCameraMotionFinished.dispatch();\n }, DELAY_AFTER_CONTINUOUS_CAMERA_MOTION_MS),\n );\n\n flagContinuousCameraMotion() {\n if (!this.continuousCameraMotionInProgress) {\n this.continuousCameraMotionStarted.dispatch();\n }\n this.continuousCameraMotionInProgress = true;\n this.debouncedEndContinuousCameraMotion();\n }\n\n get isContinuousCameraMotionInProgress() {\n return this.continuousCameraMotionInProgress;\n }\n\n constructor(public container: HTMLElement) {\n super();\n const { canvas, resizeObserver } = this;\n container.style.position = \"relative\";\n canvas.style.position = \"absolute\";\n canvas.style.top = \"0px\";\n canvas.style.left = \"0px\";\n canvas.style.width = \"100%\";\n canvas.style.height = \"100%\";\n canvas.style.zIndex = \"0\";\n resizeObserver.observe(canvas);\n container.appendChild(canvas);\n this.registerEventListener(\n canvas,\n \"webglcontextlost\",\n (event: WebGLContextEvent) => {\n console.log(`Lost WebGL context: ${event.statusMessage}`);\n // Wait for context to be regained.\n event.preventDefault();\n },\n );\n this.registerEventListener(canvas, \"webglcontextrestored\", () => {\n console.log(\"WebGL context restored\");\n // Simply reload Neuroglancer.\n window.location.reload();\n });\n this.gl = initializeWebGL(canvas);\n }\n\n applyWindowedViewportToElement(element: HTMLElement, value: Float64Array) {\n // These values specify the position of the canvas relative to the viewer. However, we will\n // actually leave the canvas in place (such that it still fills the browser window) and move\n // the viewer.\n const [left, top, width, height] = value;\n const totalWidth = 1 / width;\n const totalHeight = 1 / height;\n element.style.position = \"absolute\";\n element.style.top = `${-totalHeight * top * 100}%`;\n element.style.left = `${-totalWidth * left * 100}%`;\n element.style.width = `${totalWidth * 100}%`;\n element.style.height = `${totalHeight * 100}%`;\n ++this.resizeGeneration;\n this.scheduleRedraw();\n }\n\n isReady() {\n for (const panel of this.panels) {\n if (!panel.visible) {\n continue;\n }\n if (!panel.isReady()) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Returns a child element that overlays the canvas.\n */\n makeCanvasOverlayElement() {\n const element = document.createElement(\"div\");\n element.style.position = \"absolute\";\n element.style.top = \"0px\";\n element.style.left = \"0px\";\n element.style.width = \"100%\";\n element.style.height = \"100%\";\n element.style.zIndex = \"2\";\n this.container.appendChild(element);\n return element;\n }\n\n disposed() {\n this.orderedPanels.length = 0;\n this.resizeObserver.disconnect();\n }\n\n addPanel(panel: Borrowed) {\n this.panels.add(panel);\n this.orderedPanels.length = 0;\n ++this.resizeGeneration;\n this.scheduleRedraw();\n }\n\n removePanel(panel: Borrowed) {\n this.panels.delete(panel);\n this.orderedPanels.length = 0;\n ++this.resizeGeneration;\n this.scheduleRedraw();\n }\n\n readonly scheduleRedraw = this.registerCancellable(\n animationFrameDebounce(() => this.draw()),\n );\n\n ensureBoundsUpdated() {\n const { resizeGeneration } = this;\n if (this.boundsGeneration === resizeGeneration) return;\n const { canvas } = this;\n canvas.width = canvas.offsetWidth;\n canvas.height = canvas.offsetHeight;\n this.canvasRect = canvas.getBoundingClientRect();\n this.rootRect = this.container.getBoundingClientRect();\n this.boundsGeneration = resizeGeneration;\n }\n\n draw() {\n ++this.frameNumber;\n this.updateStarted.dispatch();\n const gl = this.gl;\n const ext = this.framerateMonitor.getTimingExtension(gl);\n const query = this.framerateMonitor.startFrameTimeQuery(gl, ext);\n this.ensureBoundsUpdated();\n this.gl.clearColor(0.0, 0.0, 0.0, 0.0);\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n const { orderedPanels, panels } = this;\n if (orderedPanels.length !== panels.size) {\n orderedPanels.push(...panels);\n orderedPanels.sort((a, b) => a.drawOrder - b.drawOrder);\n }\n for (const panel of orderedPanels) {\n if (!panel.shouldDraw) continue;\n panel.ensureBoundsUpdated();\n const { renderViewport } = panel;\n if (renderViewport.width === 0 || renderViewport.height === 0) continue;\n panel.draw();\n }\n\n // Ensure the alpha buffer is set to 1.\n gl.disable(gl.SCISSOR_TEST);\n this.gl.clearColor(1.0, 1.0, 1.0, 1.0);\n this.gl.colorMask(false, false, false, true);\n gl.clear(gl.COLOR_BUFFER_BIT);\n this.gl.colorMask(true, true, true, true);\n this.updateFinished.dispatch();\n this.framerateMonitor.endFrameTimeQuery(gl, ext, query);\n this.framerateMonitor.grabAnyFinishedQueryResults(gl);\n }\n\n getDepthArray(): Float32Array {\n const { width, height } = this.canvas;\n const depthArray = new Float32Array(width * height);\n for (const panel of this.panels) {\n if (!panel.shouldDraw) continue;\n const panelDepthArray = panel.getDepthArray();\n if (panelDepthArray === undefined) continue;\n const {\n canvasRelativeClippedTop,\n canvasRelativeClippedLeft,\n renderViewport: { width, height },\n } = panel;\n for (let y = 0; y < height; ++y) {\n const panelDepthArrayOffset = (height - 1 - y) * width;\n depthArray.set(\n panelDepthArray.subarray(\n panelDepthArrayOffset,\n panelDepthArrayOffset + width,\n ),\n (canvasRelativeClippedTop + y) * width + canvasRelativeClippedLeft,\n );\n }\n }\n return depthArray;\n }\n\n getLastFrameTimesInMs(numberOfFrames: number = 10) {\n return this.framerateMonitor.getLastFrameTimesInMs(numberOfFrames);\n }\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { RenderViewport, renderViewportsEqual } from \"#src/display_context.js\";\nimport type { DisplayDimensionRenderInfo } from \"#src/navigation_state.js\";\nimport { arraysEqual } from \"#src/util/array.js\";\nimport { mat4 } from \"#src/util/geom.js\";\nimport { kEmptyFloat32Vec } from \"#src/util/vector.js\";\n\nexport class ProjectionParameters extends RenderViewport {\n displayDimensionRenderInfo: DisplayDimensionRenderInfo;\n\n /**\n * Global position.\n */\n globalPosition: Float32Array = kEmptyFloat32Vec;\n\n /**\n * Transform from camera coordinates to OpenGL clip coordinates.\n */\n projectionMat: mat4 = mat4.create();\n\n /**\n * Transform from world coordinates to camera coordinates.\n */\n viewMatrix: mat4 = mat4.create();\n\n /**\n * Inverse of `viewMat`.\n */\n invViewMatrix: mat4 = mat4.create();\n\n /**\n * Transform from world coordinates to OpenGL clip coordinates. Equal to:\n * `projectionMat * viewMat`.\n */\n viewProjectionMat: mat4 = mat4.create();\n\n /**\n * Inverse of `viewProjectionMat`.\n */\n invViewProjectionMat: mat4 = mat4.create();\n}\n\nexport function projectionParametersEqual(\n a: ProjectionParameters,\n b: ProjectionParameters,\n) {\n return (\n a.displayDimensionRenderInfo === b.displayDimensionRenderInfo &&\n renderViewportsEqual(a, b) &&\n arraysEqual(a.globalPosition, b.globalPosition) &&\n arraysEqual(a.projectionMat, b.projectionMat) &&\n arraysEqual(a.viewMatrix, b.viewMatrix)\n );\n}\n\nexport function updateProjectionParametersFromInverseViewAndProjection(\n p: ProjectionParameters,\n) {\n const { viewMatrix, viewProjectionMat } = p;\n mat4.invert(viewMatrix, p.invViewMatrix);\n mat4.multiply(viewProjectionMat, p.projectionMat, viewMatrix);\n mat4.invert(p.invViewProjectionMat, viewProjectionMat);\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @file Message list framework for messages to be displayed in the UI.\n */\n\nimport { NullarySignal } from \"#src/util/signal.js\";\n\nexport enum MessageSeverity {\n info = 0,\n warning = 1,\n error = 2,\n}\n\nexport class Message {\n severity: MessageSeverity;\n message: string;\n}\n\nexport class MessageList {\n changed = new NullarySignal();\n\n private messages: Message[] = [];\n private children: MessageList[] = [];\n\n addMessage(message: Message) {\n this.messages.push(message);\n this.changed.dispatch();\n }\n\n clearMessages() {\n const { messages } = this;\n if (messages.length === 0) return;\n messages.length = 0;\n this.changed.dispatch();\n }\n\n isEmpty(): boolean {\n return (\n this.messages.length === 0 && !this.children.some((x) => !x.isEmpty())\n );\n }\n\n addChild(list: MessageList) {\n this.children.push(list);\n list.changed.add(this.changed.dispatch);\n if (!list.isEmpty()) {\n this.changed.dispatch();\n }\n return () => {\n const { children } = this;\n children.splice(children.indexOf(list), 1);\n list.changed.remove(this.changed.dispatch);\n if (!list.isEmpty()) {\n this.changed.dispatch();\n }\n };\n }\n\n *[Symbol.iterator](): Iterator {\n yield* this.messages;\n for (const child of this.children) {\n yield* child;\n }\n }\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { CancellationToken } from \"#src/util/cancellation.js\";\nimport {\n CANCELED,\n CancellationTokenSource,\n makeCancelablePromise,\n uncancelableToken,\n} from \"#src/util/cancellation.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\n\nexport type RPCHandler = (this: RPC, x: any) => void;\n\nexport type RpcId = number;\n\nconst IS_WORKER = !(typeof Window !== \"undefined\" && self instanceof Window);\n\nconst DEBUG = false;\n\nconst DEBUG_MESSAGES = false;\n\nconst PROMISE_RESPONSE_ID = \"rpc.promise.response\";\nconst PROMISE_CANCEL_ID = \"rpc.promise.cancel\";\nconst READY_ID = \"rpc.ready\";\n\nconst handlers = new Map();\n\nexport function registerRPC(key: string, handler: RPCHandler) {\n handlers.set(key, handler);\n}\n\nexport type RPCPromise = Promise<{ value: T; transfers?: any[] }>;\n\nexport class RPCError extends Error {\n constructor(\n public name: string,\n public message: string,\n ) {\n super(message);\n }\n}\n\nexport function registerPromiseRPC(\n key: string,\n handler: (\n this: RPC,\n x: any,\n cancellationToken: CancellationToken,\n ) => RPCPromise,\n) {\n registerRPC(key, function (this: RPC, x: any) {\n const id = x.id;\n const cancellationToken = new CancellationTokenSource();\n const promise = handler.call(this, x, cancellationToken) as RPCPromise;\n this.set(id, { promise, cancellationToken });\n promise.then(\n ({ value, transfers }) => {\n this.delete(id);\n this.invoke(PROMISE_RESPONSE_ID, { id: id, value: value }, transfers);\n },\n (error) => {\n this.delete(id);\n this.invoke(PROMISE_RESPONSE_ID, {\n id: id,\n error: error.message,\n errorName: error.name,\n });\n },\n );\n });\n}\n\nregisterRPC(PROMISE_CANCEL_ID, function (this: RPC, x: any) {\n const id = x.id;\n const request = this.get(id);\n if (request !== undefined) {\n const { cancellationToken } = request;\n cancellationToken.cancel();\n }\n});\n\nregisterRPC(PROMISE_RESPONSE_ID, function (this: RPC, x: any) {\n const id = x.id;\n const { resolve, reject } = this.get(id);\n this.delete(id);\n if (Object.prototype.hasOwnProperty.call(x, \"value\")) {\n resolve(x.value);\n } else {\n const errorName = x.errorName;\n if (errorName === CANCELED.name) {\n reject(CANCELED);\n } else {\n reject(new RPCError(x.errorName, x.error));\n }\n }\n});\n\nregisterRPC(READY_ID, function (this: RPC, x: any) {\n x;\n this.onPeerReady();\n});\n\ninterface RPCTarget {\n postMessage(message?: any, ports?: any): void;\n onmessage: ((ev: MessageEvent) => any) | null;\n}\n\nconst INITIAL_RPC_ID = IS_WORKER ? -1 : 0;\n\nexport class RPC {\n private objects = new Map();\n private nextId: RpcId = INITIAL_RPC_ID;\n private queue: { data: any; transfers?: any[] }[] | undefined;\n constructor(\n public target: RPCTarget,\n waitUntilReady: boolean,\n ) {\n if (waitUntilReady) {\n this.queue = [];\n }\n target.onmessage = (e) => {\n const data = e.data;\n if (DEBUG_MESSAGES) {\n console.log(\"Received message\", data);\n }\n handlers.get(data.functionName)!.call(this, data);\n };\n }\n\n sendReady() {\n this.invoke(READY_ID, {});\n }\n\n onPeerReady() {\n const { queue } = this;\n if (queue === undefined) return;\n this.queue = undefined;\n for (const { data, transfers } of queue) {\n this.target.postMessage(data, transfers);\n }\n }\n\n get numObjects() {\n return this.objects.size;\n }\n\n set(id: RpcId, value: any) {\n this.objects.set(id, value);\n }\n\n delete(id: RpcId) {\n this.objects.delete(id);\n }\n get(id: RpcId) {\n return this.objects.get(id);\n }\n getRef(x: { id: RpcId; gen: number }): T {\n const rpcId = x.id;\n const obj = this.get(rpcId);\n obj.referencedGeneration = x.gen;\n obj.addRef();\n return obj;\n }\n\n getOptionalRef(x: {\n id: RpcId;\n gen: number;\n }): T | undefined {\n if (x === undefined) return undefined;\n const rpcId = x.id;\n const obj = this.get(rpcId) as T;\n obj.referencedGeneration = x.gen;\n obj.addRef();\n return obj;\n }\n\n invoke(name: string, x: any, transfers?: any[]) {\n x.functionName = name;\n if (DEBUG_MESSAGES) {\n console.trace(\"Sending message\", x);\n }\n const { queue } = this;\n if (queue !== undefined) {\n queue.push({ data: x, transfers });\n return;\n }\n this.target.postMessage(x, transfers);\n }\n\n promiseInvoke(\n name: string,\n x: any,\n cancellationToken = uncancelableToken,\n transfers?: any[],\n ): Promise {\n return makeCancelablePromise(\n cancellationToken,\n (resolve, reject, token) => {\n const id = (x.id = this.newId());\n this.set(id, { resolve, reject });\n this.invoke(name, x, transfers);\n token.add(() => {\n this.invoke(PROMISE_CANCEL_ID, { id: id });\n });\n },\n );\n }\n newId() {\n return IS_WORKER ? this.nextId-- : this.nextId++;\n }\n}\n\nexport class SharedObject extends RefCounted {\n rpc: RPC | null = null;\n rpcId: RpcId | null = null;\n isOwner: boolean | undefined;\n unreferencedGeneration: number;\n referencedGeneration: number;\n\n initializeSharedObject(rpc: RPC, rpcId = rpc.newId()) {\n this.rpc = rpc;\n this.rpcId = rpcId;\n this.isOwner = false;\n rpc.set(rpcId, this);\n }\n\n initializeCounterpart(rpc: RPC, options: any = {}) {\n this.initializeSharedObject(rpc);\n this.unreferencedGeneration = 0;\n this.referencedGeneration = 0;\n this.isOwner = true;\n options.id = this.rpcId;\n options.type = this.RPC_TYPE_ID;\n rpc.invoke(\"SharedObject.new\", options);\n }\n\n dispose() {\n super.dispose();\n }\n\n /**\n * Precondition: this.isOwner === true.\n */\n addCounterpartRef() {\n return { id: this.rpcId, gen: ++this.referencedGeneration };\n }\n\n protected refCountReachedZero() {\n if (this.isOwner === true) {\n if (this.referencedGeneration === this.unreferencedGeneration) {\n this.ownerDispose();\n }\n } else if (this.isOwner === false) {\n this.rpc!.invoke(\"SharedObject.refCountReachedZero\", {\n id: this.rpcId,\n gen: this.referencedGeneration,\n });\n } else {\n super.refCountReachedZero();\n }\n }\n\n /**\n * Precondition: this.isOwner === true.\n */\n protected ownerDispose() {\n if (DEBUG) {\n console.log(`[${IS_WORKER}] #rpc object = ${this.rpc!.numObjects}`);\n }\n const { rpc, rpcId } = this;\n super.refCountReachedZero();\n rpc!.delete(rpcId!);\n rpc!.invoke(\"SharedObject.dispose\", { id: rpcId });\n }\n\n /**\n * Precondition: this.isOwner === true.\n *\n * This should be called when the counterpart's refCount is decremented and reaches zero.\n */\n counterpartRefCountReachedZero(generation: number) {\n this.unreferencedGeneration = generation;\n if (this.refCount === 0 && generation === this.referencedGeneration) {\n this.ownerDispose();\n }\n }\n\n /**\n * Should be set to a constant specifying the SharedObject type identifier on the prototype of\n * final derived owner classes. It is not used on counterpart (non-owner) classes.\n */\n RPC_TYPE_ID: string;\n}\n\nexport function initializeSharedObjectCounterpart(\n obj: SharedObject,\n rpc?: RPC,\n options: any = {},\n) {\n if (rpc != null) {\n obj.initializeSharedObject(rpc, options.id);\n }\n}\n\n/**\n * Base class for defining a SharedObject type that will never be owned.\n */\nexport class SharedObjectCounterpart extends SharedObject {\n constructor(rpc?: RPC, options: any = {}) {\n super();\n initializeSharedObjectCounterpart(this, rpc, options);\n }\n}\n\nexport interface SharedObjectConstructor {\n new (rpc: RPC, options: any): SharedObjectCounterpart;\n}\n\nregisterRPC(\"SharedObject.dispose\", function (x) {\n const obj = this.get(x.id);\n if (obj.refCount !== 0) {\n throw new Error(\n \"Attempted to dispose object with non-zero reference count.\",\n );\n }\n if (DEBUG) {\n console.log(`[${IS_WORKER}] #rpc objects: ${this.numObjects}`);\n }\n obj.disposed();\n this.delete(obj.rpcId!);\n obj.rpcId = null;\n obj.rpc = null;\n});\n\nregisterRPC(\"SharedObject.refCountReachedZero\", function (x) {\n const obj = this.get(x.id);\n const generation = x.gen;\n obj.counterpartRefCountReachedZero(generation);\n});\n\nconst sharedObjectConstructors = new Map();\n\n/**\n * Register a class as a SharedObject owner type under the specified identifier.\n *\n * This is intended to be used as a decorator.\n */\nexport function registerSharedObjectOwner(identifier: string) {\n return (constructorFunction: { prototype: { RPC_TYPE_ID: string } }) => {\n constructorFunction.prototype.RPC_TYPE_ID = identifier;\n };\n}\n\n/**\n * Register a class as a SharedObject counterpart type under the specified identifier.\n *\n * This is intended to be used as a decorator.\n *\n * Also register the type as a SharedObject owner, which is useful if this type is also used as a\n * SharedObject owner.\n */\nexport function registerSharedObject(identifier?: string) {\n return (constructorFunction: SharedObjectConstructor) => {\n if (identifier !== undefined) {\n constructorFunction.prototype.RPC_TYPE_ID = identifier;\n } else {\n identifier = constructorFunction.prototype.RPC_TYPE_ID;\n if (identifier === undefined) {\n throw new Error(\"RPC_TYPE_ID should have already been defined\");\n }\n }\n sharedObjectConstructors.set(identifier, constructorFunction);\n };\n}\n\nregisterRPC(\"SharedObject.new\", function (x) {\n const rpc = this;\n const typeName = x.type;\n const constructorFunction = sharedObjectConstructors.get(typeName)!;\n const obj = new constructorFunction(rpc, x);\n // Counterpart objects start with a reference count of zero.\n --obj.refCount;\n});\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @file Facility for sharing arbitrary values that support structural cloning between threads.\n */\n\nimport type { WatchableValueInterface } from \"#src/trackable_value.js\";\nimport { WatchableValue } from \"#src/trackable_value.js\";\nimport type { RPC } from \"#src/worker_rpc.js\";\nimport {\n registerRPC,\n registerSharedObject,\n SharedObjectCounterpart,\n} from \"#src/worker_rpc.js\";\n\nconst CHANGED_RPC_METHOD_ID = \"SharedWatchableValue.changed\";\n\n@registerSharedObject(\"SharedWatchableValue\")\nexport class SharedWatchableValue\n extends SharedObjectCounterpart\n implements WatchableValueInterface\n{\n base: WatchableValueInterface;\n\n /**\n * The value is being updated to reflect a remote change.\n * @internal\n */\n updatingValue_ = false;\n\n constructor(rpc?: RPC, options: any = {}) {\n super(rpc, options);\n if (rpc !== undefined) {\n this.base = new WatchableValue(options.value);\n this.setupChangedHandler();\n }\n }\n\n initializeCounterpart(rpc: RPC, options: any = {}) {\n options.value = this.value;\n super.initializeCounterpart(rpc, options);\n }\n\n private setupChangedHandler() {\n this.registerDisposer(\n this.base.changed.add(() => {\n if (this.updatingValue_) {\n this.updatingValue_ = false;\n } else {\n const { rpc } = this;\n if (rpc !== null) {\n rpc.invoke(CHANGED_RPC_METHOD_ID, {\n id: this.rpcId,\n value: this.value,\n });\n }\n }\n }),\n );\n }\n\n static makeFromExisting(rpc: RPC, base: WatchableValueInterface) {\n const obj = new SharedWatchableValue();\n obj.base = base;\n obj.setupChangedHandler();\n obj.initializeCounterpart(rpc);\n return obj;\n }\n\n static make(rpc: RPC, value: T) {\n return SharedWatchableValue.makeFromExisting(\n rpc,\n new WatchableValue(value),\n );\n }\n\n get value() {\n return this.base.value;\n }\n\n set value(value: T) {\n this.base.value = value;\n }\n\n get changed() {\n return this.base.changed;\n }\n}\n\nregisterRPC(CHANGED_RPC_METHOD_ID, function (x) {\n const obj = >this.get(x.id);\n obj.updatingValue_ = true;\n obj.base.value = x.value;\n obj.updatingValue_ = false;\n});\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SharedWatchableValue } from \"#src/shared_watchable_value.js\";\nimport { WatchableValue } from \"#src/trackable_value.js\";\nimport type { RPC, SharedObject } from \"#src/worker_rpc.js\";\n\n/**\n * Numeric value specifying a visibility or prefetch priority.\n *\n * A value of `Number.POSITIVE_INFINITY` means visible.\n *\n * Any other finite value means not visible, and specifies the prefetch priority (higher means\n * higher priority); this should always be a small integer.\n *\n * A value of `Number.NEGATIVE_INFINITY` means ignored (not visible, and not prefetched).\n */\nexport type VisibilityPriority = number;\n\nexport class WatchableVisibilityPriority extends WatchableValue {\n // biome-ignore lint/complexity/noUselessConstructor: adds defaults\n constructor(value = Number.NEGATIVE_INFINITY) {\n super(value);\n }\n\n static VISIBLE = Number.POSITIVE_INFINITY;\n static IGNORED = Number.NEGATIVE_INFINITY;\n get visible() {\n return this.value === Number.POSITIVE_INFINITY;\n }\n\n get ignored() {\n return this.value === Number.NEGATIVE_INFINITY;\n }\n}\n\nexport interface VisibilityPrioritySpecification {\n visibility: WatchableVisibilityPriority;\n}\n\n/**\n * Maintains the maximum value of multiple WatchableVisibilityPriority values.\n */\nexport class VisibilityPriorityAggregator extends WatchableVisibilityPriority {\n private contributors = new Map<() => void, WatchableVisibilityPriority>();\n\n /**\n * Registers `x` to be included in the set of values to be aggregated.\n *\n * @returns A disposer function that unregisters the specified value.\n */\n add(x: WatchableVisibilityPriority) {\n const { contributors } = this;\n const changedDisposer = x.changed.add(() => {\n this.update();\n });\n const disposer = () => {\n contributors.delete(disposer);\n changedDisposer();\n this.update();\n };\n contributors.set(disposer, x);\n this.update();\n return disposer;\n }\n\n private update() {\n let priority = Number.NEGATIVE_INFINITY;\n for (const x of this.contributors.values()) {\n priority = Math.max(priority, x.value);\n }\n this.value = priority;\n }\n}\n\n/**\n * Mixin that adds a `visibility` property which is shared with the counterpart.\n */\nexport function withSharedVisibility<\n T extends { new (...args: any[]): SharedObject },\n>(Base: T) {\n return class extends Base {\n visibility = new VisibilityPriorityAggregator();\n\n initializeCounterpart(rpc: RPC, options: any = {}) {\n // Backend doesn't need to own a reference to SharedWatchableValue because frontend, which is\n // the owner of this SharedObject, owns a reference.\n options.visibility = this.registerDisposer(\n SharedWatchableValue.makeFromExisting(rpc, this.visibility),\n ).rpcId;\n super.initializeCounterpart(rpc, options);\n }\n };\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { debounce } from \"lodash-es\";\nimport { LayerChunkProgressInfo } from \"#src/chunk_manager/base.js\";\nimport { RenderViewport, renderViewportsEqual } from \"#src/display_context.js\";\nimport type {\n LayerView,\n MouseSelectionState,\n PickState,\n UserLayer,\n VisibleLayerInfo,\n} from \"#src/layer/index.js\";\nimport type {\n DisplayDimensionRenderInfo,\n NavigationState,\n} from \"#src/navigation_state.js\";\nimport type { PickIDManager } from \"#src/object_picking.js\";\nimport {\n ProjectionParameters,\n projectionParametersEqual,\n} from \"#src/projection_parameters.js\";\nimport type { RenderLayerTransformOrError } from \"#src/render_coordinate_transform.js\";\nimport { get3dModelToDisplaySpaceMatrix } from \"#src/render_coordinate_transform.js\";\nimport {\n PROJECTION_PARAMETERS_CHANGED_RPC_METHOD_ID,\n PROJECTION_PARAMETERS_RPC_ID,\n} from \"#src/render_layer_common.js\";\nimport type { WatchableValueChangeInterface } from \"#src/trackable_value.js\";\nimport { WatchableSet } from \"#src/trackable_value.js\";\nimport type { Borrowed } from \"#src/util/disposable.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport { mat4 } from \"#src/util/geom.js\";\nimport { MessageList, MessageSeverity } from \"#src/util/message_list.js\";\nimport { NullarySignal, Signal } from \"#src/util/signal.js\";\nimport type { Uint64 } from \"#src/util/uint64.js\";\nimport { VisibilityPriorityAggregator } from \"#src/visibility_priority/frontend.js\";\nimport type { RPC } from \"#src/worker_rpc.js\";\nimport { registerSharedObjectOwner, SharedObject } from \"#src/worker_rpc.js\";\n\nexport enum RenderLayerRole {\n DATA = 0,\n ANNOTATION = 1,\n DEFAULT_ANNOTATION = 2,\n}\n\nexport function allRenderLayerRoles() {\n return new WatchableSet([\n RenderLayerRole.DATA,\n RenderLayerRole.ANNOTATION,\n RenderLayerRole.DEFAULT_ANNOTATION,\n ]);\n}\n\nexport class RenderLayer extends RefCounted {\n userLayer: UserLayer | undefined;\n role: RenderLayerRole = RenderLayerRole.DATA;\n messages = new MessageList();\n layerChanged = new NullarySignal();\n redrawNeeded = new NullarySignal();\n layerChunkProgressInfo = new LayerChunkProgressInfo();\n\n handleAction(_action: string) {\n // Do nothing by default.\n }\n\n getValueAt(_x: Float32Array): any {\n return undefined;\n }\n\n /**\n * Transform the stored pickedValue and offset associated with the retrieved pick ID into the\n * actual value.\n */\n transformPickedValue(pickState: PickState): any {\n return pickState.pickedValue;\n }\n\n /**\n * Optionally updates the mouse state based on the retrived pick information. This might snap the\n * 3-d position to the center of the picked point.\n */\n updateMouseState(\n _mouseState: MouseSelectionState,\n _pickedValue: Uint64,\n _pickedOffset: number,\n _data: any,\n ) {}\n}\n\n/**\n * Extends RenderLayer with functionality for tracking the number of panels in which the layer is\n * visible.\n */\nexport class VisibilityTrackedRenderLayer<\n View extends LayerView = LayerView,\n AttachmentState = unknown,\n> extends RenderLayer {\n backend: SharedObject | undefined;\n visibility = new VisibilityPriorityAggregator();\n attach(attachment: VisibleLayerInfo) {\n attachment;\n }\n}\n\nexport interface ThreeDimensionalReadyRenderContext {\n projectionParameters: ProjectionParameters;\n}\n\nexport interface ThreeDimensionalRenderContext\n extends ThreeDimensionalReadyRenderContext {\n pickIDs: PickIDManager;\n wireFrame: boolean;\n bindFramebuffer: () => void;\n frameNumber: number;\n}\n\nexport interface ThreeDimensionalRenderLayerAttachmentState {\n transform: RenderLayerTransformOrError;\n displayDimensionRenderInfo: DisplayDimensionRenderInfo;\n modelTransform: mat4 | undefined;\n}\n\nexport function update3dRenderLayerAttachment(\n transform: RenderLayerTransformOrError,\n displayDimensionRenderInfo: DisplayDimensionRenderInfo,\n attachment: VisibleLayerInfo<\n LayerView,\n ThreeDimensionalRenderLayerAttachmentState\n >,\n): mat4 | undefined {\n let { state } = attachment;\n if (\n state === undefined ||\n state.transform !== transform ||\n state.displayDimensionRenderInfo !== displayDimensionRenderInfo\n ) {\n attachment.messages.clearMessages();\n state = attachment.state = {\n transform,\n displayDimensionRenderInfo,\n modelTransform: undefined,\n };\n if (transform.error !== undefined) {\n attachment.messages.addMessage({\n severity: MessageSeverity.error,\n message: transform.error,\n });\n return undefined;\n }\n try {\n const modelTransform = mat4.create();\n get3dModelToDisplaySpaceMatrix(\n modelTransform,\n displayDimensionRenderInfo,\n transform,\n );\n state.modelTransform = modelTransform;\n } catch (e) {\n attachment.messages.addMessage({\n severity: MessageSeverity.error,\n message: (e as Error).message,\n });\n }\n }\n return state.modelTransform;\n}\n\nexport class DerivedProjectionParameters<\n Parameters extends ProjectionParameters = ProjectionParameters,\n >\n extends RefCounted\n implements WatchableValueChangeInterface\n{\n private oldValue_: Parameters;\n private value_: Parameters;\n private renderViewport = new RenderViewport();\n\n changed = new Signal<(oldValue: Parameters, newValue: Parameters) => void>();\n constructor(options: {\n navigationState: Borrowed;\n update: (out: Parameters, navigationState: NavigationState) => void;\n isEqual?: (a: Parameters, b: Parameters) => boolean;\n parametersConstructor?: { new (): Parameters };\n }) {\n super();\n const {\n parametersConstructor = ProjectionParameters as { new (): Parameters },\n navigationState,\n update,\n isEqual = projectionParametersEqual,\n } = options;\n this.oldValue_ = new parametersConstructor();\n this.value_ = new parametersConstructor();\n const performUpdate = () => {\n const { oldValue_, value_ } = this;\n oldValue_.displayDimensionRenderInfo =\n navigationState.displayDimensionRenderInfo.value;\n Object.assign(oldValue_, this.renderViewport);\n let { globalPosition } = oldValue_;\n const newGlobalPosition = navigationState.position.value;\n const rank = newGlobalPosition.length;\n if (globalPosition.length !== rank) {\n oldValue_.globalPosition = globalPosition = new Float32Array(rank);\n }\n globalPosition.set(newGlobalPosition);\n update(oldValue_, navigationState);\n if (isEqual(oldValue_, value_)) return;\n this.value_ = oldValue_;\n this.oldValue_ = value_;\n this.changed.dispatch(value_, oldValue_);\n };\n const debouncedUpdate = (this.update = this.registerCancellable(\n debounce(performUpdate, 0),\n ));\n this.registerDisposer(navigationState.changed.add(debouncedUpdate));\n performUpdate();\n }\n\n setViewport(viewport: RenderViewport) {\n if (renderViewportsEqual(viewport, this.renderViewport)) return;\n Object.assign(this.renderViewport, viewport);\n this.update();\n }\n\n get value() {\n this.update.flush();\n return this.value_;\n }\n\n readonly update: (() => void) & { flush(): void };\n}\n\n@registerSharedObjectOwner(PROJECTION_PARAMETERS_RPC_ID)\nexport class SharedProjectionParameters<\n T extends ProjectionParameters = ProjectionParameters,\n> extends SharedObject {\n private prevDisplayDimensionRenderInfo:\n | undefined\n | DisplayDimensionRenderInfo = undefined;\n constructor(\n rpc: RPC,\n public base: WatchableValueChangeInterface,\n public updateInterval = 10,\n ) {\n super();\n this.initializeCounterpart(rpc, { value: base.value });\n this.registerDisposer(base.changed.add(this.update));\n }\n\n flush() {\n this.update.flush();\n }\n\n private update = this.registerCancellable(\n debounce((_oldValue: T, newValue: T) => {\n // Note: Because we are using debouce, we cannot rely on `_oldValue`, since\n // `DerivedProjectionParameters` reuses the objects.\n let valueUpdate: any;\n if (\n newValue.displayDimensionRenderInfo !==\n this.prevDisplayDimensionRenderInfo\n ) {\n valueUpdate = newValue;\n this.prevDisplayDimensionRenderInfo =\n newValue.displayDimensionRenderInfo;\n } else {\n const { displayDimensionRenderInfo, ...remainder } = newValue;\n valueUpdate = remainder;\n }\n this.rpc!.invoke(PROJECTION_PARAMETERS_CHANGED_RPC_METHOD_ID, {\n id: this.rpcId,\n value: valueUpdate,\n });\n }, this.updateInterval),\n );\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { debounce } from \"lodash-es\";\nimport type { WatchableValueInterface } from \"#src/trackable_value.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport { NullarySignal } from \"#src/util/signal.js\";\nimport type { Trackable } from \"#src/util/trackable.js\";\n\nexport class TrackableBoolean implements Trackable {\n get value() {\n return this.value_;\n }\n set value(newValue: boolean) {\n if (newValue !== this.value_) {\n this.value_ = newValue;\n this.changed.dispatch();\n }\n }\n toggle() {\n this.value = !this.value;\n }\n changed = new NullarySignal();\n constructor(\n private value_: boolean,\n public defaultValue: boolean = value_,\n ) {}\n toJSON() {\n const { value_ } = this;\n if (value_ === this.defaultValue) {\n return undefined;\n }\n return this.value_;\n }\n restoreState(x: any) {\n if (x === true || x === false) {\n this.value = x;\n return;\n }\n this.value = this.defaultValue;\n }\n reset() {\n this.value = this.defaultValue;\n }\n}\n\nexport class TrackableBooleanCheckbox extends RefCounted {\n element = document.createElement(\"input\");\n constructor(\n public model: WatchableValueInterface,\n options: {\n enableTitle?: string;\n disableTitle?: string;\n } = {},\n ) {\n super();\n const { element } = this;\n element.type = \"checkbox\";\n\n const updateCheckbox = () => {\n const value = this.model.value;\n this.element.checked = value;\n if (\n options.enableTitle !== undefined ||\n options.disableTitle !== undefined\n ) {\n this.element.title =\n (value ? options.enableTitle : options.disableTitle) ?? \"\";\n }\n };\n\n this.registerDisposer(model.changed.add(updateCheckbox));\n updateCheckbox();\n this.registerEventListener(\n element,\n \"change\",\n function (this: typeof element, _e: Event) {\n model.value = this.checked;\n },\n );\n\n // Prevent the checkbox from becoming focused.\n element.addEventListener(\"mousedown\", (event: MouseEvent) => {\n event.preventDefault();\n });\n }\n\n disposed() {\n const { element } = this;\n const { parentElement } = element;\n if (parentElement) {\n parentElement.removeChild(element);\n }\n super.disposed();\n }\n}\n\nexport class ElementVisibilityFromTrackableBoolean extends RefCounted {\n private initialDisplay = this.element.style.display;\n constructor(\n public model: WatchableValueInterface,\n public element: HTMLElement,\n ) {\n super();\n this.updateVisibility();\n this.registerDisposer(\n model.changed.add(\n this.registerCancellable(debounce(() => this.updateVisibility(), 0)),\n ),\n );\n }\n\n updateVisibility() {\n this.element.style.display = this.model.value\n ? this.initialDisplay\n : \"none\";\n }\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type ValueOrError = (T & { error?: undefined }) | { error: string };\n\nexport function makeValueOrError(f: () => T): ValueOrError {\n try {\n return f() as ValueOrError;\n } catch (e) {\n return { error: (e as Error).message };\n }\n}\n\nexport function valueOrThrow(x: ValueOrError): T {\n if (x.error !== undefined) throw new Error(x.error);\n return x;\n}\n","/**\n * @license\n * Copyright 2018 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport { NullarySignal } from \"#src/util/signal.js\";\n\nexport class WatchableMap extends RefCounted {\n changed = new NullarySignal();\n map: Map;\n private disposerMap = new Map();\n constructor(\n private register: (context: RefCounted, v: V, k: K) => void,\n values?: Iterable<[K, V]>,\n ) {\n super();\n if (values === undefined) {\n this.map = new Map();\n } else {\n const map = (this.map = new Map(values));\n const { disposerMap } = this;\n for (const [key, value] of map) {\n const context = new RefCounted();\n disposerMap.set(key, context);\n register(context, value, key);\n }\n }\n }\n\n get value(): ReadonlyMap {\n return this.map;\n }\n\n set(key: K, value: V) {\n const { map, disposerMap } = this;\n let context = disposerMap.get(key);\n if (context !== undefined) {\n context.dispose();\n }\n context = new RefCounted();\n disposerMap.set(key, context);\n map.set(key, value);\n this.register(context, value, key);\n this.changed.dispatch();\n return this;\n }\n delete(key: K) {\n const { map, disposerMap } = this;\n const context = disposerMap.get(key);\n if (context !== undefined) {\n context.dispose();\n disposerMap.delete(key);\n map.delete(key);\n this.changed.dispatch();\n return true;\n }\n return false;\n }\n get(key: K) {\n return this.map.get(key);\n }\n has(key: K) {\n return this.map.has(key);\n }\n get size() {\n return this.map.size;\n }\n [Symbol.iterator]() {\n return this.map[Symbol.iterator]();\n }\n clear() {\n const { map, disposerMap } = this;\n if (map.size > 0) {\n for (const disposer of disposerMap.values()) {\n disposer.dispose();\n }\n map.clear();\n disposerMap.clear();\n this.changed.dispatch();\n }\n }\n values() {\n return this.map.values();\n }\n keys() {\n return this.map.keys();\n }\n disposed() {\n const { map, disposerMap } = this;\n for (const disposer of disposerMap.values()) {\n disposer.dispose();\n }\n map.clear();\n disposerMap.clear();\n super.disposed();\n }\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst OBJECT_ID_SYMBOL = Symbol(\"objectId\");\nlet nextObjectId = 0;\n\n/**\n * Returns a string that uniquely identifies a particular primitive value or object instance.\n */\nexport function getObjectId(x: any) {\n if (x instanceof Object) {\n let id = x[OBJECT_ID_SYMBOL];\n if (id === undefined) {\n id = x[OBJECT_ID_SYMBOL] = nextObjectId++;\n }\n return `o${id}`;\n }\n return \"\" + JSON.stringify(x);\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { DataType } from \"#src/util/data_type.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport type { GL } from \"#src/webgl/context.js\";\nimport type {\n ControlPointTexture,\n SortedControlPoints,\n} from \"#src/widget/transfer_function.js\";\n\nconst DEBUG_SHADER = false;\n\nexport enum ShaderType {\n VERTEX = WebGL2RenderingContext.VERTEX_SHADER,\n FRAGMENT = WebGL2RenderingContext.FRAGMENT_SHADER,\n}\n\nexport interface ShaderErrorMessage {\n file?: number;\n line?: number;\n message: string;\n}\n\n/**\n * Parses the output of getShaderInfoLog into a list of messages.\n */\nexport function parseShaderErrors(log: string) {\n log = log.replace(\"\\0\", \"\");\n const result: ShaderErrorMessage[] = [];\n for (let line of log.split(\"\\n\")) {\n let m = line.match(/^ERROR:\\s*(\\d+):(\\d+)\\s*(.+)$/);\n if (m !== null) {\n result.push({\n message: m[3].trim(),\n file: parseInt(m[1], 10),\n line: parseInt(m[2], 10),\n });\n } else {\n m = line.match(/^ERROR:\\s*(.+)$/);\n if (m !== null) {\n result.push({ message: m[1] });\n } else {\n line = line.trim();\n if (line) {\n result.push({ message: line });\n }\n }\n }\n }\n return result;\n}\n\nexport class ShaderCompilationError extends Error {\n shaderType: ShaderType;\n source: string;\n log: string;\n errorMessages: ShaderErrorMessage[];\n constructor(\n shaderType: ShaderType,\n source: string,\n log: string,\n errorMessages: ShaderErrorMessage[],\n ) {\n const message = `Error compiling ${ShaderType[\n shaderType\n ].toLowerCase()} shader: ${log}`;\n super(message);\n this.name = \"ShaderCompilationError\";\n this.log = log;\n this.message = message;\n this.shaderType = shaderType;\n this.source = source;\n this.errorMessages = errorMessages;\n }\n}\n\nexport class ShaderLinkError extends Error {\n vertexSource: string;\n fragmentSource: string;\n log: string;\n constructor(vertexSource: string, fragmentSource: string, log: string) {\n const message = `Error linking shader: ${log}`;\n super(message);\n this.name = \"ShaderLinkError\";\n this.log = log;\n this.message = message;\n this.vertexSource = vertexSource;\n this.fragmentSource = fragmentSource;\n }\n}\n\nexport function getShader(\n gl: WebGL2RenderingContext,\n source: string,\n shaderType: ShaderType,\n) {\n const shader = gl.createShader(shaderType)!;\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const log = gl.getShaderInfoLog(shader) || \"\";\n\n if (DEBUG_SHADER) {\n const lines = source\n .replace(\"<\", \"<\")\n .replace(\">\", \">\")\n .split(\"\\n\");\n let s = \"
\";\n      s += log.replace(\"<\", \"<\").replace(\">\", \">\") + \"\\n\";\n      lines.forEach((line, i) => {\n        s += `${i + 1}: ${line}\\n`;\n      });\n      s += \"\\n
\";\n console.log(s);\n const w = window.open(\"about:blank\", \"_blank\");\n if (w !== null) {\n try {\n w.document.write(s);\n } catch {\n // Ignore error writing output, e.g. due to popup blocking.\n }\n }\n }\n\n throw new ShaderCompilationError(\n shaderType,\n source,\n log,\n parseShaderErrors(log),\n );\n }\n\n return shader!;\n}\n\nexport type AttributeIndex = number;\n\nexport type AttributeType = number;\n\nexport interface VertexShaderInputBinder {\n enable(divisor: number): void;\n disable(): void;\n bind(stride: number, offset: number): void;\n}\n\nlet curShader: ShaderProgram | undefined;\n\nexport class ShaderProgram extends RefCounted {\n program: WebGLProgram;\n vertexShader: WebGLShader;\n fragmentShader: WebGLShader;\n attributes = new Map();\n uniforms = new Map();\n textureUnits: Map;\n vertexShaderInputBinders: { [name: string]: VertexShaderInputBinder } = {};\n vertexDebugOutputs?: VertexDebugOutput[];\n transferFunctionTextures: Map = new Map<\n any,\n ControlPointTexture\n >();\n\n constructor(\n public gl: GL,\n public vertexSource: string,\n public fragmentSource: string,\n uniformNames?: string[],\n attributeNames?: string[],\n vertexDebugOutputs?: VertexDebugOutput[],\n ) {\n super();\n const vertexShader = (this.vertexShader = getShader(\n gl,\n vertexSource,\n gl.VERTEX_SHADER,\n ));\n const fragmentShader = (this.fragmentShader = getShader(\n gl,\n fragmentSource,\n gl.FRAGMENT_SHADER,\n ));\n\n const shaderProgram = gl.createProgram()!;\n gl.attachShader(shaderProgram, vertexShader);\n gl.attachShader(shaderProgram, fragmentShader);\n\n if (DEBUG_SHADER && vertexDebugOutputs?.length) {\n gl.transformFeedbackVaryings(\n shaderProgram,\n vertexDebugOutputs.map((x) => x.name),\n WebGL2RenderingContext.INTERLEAVED_ATTRIBS,\n );\n this.vertexDebugOutputs = vertexDebugOutputs;\n }\n\n gl.linkProgram(shaderProgram);\n if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {\n const log = gl.getProgramInfoLog(shaderProgram) || \"\";\n\n // DEBUG\n // {\n // let combinedSource = 'VERTEX SHADER\\n\\n' + vertexSource + '\\n\\n\\nFRAGMENT SHADER\\n\\n' +\n // fragmentSource + '\\n';\n // let w = window.open(\"about:blank\", \"_blank\");\n // w.document.write('
' + combinedSource.replace('<', '<').replace('>', '>') +\n      //   '
');\n // }\n\n throw new ShaderLinkError(vertexSource, fragmentSource, log);\n }\n this.program = shaderProgram!;\n\n const { uniforms, attributes } = this;\n if (uniformNames) {\n for (const name of uniformNames) {\n uniforms.set(name, gl.getUniformLocation(shaderProgram, name));\n }\n }\n\n if (attributeNames) {\n for (const name of attributeNames) {\n attributes.set(name, gl.getAttribLocation(shaderProgram, name));\n }\n }\n }\n\n uniform(name: string): WebGLUniformLocation {\n return this.uniforms.get(name)!;\n }\n\n attribute(name: string): number {\n return this.attributes.get(name)!;\n }\n\n textureUnit(symbol: symbol | string): number {\n return this.textureUnits.get(symbol)!;\n }\n\n bind() {\n curShader = this;\n this.gl.useProgram(this.program);\n }\n\n bindAndUpdateTransferFunctionTexture(\n symbol: symbol | string,\n sortedControlPoints: SortedControlPoints,\n dataType: DataType,\n lookupTableSize: number,\n ) {\n const textureUnit = this.textureUnits.get(symbol);\n if (textureUnit === undefined) {\n throw new Error(`Invalid texture unit symbol: ${symbol.toString()}`);\n }\n const texture = this.transferFunctionTextures.get(symbol);\n if (texture === undefined) {\n throw new Error(\n `Invalid transfer function texture symbol: ${symbol.toString()}`,\n );\n }\n return texture.updateAndActivate({\n textureUnit,\n sortedControlPoints,\n dataType,\n lookupTableSize,\n });\n }\n\n unbindTransferFunctionTextures() {\n const gl = this.gl;\n for (const key of this.transferFunctionTextures.keys()) {\n const value = this.textureUnits.get(key);\n if (value !== undefined) {\n this.gl.activeTexture(gl.TEXTURE0 + value);\n this.gl.bindTexture(gl.TEXTURE_2D, null);\n }\n }\n }\n\n disposed() {\n const { gl } = this;\n gl.deleteShader(this.vertexShader);\n this.vertexShader = undefined;\n gl.deleteShader(this.fragmentShader);\n this.fragmentShader = undefined;\n gl.deleteProgram(this.program);\n this.program = undefined;\n this.gl = undefined;\n this.attributes = undefined;\n this.uniforms = undefined;\n this.transferFunctionTextures = undefined;\n }\n}\n\nexport function drawArraysInstanced(\n gl: WebGL2RenderingContext,\n mode: number,\n first: number,\n count: number,\n instanceCount: number,\n) {\n gl.drawArraysInstanced(mode, first, count, instanceCount);\n if (!DEBUG_SHADER || !curShader?.vertexDebugOutputs) {\n return;\n }\n\n const { vertexDebugOutputs } = curShader;\n let bytesPerVertex = 0;\n for (const debugOutput of vertexDebugOutputs) {\n bytesPerVertex += DEBUG_OUTPUT_TYPE_TO_BYTES[debugOutput.typeName];\n }\n const buffer = gl.createBuffer();\n const totalBytes = bytesPerVertex * count * instanceCount;\n gl.bindBuffer(WebGL2RenderingContext.ARRAY_BUFFER, buffer);\n gl.bufferData(\n WebGL2RenderingContext.ARRAY_BUFFER,\n totalBytes,\n WebGL2RenderingContext.DYNAMIC_DRAW,\n );\n gl.bindBuffer(WebGL2RenderingContext.ARRAY_BUFFER, null);\n gl.bindBufferBase(\n WebGL2RenderingContext.TRANSFORM_FEEDBACK_BUFFER,\n 0,\n buffer,\n );\n gl.beginTransformFeedback(WebGL2RenderingContext.POINTS);\n gl.enable(WebGL2RenderingContext.RASTERIZER_DISCARD);\n gl.drawArraysInstanced(\n WebGL2RenderingContext.POINTS,\n first,\n count,\n instanceCount,\n );\n gl.disable(WebGL2RenderingContext.RASTERIZER_DISCARD);\n gl.endTransformFeedback();\n gl.bindBufferBase(WebGL2RenderingContext.TRANSFORM_FEEDBACK_BUFFER, 0, null);\n gl.bindBuffer(WebGL2RenderingContext.ARRAY_BUFFER, buffer);\n const array = new Uint8Array(totalBytes);\n gl.getBufferSubData(\n WebGL2RenderingContext.ARRAY_BUFFER,\n 0,\n array,\n 0,\n totalBytes,\n );\n gl.bindBuffer(WebGL2RenderingContext.ARRAY_BUFFER, null);\n gl.deleteBuffer(buffer);\n let offset = 0;\n const floatView = new Float32Array(array.buffer);\n for (let instance = 0; instance < instanceCount; ++instance) {\n for (let vertex = 0; vertex < count; ++vertex) {\n let msg = `i=${instance} v=${vertex}:`;\n for (const debugOutput of vertexDebugOutputs) {\n msg += ` ${debugOutput.name}=`;\n switch (debugOutput.typeName) {\n case \"float\":\n msg += `${floatView[offset++]}`;\n break;\n case \"vec2\":\n msg += `${floatView[offset++]},${floatView[offset++]}`;\n break;\n case \"vec3\":\n msg += `${floatView[offset++]},${floatView[offset++]},${\n floatView[offset++]\n }`;\n break;\n case \"vec4\":\n msg += `${floatView[offset++]},${floatView[offset++]},${\n floatView[offset++]\n },${floatView[offset++]}`;\n break;\n }\n }\n console.log(msg);\n }\n }\n}\n\nexport type ShaderCodePart =\n | string\n | ShaderCodePartArray\n | ShaderCodePartFunction;\ninterface ShaderCodePartFunction {\n (): ShaderCodePart;\n}\ntype ShaderCodePartArray = Array;\n\nexport class ShaderCode {\n code = \"\";\n parts = new Set();\n\n add(x: ShaderCodePart) {\n if (this.parts.has(x)) {\n return;\n }\n this.parts.add(x);\n switch (typeof x) {\n case \"string\":\n this.code += x;\n break;\n case \"function\":\n this.add((x)());\n break;\n default:\n if (Array.isArray(x)) {\n for (const y of x) {\n this.add(y);\n }\n } else {\n console.log(\"Invalid code type\", x);\n throw new Error(\"Invalid code type\");\n }\n }\n }\n\n toString(): string {\n return this.code;\n }\n}\n\nexport type ShaderInitializer = (x: ShaderProgram) => void;\nexport type ShaderModule = (x: ShaderBuilder) => void;\n\nexport type ShaderSamplerPrefix = \"i\" | \"u\" | \"\";\n\nexport type ShaderSamplerType =\n | \"sampler2D\"\n | \"usampler2D\"\n | \"isampler2D\"\n | \"sampler3D\"\n | \"usampler3D\"\n | \"isampler3D\";\n\nexport type ShaderInterpolationMode =\n | \"\"\n | \"centroid\"\n | \"flat centroid\"\n | \"smooth centroid\"\n | \"flat\"\n | \"smooth\";\n\nexport const textureTargetForSamplerType = {\n sampler2D: WebGL2RenderingContext.TEXTURE_2D,\n isampler2D: WebGL2RenderingContext.TEXTURE_2D,\n usampler2D: WebGL2RenderingContext.TEXTURE_2D,\n sampler3D: WebGL2RenderingContext.TEXTURE_3D,\n isampler3D: WebGL2RenderingContext.TEXTURE_3D,\n usampler3D: WebGL2RenderingContext.TEXTURE_3D,\n};\n\nexport type DebugOutputType = \"float\" | \"vec2\" | \"vec3\" | \"vec4\";\n\nconst DEBUG_OUTPUT_TYPE_TO_BYTES: Record = {\n float: 4,\n vec2: 8,\n vec3: 12,\n vec4: 16,\n};\n\ninterface VertexDebugOutput {\n typeName: DebugOutputType;\n name: string;\n}\n\nexport class ShaderBuilder {\n private nextSymbolID = 0;\n private nextTextureUnit = 0;\n private uniformsCode = \"\";\n private attributesCode = \"\";\n private varyingsCodeVS = \"\";\n private varyingsCodeFS = \"\";\n private fragmentExtensionsSet = new Set();\n private fragmentExtensions = \"\";\n private vertexCode = new ShaderCode();\n private vertexMain = \"\";\n private fragmentCode = new ShaderCode();\n private outputBufferCode = \"\";\n private fragmentMain = \"\";\n private required = new Set();\n private uniforms = new Array();\n private attributes = new Array();\n private initializers: Array = [];\n private textureUnits = new Map();\n private vertexDebugOutputs: VertexDebugOutput[] = [];\n constructor(public gl: GL) {}\n\n addVertexPositionDebugOutput() {\n this.vertexDebugOutputs.push({ typeName: \"vec4\", name: \"gl_Position\" });\n }\n\n addVertexDebugOutput(typeName: DebugOutputType, name: string) {\n this.addVarying(typeName, name);\n this.vertexDebugOutputs.push({ typeName, name });\n }\n\n allocateTextureUnit(symbol: symbol | string, count = 1) {\n if (this.textureUnits.has(symbol)) {\n throw new Error(\"Duplicate texture unit symbol: \" + symbol.toString());\n }\n const old = this.nextTextureUnit;\n this.nextTextureUnit += count;\n this.textureUnits.set(symbol, old);\n return old;\n }\n\n addTextureSampler(\n samplerType: ShaderSamplerType,\n name: string,\n symbol: symbol | string,\n extent?: number,\n ) {\n const textureUnit = this.allocateTextureUnit(symbol, extent);\n this.addUniform(`highp ${samplerType}`, name, extent);\n this.addInitializer((shader) => {\n if (extent) {\n const textureUnits = new Int32Array(extent);\n for (let i = 0; i < extent; ++i) {\n textureUnits[i] = i + textureUnit;\n }\n shader.gl.uniform1iv(shader.uniform(name), textureUnits);\n } else {\n shader.gl.uniform1i(shader.uniform(name), textureUnit);\n }\n });\n return textureUnit;\n }\n\n symbol(name: string) {\n return name + this.nextSymbolID++;\n }\n\n addAttribute(typeName: string, name: string, location?: number) {\n this.attributes.push(name);\n if (location !== undefined)\n this.attributesCode += `layout(location = ${location})`;\n this.attributesCode += `in ${typeName} ${name};\\n`;\n return name;\n }\n\n addVarying(\n typeName: string,\n name: string,\n interpolationMode: ShaderInterpolationMode = \"\",\n ) {\n this.varyingsCodeVS += `${interpolationMode} out ${typeName} ${name};\\n`;\n this.varyingsCodeFS += `${interpolationMode} in ${typeName} ${name};\\n`;\n }\n\n addOutputBuffer(typeName: string, name: string, location: number | null) {\n if (location !== null) {\n this.outputBufferCode += `layout(location = ${location}) `;\n }\n this.outputBufferCode += `out ${typeName} ${name};\\n`;\n }\n\n addUniform(typeName: string, name: string, extent?: number) {\n this.uniforms.push(name);\n if (extent != null) {\n this.uniformsCode += `uniform ${typeName} ${name}[${extent}];\\n`;\n } else {\n this.uniformsCode += `uniform ${typeName} ${name};\\n`;\n }\n return name;\n }\n\n addFragmentExtension(name: string) {\n if (this.fragmentExtensionsSet.has(name)) {\n return;\n }\n this.fragmentExtensionsSet.add(name);\n this.fragmentExtensions += `#extension ${name} : require\\n`;\n }\n\n addVertexCode(code: ShaderCodePart) {\n this.vertexCode.add(code);\n }\n\n addFragmentCode(code: ShaderCodePart) {\n this.fragmentCode.add(code);\n }\n\n setVertexMain(code: string) {\n this.vertexMain = code;\n }\n addVertexMain(code: string) {\n this.vertexMain = (this.vertexMain || \"\") + code;\n }\n\n setFragmentMain(code: string) {\n this.fragmentMain = `void main() {\n${code}\n}\n`;\n }\n setFragmentMainFunction(code: string) {\n this.fragmentMain = code;\n }\n\n addInitializer(f: ShaderInitializer) {\n this.initializers.push(f);\n }\n\n require(f: ShaderModule): void {\n if (this.required.has(f)) {\n return;\n }\n this.required.add(f);\n f(this);\n }\n\n build() {\n const vertexSource = `#version 300 es\nprecision highp float;\nprecision highp int;\n${this.uniformsCode}\n${this.attributesCode}\n${this.varyingsCodeVS}\nfloat defaultMaxProjectionIntensity = 0.0;\n${this.vertexCode}\nvoid main() {\n${this.vertexMain}\n}\n`;\n const fragmentSource = `#version 300 es\n${this.fragmentExtensions}\nprecision highp float;\nprecision highp int;\n${this.uniformsCode}\n${this.varyingsCodeFS}\n${this.outputBufferCode}\nfloat defaultMaxProjectionIntensity = 0.0;\n${this.fragmentCode}\n${this.fragmentMain}\n`;\n const shader = new ShaderProgram(\n this.gl,\n vertexSource,\n fragmentSource,\n this.uniforms,\n this.attributes,\n this.vertexDebugOutputs,\n );\n shader.textureUnits = this.textureUnits;\n const { initializers } = this;\n if (initializers.length > 0) {\n shader.bind();\n for (const initializer of initializers) {\n initializer(shader);\n }\n }\n return shader;\n }\n}\n\nexport function shaderContainsIdentifiers(\n code: string,\n identifiers: Iterable,\n) {\n const found = new Set();\n for (const identifier of identifiers) {\n const pattern = new RegExp(\n `(?:^|[^a-zA-Z0-9_])${identifier}[^a-zA-Z0-9_])`,\n );\n if (code.match(pattern) !== null) {\n found.add(identifier);\n }\n }\n return found;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { WatchableValueInterface } from \"#src/trackable_value.js\";\nimport {\n constantWatchableValue,\n WatchableValue,\n TrackableValue,\n} from \"#src/trackable_value.js\";\nimport type { RefCounted } from \"#src/util/disposable.js\";\nimport { stableStringify, verifyString } from \"#src/util/json.js\";\nimport { getObjectId } from \"#src/util/object_id.js\";\nimport type { GL } from \"#src/webgl/context.js\";\nimport type {\n ShaderCompilationError,\n ShaderLinkError,\n ShaderModule,\n ShaderProgram,\n} from \"#src/webgl/shader.js\";\nimport { ShaderBuilder } from \"#src/webgl/shader.js\";\n\n/**\n * undefined means shader has not been compiled. null means shader was compiled successfully.\n */\nexport type WatchableShaderError = WatchableValue<\n ShaderCompilationError | ShaderLinkError | undefined | null\n>;\n\nexport function makeWatchableShaderError() {\n return new WatchableValue<\n ShaderCompilationError | ShaderLinkError | undefined | null\n >(undefined);\n}\n\nexport type TrackableFragmentMain = TrackableValue;\n\nexport function makeTrackableFragmentMain(value: string) {\n return new TrackableValue(value, verifyString);\n}\n\nexport interface ParameterizedShaderGetterResult<\n Parameters = any,\n ExtraParameters = any,\n> {\n shader: ShaderProgram | null;\n fallback: boolean;\n parameters: Parameters;\n extraParameters: ExtraParameters;\n}\n\nexport interface ParameterizedContextDependentShaderGetter<\n Context,\n Parameters,\n ExtraParameters = undefined,\n> {\n (\n context: Context,\n ): ParameterizedShaderGetterResult;\n}\n\nexport interface ParameterizedShaderOptions<\n Parameters = any,\n ExtraParameters = any,\n> {\n memoizeKey: any;\n parameters: WatchableValueInterface;\n fallbackParameters?: WatchableValueInterface | undefined;\n shaderError?: WatchableShaderError | undefined;\n encodeParameters?: (p: Parameters) => any;\n extraParameters?: WatchableValueInterface;\n encodeExtraParameters?: (p: ExtraParameters) => any;\n}\n\nexport function parameterizedContextDependentShaderGetter<\n Context,\n ContextKey,\n Parameters,\n ExtraParameters = undefined,\n>(\n refCounted: RefCounted,\n gl: GL,\n options: ParameterizedShaderOptions & {\n getContextKey: (context: Context) => ContextKey;\n defineShader: (\n builder: ShaderBuilder,\n context: Context,\n parameters: Parameters,\n extraParameters: ExtraParameters,\n ) => void;\n encodeContext?: (context: Context) => any;\n },\n): ParameterizedContextDependentShaderGetter<\n Context,\n Parameters,\n ExtraParameters\n> {\n const shaders = new Map<\n ContextKey,\n ParameterizedShaderGetterResult & {\n parametersGeneration: number;\n extraParametersGeneration: number;\n }\n >();\n const {\n parameters,\n fallbackParameters,\n shaderError,\n encodeParameters = (p: Parameters) => p,\n extraParameters = constantWatchableValue(\n undefined as any as ExtraParameters,\n ),\n encodeExtraParameters = (p: ExtraParameters) => p,\n getContextKey,\n defineShader,\n } = options;\n if (shaderError !== undefined) {\n shaderError.value = undefined;\n }\n const { encodeContext = getContextKey } = options;\n const stringMemoizeKey = stableStringify(options.memoizeKey);\n function getNewShader(\n context: Context,\n parameters: Parameters,\n extraParameters: ExtraParameters,\n ) {\n const key = JSON.stringify({\n id: stringMemoizeKey,\n context: encodeContext(context),\n parameters: encodeParameters(parameters),\n extraParameters: encodeExtraParameters(extraParameters),\n });\n return gl.memoize.get(key, () => {\n const builder = new ShaderBuilder(gl);\n defineShader(builder, context, parameters, extraParameters);\n return builder.build();\n });\n }\n function getter(context: Context) {\n const contextKey = getContextKey(context);\n let entry = shaders.get(contextKey);\n if (entry === undefined) {\n entry = {\n parametersGeneration: -1,\n extraParametersGeneration: -1,\n shader: null,\n fallback: false,\n parameters: parameters.value,\n extraParameters: extraParameters.value,\n };\n shaders.set(contextKey, entry);\n }\n const parametersGeneration = parameters.changed.count;\n const extraParametersGeneration = extraParameters.changed.count;\n if (\n parametersGeneration === entry.parametersGeneration &&\n extraParametersGeneration === entry.extraParametersGeneration\n ) {\n return entry;\n }\n const parametersValue = (entry.parameters = parameters.value);\n const extraParametersValue = (entry.extraParameters =\n extraParameters.value);\n const oldShader = entry.shader;\n entry.parametersGeneration = parametersGeneration;\n entry.extraParametersGeneration = extraParametersGeneration;\n let newShader: ShaderProgram | null = null;\n try {\n newShader = getNewShader(context, parametersValue, extraParametersValue);\n entry.fallback = false;\n if (fallbackParameters !== undefined) {\n fallbackParameters.value = parametersValue;\n }\n if (shaderError !== undefined) {\n shaderError.value = null;\n }\n } catch (e) {\n if (shaderError !== undefined) {\n shaderError.value = e;\n }\n if (fallbackParameters !== undefined) {\n try {\n const fallbackParametersValue = fallbackParameters.value;\n newShader = getNewShader(\n context,\n fallbackParametersValue,\n extraParametersValue,\n );\n entry.parameters = fallbackParametersValue;\n entry.fallback = true;\n } catch {\n // Ignore error creating fallback shader.\n }\n }\n }\n if (oldShader !== null) {\n oldShader.dispose();\n }\n entry.shader = newShader;\n return entry;\n }\n refCounted.registerDisposer(() => {\n for (const entry of shaders.values()) {\n const { shader } = entry;\n if (shader !== null) {\n shader.dispose();\n }\n }\n });\n return getter;\n}\n\nexport interface ParameterizedEmitterDependentShaderOptions<\n Parameters = any,\n ExtraParameters = any,\n> extends ParameterizedShaderOptions {\n defineShader: (\n builder: ShaderBuilder,\n parameters: Parameters,\n extraParameters: ExtraParameters,\n ) => void;\n}\n\nexport type ParameterizedEmitterDependentShaderGetter<\n Parameters = any,\n ExtraParameters = any,\n> = ParameterizedContextDependentShaderGetter<\n ShaderModule,\n Parameters,\n ExtraParameters\n>;\n\nexport function parameterizedEmitterDependentShaderGetter<\n Parameters,\n ExtraParameters = undefined,\n>(\n refCounted: RefCounted,\n gl: GL,\n options: ParameterizedEmitterDependentShaderOptions<\n Parameters,\n ExtraParameters\n >,\n): ParameterizedEmitterDependentShaderGetter {\n return parameterizedContextDependentShaderGetter(refCounted, gl, {\n ...options,\n getContextKey: (emitter: ShaderModule) => emitter,\n encodeContext: (emitter: ShaderModule) => getObjectId(emitter),\n defineShader: (\n builder,\n emitter: ShaderModule,\n parameters,\n extraParameters,\n ) => {\n builder.require(emitter);\n return options.defineShader(builder, parameters, extraParameters);\n },\n });\n}\n\nexport function shaderCodeWithLineDirective(\n code: string,\n sourceStringNumber = 1,\n line = 0,\n) {\n return `\\n#line ${line} ${sourceStringNumber}\\n` + code;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Disposable } from \"#src/util/disposable.js\";\nimport { RefCountedValue } from \"#src/util/disposable.js\";\nimport { stableStringify } from \"#src/util/json.js\";\nimport { getObjectId } from \"#src/util/object_id.js\";\nimport type { GL } from \"#src/webgl/context.js\";\nimport type { AttributeIndex } from \"#src/webgl/shader.js\";\n\nexport type BufferType = number;\nexport type WebGLDataType = number;\nexport type WebGLBufferUsage = number;\nexport class Buffer implements Disposable {\n buffer: WebGLBuffer | null;\n constructor(\n public gl: WebGL2RenderingContext,\n public bufferType: BufferType = WebGL2RenderingContext.ARRAY_BUFFER,\n ) {\n this.gl = gl;\n // This should never return null.\n this.buffer = gl.createBuffer();\n }\n\n bind() {\n this.gl.bindBuffer(this.bufferType, this.buffer);\n }\n\n bindToVertexAttrib(\n location: AttributeIndex,\n componentsPerVertexAttribute: number,\n attributeType: WebGLDataType = WebGL2RenderingContext.FLOAT,\n normalized = false,\n stride = 0,\n offset = 0,\n ) {\n this.bind();\n this.gl.enableVertexAttribArray(location);\n this.gl.vertexAttribPointer(\n location,\n componentsPerVertexAttribute,\n attributeType,\n normalized,\n stride,\n offset,\n );\n }\n\n bindToVertexAttribI(\n location: AttributeIndex,\n componentsPerVertexAttribute: number,\n attributeType: WebGLDataType = WebGL2RenderingContext.UNSIGNED_INT,\n stride = 0,\n offset = 0,\n ) {\n this.bind();\n this.gl.enableVertexAttribArray(location);\n this.gl.vertexAttribIPointer(\n location,\n componentsPerVertexAttribute,\n attributeType,\n stride,\n offset,\n );\n }\n\n setData(\n data: ArrayBufferView,\n usage: WebGLBufferUsage = WebGL2RenderingContext.STATIC_DRAW,\n ) {\n const gl = this.gl;\n this.bind();\n gl.bufferData(this.bufferType, data, usage);\n }\n\n dispose() {\n this.gl.deleteBuffer(this.buffer);\n this.buffer = undefined;\n this.gl = undefined;\n }\n\n static fromData(\n gl: WebGL2RenderingContext,\n data: ArrayBufferView,\n bufferType?: BufferType,\n usage?: WebGLBufferUsage,\n ) {\n const buffer = new Buffer(gl, bufferType);\n buffer.setData(data, usage);\n return buffer;\n }\n}\n\nexport function getMemoizedBuffer(\n gl: GL,\n bufferType: number,\n getter: (...args: any[]) => ArrayBufferView,\n ...args: any[]\n) {\n return gl.memoize.get(\n stableStringify({\n id: \"getMemoizedBuffer\",\n getter: getObjectId(getter),\n args,\n }),\n () => {\n const result = new RefCountedValue(\n Buffer.fromData(\n gl,\n getter(...args),\n bufferType,\n WebGL2RenderingContext.STATIC_DRAW,\n ),\n );\n result.registerDisposer(result.value);\n return result;\n },\n );\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { tile2dArray } from \"#src/util/array.js\";\nimport { getMemoizedBuffer } from \"#src/webgl/buffer.js\";\nimport type { GL } from \"#src/webgl/context.js\";\n\nexport function getSquareCornersArray(\n startX = -1,\n startY = -1,\n endX = 1,\n endY = 1,\n minorTiles = 1,\n majorTiles = 1,\n) {\n return tile2dArray(\n new Float32Array([\n startX,\n startY, //\n startX,\n endY, //\n endX,\n endY, //\n endX,\n startY, //\n ]),\n /*majorDimension=*/ 2,\n minorTiles,\n majorTiles,\n );\n}\n\nexport function getCubeCornersArray(\n startX = -1,\n startY = -1,\n startZ = -1,\n endX = 1,\n endY = 1,\n endZ = 1,\n minorTiles = 1,\n majorTiles = 1,\n) {\n return tile2dArray(\n new Float32Array([\n startX,\n startY,\n startZ, //\n endX,\n startY,\n startZ, //\n startX,\n endY,\n startZ, //\n endX,\n endY,\n startZ, //\n startX,\n startY,\n endZ, //\n endX,\n startY,\n endZ, //\n startX,\n endY,\n endZ, //\n endX,\n endY,\n endZ, //\n ]),\n /*majorDimension=*/ 3,\n minorTiles,\n majorTiles,\n );\n}\n\nexport function getSquareCornersBuffer(\n gl: GL,\n startX = -1,\n startY = -1,\n endX = 1,\n endY = 1,\n minorTiles = 1,\n majorTiles = 1,\n) {\n return getMemoizedBuffer(\n gl,\n WebGL2RenderingContext.ARRAY_BUFFER,\n getSquareCornersArray,\n startX,\n startY,\n endX,\n endY,\n minorTiles,\n majorTiles,\n ).value;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { GL } from \"#src/webgl/context.js\";\n\n/**\n * Sets parameters to make a texture suitable for use as a raw array: NEAREST\n * filtering, clamping.\n */\nexport function setRawTextureParameters(gl: WebGL2RenderingContext) {\n gl.texParameteri(\n WebGL2RenderingContext.TEXTURE_2D,\n WebGL2RenderingContext.TEXTURE_MIN_FILTER,\n WebGL2RenderingContext.NEAREST,\n );\n gl.texParameteri(\n WebGL2RenderingContext.TEXTURE_2D,\n WebGL2RenderingContext.TEXTURE_MAG_FILTER,\n WebGL2RenderingContext.NEAREST,\n );\n // Prevents s-coordinate wrapping (repeating). Repeating not\n // permitted for non-power-of-2 textures.\n gl.texParameteri(\n WebGL2RenderingContext.TEXTURE_2D,\n WebGL2RenderingContext.TEXTURE_WRAP_S,\n WebGL2RenderingContext.CLAMP_TO_EDGE,\n );\n // Prevents t-coordinate wrapping (repeating). Repeating not\n // permitted for non-power-of-2 textures.\n gl.texParameteri(\n WebGL2RenderingContext.TEXTURE_2D,\n WebGL2RenderingContext.TEXTURE_WRAP_T,\n WebGL2RenderingContext.CLAMP_TO_EDGE,\n );\n}\n\nexport function setRawTexture3DParameters(gl: WebGL2RenderingContext) {\n gl.texParameteri(\n WebGL2RenderingContext.TEXTURE_3D,\n WebGL2RenderingContext.TEXTURE_MIN_FILTER,\n WebGL2RenderingContext.NEAREST,\n );\n gl.texParameteri(\n WebGL2RenderingContext.TEXTURE_3D,\n WebGL2RenderingContext.TEXTURE_MAG_FILTER,\n WebGL2RenderingContext.NEAREST,\n );\n // Prevents s-coordinate wrapping (repeating). Repeating not\n // permitted for non-power-of-2 textures.\n gl.texParameteri(\n WebGL2RenderingContext.TEXTURE_3D,\n WebGL2RenderingContext.TEXTURE_WRAP_S,\n WebGL2RenderingContext.CLAMP_TO_EDGE,\n );\n // Prevents t-coordinate wrapping (repeating). Repeating not\n // permitted for non-power-of-2 textures.\n gl.texParameteri(\n WebGL2RenderingContext.TEXTURE_3D,\n WebGL2RenderingContext.TEXTURE_WRAP_T,\n WebGL2RenderingContext.CLAMP_TO_EDGE,\n );\n gl.texParameteri(\n WebGL2RenderingContext.TEXTURE_3D,\n WebGL2RenderingContext.TEXTURE_WRAP_R,\n WebGL2RenderingContext.CLAMP_TO_EDGE,\n );\n}\n\nexport function resizeTexture(\n gl: GL,\n texture: WebGLTexture | null,\n width: number,\n height: number,\n internalFormat: number = WebGL2RenderingContext.RGBA8,\n format: number = WebGL2RenderingContext.RGBA,\n dataType: number = WebGL2RenderingContext.UNSIGNED_BYTE,\n) {\n gl.activeTexture(WebGL2RenderingContext.TEXTURE0 + gl.tempTextureUnit);\n gl.bindTexture(WebGL2RenderingContext.TEXTURE_2D, texture);\n setRawTextureParameters(gl);\n gl.texImage2D(\n WebGL2RenderingContext.TEXTURE_2D,\n 0,\n /*internalformat=*/ internalFormat,\n /*width=*/ width,\n /*height=*/ height,\n /*border=*/ 0,\n /*format=*/ format,\n dataType,\n null,\n );\n gl.bindTexture(WebGL2RenderingContext.TEXTURE_2D, null);\n}\n\nexport function setTextureFromCanvas(\n gl: GL,\n texture: WebGLTexture | null,\n canvas: HTMLCanvasElement,\n) {\n gl.activeTexture(WebGL2RenderingContext.TEXTURE0 + gl.tempTextureUnit);\n gl.bindTexture(WebGL2RenderingContext.TEXTURE_2D, texture);\n gl.texParameteri(\n WebGL2RenderingContext.TEXTURE_2D,\n WebGL2RenderingContext.TEXTURE_MIN_FILTER,\n WebGL2RenderingContext.LINEAR,\n );\n gl.texParameteri(\n WebGL2RenderingContext.TEXTURE_2D,\n WebGL2RenderingContext.TEXTURE_MAG_FILTER,\n WebGL2RenderingContext.LINEAR,\n );\n // Prevents s-coordinate wrapping (repeating). Repeating not permitted for non-power-of-2\n // textures.\n gl.texParameteri(\n WebGL2RenderingContext.TEXTURE_2D,\n WebGL2RenderingContext.TEXTURE_WRAP_S,\n WebGL2RenderingContext.CLAMP_TO_EDGE,\n );\n // Prevents t-coordinate wrapping (repeating). Repeating not permitted for non-power-of-2\n // textures.\n gl.texParameteri(\n WebGL2RenderingContext.TEXTURE_2D,\n WebGL2RenderingContext.TEXTURE_WRAP_T,\n WebGL2RenderingContext.CLAMP_TO_EDGE,\n );\n gl.pixelStorei(WebGL2RenderingContext.UNPACK_FLIP_Y_WEBGL, 1);\n gl.pixelStorei(WebGL2RenderingContext.UNPACK_ALIGNMENT, 4);\n gl.texImage2D(\n WebGL2RenderingContext.TEXTURE_2D,\n /*level=*/ 0,\n /*internalformat=*/ WebGL2RenderingContext.RGBA8,\n /*format=*/ WebGL2RenderingContext.RGBA,\n WebGL2RenderingContext.UNSIGNED_BYTE,\n canvas,\n );\n gl.pixelStorei(WebGL2RenderingContext.UNPACK_FLIP_Y_WEBGL, 0);\n gl.bindTexture(WebGL2RenderingContext.TEXTURE_2D, null);\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getObjectId } from \"#src/util/object_id.js\";\nimport type { GL } from \"#src/webgl/context.js\";\nimport type { ShaderModule, ShaderProgram } from \"#src/webgl/shader.js\";\nimport { ShaderBuilder } from \"#src/webgl/shader.js\";\n\nexport function defineCopyFragmentShader(builder: ShaderBuilder) {\n builder.addOutputBuffer(\"vec4\", \"v4f_fragColor\", null);\n builder.setFragmentMain(\"v4f_fragColor = getValue0();\");\n}\n\nexport function elementWiseTextureShader(\n gl: GL,\n shaderModule: ShaderModule = defineCopyFragmentShader,\n numTextures = 1,\n): ShaderProgram {\n return gl.memoize.get(\n `elementWiseTextureShader:${numTextures}:${getObjectId(shaderModule)}`,\n () => {\n const builder = new ShaderBuilder(gl);\n builder.addVarying(\"vec2\", \"vTexCoord\");\n builder.addUniform(\"sampler2D\", \"uSampler\", numTextures);\n builder.addInitializer((shader) => {\n const textureIndices: number[] = [];\n for (let i = 0; i < numTextures; ++i) {\n textureIndices[i] = i;\n }\n gl.uniform1iv(shader.uniform(\"uSampler\"), textureIndices);\n });\n for (let i = 0; i < numTextures; ++i) {\n builder.addFragmentCode(`\nvec4 getValue${i}() {\n return texture(uSampler[${i}], vTexCoord);\n}\n`);\n }\n builder.addUniform(\"mat4\", \"uProjectionMatrix\");\n builder.require(shaderModule);\n builder.addAttribute(\"vec4\", \"aVertexPosition\");\n builder.addAttribute(\"vec2\", \"aTexCoord\");\n builder.setVertexMain(\n \"vTexCoord = aTexCoord; gl_Position = uProjectionMatrix * aVertexPosition;\",\n );\n return builder.build();\n },\n );\n}\n\nexport function trivialTextureShader(gl: GL): ShaderProgram {\n return elementWiseTextureShader(gl, defineCopyFragmentShader, 1);\n}\n\nexport function trivialColorShader(gl: GL): ShaderProgram {\n return gl.memoize.get(\"trivialColorShader\", () => {\n const builder = new ShaderBuilder(gl);\n builder.addVarying(\"vec4\", \"vColor\");\n builder.addOutputBuffer(\"vec4\", \"v4f_fragColor\", null);\n builder.setFragmentMain(\"v4f_fragColor = vColor;\");\n builder.addAttribute(\"vec4\", \"aVertexPosition\");\n builder.addAttribute(\"vec4\", \"aColor\");\n builder.addUniform(\"mat4\", \"uProjectionMatrix\");\n builder.setVertexMain(\n \"vColor = aColor; gl_Position = uProjectionMatrix * aVertexPosition;\",\n );\n return builder.build();\n });\n}\n\nexport function trivialUniformColorShader(gl: GL): ShaderProgram {\n return gl.memoize.get(\"trivialUniformColorShader\", () => {\n const builder = new ShaderBuilder(gl);\n builder.addUniform(\"mat4\", \"uProjectionMatrix\");\n builder.addAttribute(\"vec4\", \"aVertexPosition\");\n builder.addUniform(\"vec4\", \"uColor\");\n builder.addOutputBuffer(\"vec4\", \"v4f_fragColor\", null);\n builder.setFragmentMain(\"v4f_fragColor = uColor;\");\n builder.setVertexMain(\"gl_Position = uProjectionMatrix * aVertexPosition;\");\n return builder.build();\n });\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport { identityMat4 } from \"#src/util/geom.js\";\nimport { getObjectId } from \"#src/util/object_id.js\";\nimport type { GL } from \"#src/webgl/context.js\";\nimport type { ShaderModule, ShaderProgram } from \"#src/webgl/shader.js\";\nimport { getSquareCornersBuffer } from \"#src/webgl/square_corners_buffer.js\";\nimport { resizeTexture } from \"#src/webgl/texture.js\";\nimport {\n defineCopyFragmentShader,\n elementWiseTextureShader,\n} from \"#src/webgl/trivial_shaders.js\";\n\nexport abstract class SizeManaged extends RefCounted {\n width = Number.NaN;\n height = Number.NaN;\n\n hasSize(width: number, height: number) {\n return this.width === width && this.height === height;\n }\n\n resize(width: number, height: number) {\n if (this.hasSize(width, height)) {\n return;\n }\n this.width = width;\n this.height = height;\n\n this.performResize();\n }\n protected abstract performResize(): void;\n}\n\nexport class Renderbuffer extends SizeManaged {\n renderbuffer: WebGLRenderbuffer | null = null;\n\n constructor(\n public gl: GL,\n public internalformat: number,\n ) {\n super();\n this.renderbuffer = gl.createRenderbuffer();\n }\n\n protected performResize() {\n const { gl } = this;\n gl.bindRenderbuffer(gl.RENDERBUFFER, this.renderbuffer);\n gl.renderbufferStorage(\n gl.RENDERBUFFER,\n this.internalformat,\n this.width,\n this.height,\n );\n gl.bindRenderbuffer(gl.RENDERBUFFER, null);\n }\n\n disposed() {\n this.gl.deleteRenderbuffer(this.renderbuffer);\n }\n\n attachToFramebuffer(attachment: number) {\n const { gl } = this;\n gl.framebufferRenderbuffer(\n gl.FRAMEBUFFER,\n attachment,\n gl.RENDERBUFFER,\n this.renderbuffer,\n );\n }\n}\n\nexport class DepthRenderbuffer extends Renderbuffer {\n constructor(\n public gl: GL,\n public includeStencilBuffer = false,\n ) {\n super(gl, includeStencilBuffer ? gl.DEPTH_STENCIL : gl.DEPTH_COMPONENT16);\n }\n attachToFramebuffer() {\n const { gl } = this;\n super.attachToFramebuffer(\n this.includeStencilBuffer\n ? gl.DEPTH_STENCIL_ATTACHMENT\n : gl.DEPTH_ATTACHMENT,\n );\n }\n}\n\nexport class DepthStencilRenderbuffer extends DepthRenderbuffer {\n constructor(gl: GL) {\n super(gl, /*includeStencilBuffer=*/ true);\n }\n}\n\nexport const StencilRenderbuffer = DepthStencilRenderbuffer;\n\nexport class Framebuffer extends RefCounted {\n framebuffer = this.gl.createFramebuffer();\n constructor(public gl: GL) {\n super();\n }\n disposed() {\n const { gl } = this;\n gl.deleteFramebuffer(this.framebuffer);\n }\n bind() {\n const { gl } = this;\n gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer);\n }\n unbind() {\n const { gl } = this;\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n }\n}\n\nexport class TextureBuffer extends SizeManaged {\n texture: WebGLTexture | null;\n\n constructor(\n public gl: GL,\n public internalFormat: number,\n public format: number,\n public dataType: number,\n ) {\n super();\n this.texture = gl.createTexture();\n }\n\n protected performResize() {\n resizeTexture(\n this.gl,\n this.texture,\n this.width,\n this.height,\n this.internalFormat,\n this.format,\n this.dataType,\n );\n }\n\n disposed() {\n this.gl.deleteTexture(this.texture);\n }\n\n attachToFramebuffer(attachment: number) {\n const { gl } = this;\n gl.framebufferTexture2D(\n gl.FRAMEBUFFER,\n attachment,\n gl.TEXTURE_2D,\n this.texture,\n /*level=*/ 0,\n );\n }\n}\n\nexport class DepthTextureBuffer extends TextureBuffer {\n // biome-ignore lint/complexity/noUselessConstructor: adds defaults\n constructor(\n gl: GL,\n internalFormat: number = WebGL2RenderingContext.DEPTH_COMPONENT16,\n format: number = WebGL2RenderingContext.DEPTH_COMPONENT,\n dataType: number = WebGL2RenderingContext.UNSIGNED_SHORT,\n ) {\n super(gl, internalFormat, format, dataType);\n }\n\n attachToFramebuffer() {\n super.attachToFramebuffer(\n this.format === WebGL2RenderingContext.DEPTH_COMPONENT\n ? WebGL2RenderingContext.DEPTH_ATTACHMENT\n : WebGL2RenderingContext.DEPTH_STENCIL_ATTACHMENT,\n );\n }\n}\n\nexport function makeTextureBuffers(\n gl: GL,\n count: number,\n internalFormat: number = WebGL2RenderingContext.RGBA8,\n format: number = WebGL2RenderingContext.RGBA,\n dataType: number = WebGL2RenderingContext.UNSIGNED_BYTE,\n) {\n const result = new Array();\n for (let i = 0; i < count; ++i) {\n result[i] = new TextureBuffer(gl, internalFormat, format, dataType);\n }\n return result;\n}\n\nexport class FramebufferConfiguration<\n ColorBuffer extends TextureBuffer | Renderbuffer =\n | TextureBuffer\n | Renderbuffer,\n DepthBuffer extends DepthTextureBuffer | DepthRenderbuffer =\n | DepthTextureBuffer\n | DepthRenderbuffer,\n> extends RefCounted {\n width = Number.NaN;\n height = Number.NaN;\n\n colorBuffers: ColorBuffer[];\n framebuffer: Framebuffer;\n depthBuffer: DepthBuffer | undefined;\n fullAttachmentList = new Array();\n private attachmentVerified = false;\n singleAttachmentList = [this.gl.COLOR_ATTACHMENT0];\n\n constructor(\n public gl: GL,\n configuration: {\n framebuffer?: Framebuffer;\n colorBuffers: ColorBuffer[];\n depthBuffer?: DepthBuffer;\n },\n ) {\n super();\n const {\n framebuffer = new Framebuffer(gl),\n colorBuffers,\n depthBuffer,\n } = configuration;\n this.framebuffer = this.registerDisposer(framebuffer);\n this.colorBuffers = colorBuffers;\n this.depthBuffer = depthBuffer;\n if (depthBuffer !== undefined) {\n this.registerDisposer(depthBuffer);\n }\n const { fullAttachmentList } = this;\n colorBuffers.forEach((buffer, i) => {\n this.registerDisposer(buffer);\n fullAttachmentList[i] = gl.COLOR_ATTACHMENT0 + i;\n });\n }\n\n hasSize(width: number, height: number) {\n return this.width === width && this.height === height;\n }\n\n bind(width: number, height: number) {\n this.width = width;\n this.height = height;\n this.framebuffer.bind();\n const { gl, depthBuffer } = this;\n if (depthBuffer !== undefined) {\n depthBuffer.resize(width, height);\n depthBuffer.attachToFramebuffer();\n } else {\n gl.framebufferRenderbuffer(\n WebGL2RenderingContext.FRAMEBUFFER,\n WebGL2RenderingContext.DEPTH_STENCIL_ATTACHMENT,\n WebGL2RenderingContext.RENDERBUFFER,\n null,\n );\n }\n this.colorBuffers.forEach((buffer, i) => {\n buffer.resize(width, height);\n buffer.attachToFramebuffer(gl.COLOR_ATTACHMENT0 + i);\n });\n gl.drawBuffers(this.fullAttachmentList);\n this.verifyAttachment();\n gl.viewport(0, 0, width, height);\n }\n\n bindSingle(textureIndex: number) {\n const { gl } = this;\n this.framebuffer.bind();\n\n // If this texture is still be bound to color attachment textureIndex, the attachment will fail\n // (at least on some browsers). Therefore, if textureIndex is not 0, we clear the attachment.\n // In the case that textureIndex is 0, the attachment will be overridden anyway.\n if (textureIndex !== 0) {\n gl.framebufferTexture2D(\n gl.FRAMEBUFFER,\n gl.COLOR_ATTACHMENT0 + textureIndex,\n gl.TEXTURE_2D,\n null,\n /*level=*/ 0,\n );\n }\n\n gl.bindTexture(gl.TEXTURE_2D, null);\n this.colorBuffers[textureIndex].attachToFramebuffer(gl.COLOR_ATTACHMENT0);\n gl.drawBuffers(this.singleAttachmentList);\n }\n\n unbind() {\n this.framebuffer.unbind();\n }\n\n readPixelFloat32IntoBuffer(\n textureIndex: number,\n glWindowX: number,\n glWindowY: number,\n offset: number,\n width = 1,\n height = 1,\n ) {\n const { gl } = this;\n try {\n this.bindSingle(textureIndex);\n // Reading just the red channel using a format of RED fails with certain WebGL\n // implementations. Using RGBA seems to have better compatibility.\n gl.readPixels(\n glWindowX,\n glWindowY,\n width,\n height,\n WebGL2RenderingContext.RGBA,\n WebGL2RenderingContext.FLOAT,\n offset,\n );\n } finally {\n this.framebuffer.unbind();\n }\n }\n\n verifyAttachment() {\n if (this.attachmentVerified) {\n return;\n }\n const { gl } = this;\n const framebufferStatus = gl.checkFramebufferStatus(gl.FRAMEBUFFER);\n if (framebufferStatus !== gl.FRAMEBUFFER_COMPLETE) {\n throw new Error(\n `Framebuffer configuration not supported: ${framebufferStatus}`,\n );\n }\n this.attachmentVerified = true;\n }\n}\n\nexport class OffscreenCopyHelper extends RefCounted {\n constructor(\n public gl: GL,\n public shader: ShaderProgram,\n ) {\n super();\n this.registerDisposer(shader);\n }\n private copyVertexPositionsBuffer = getSquareCornersBuffer(this.gl);\n private copyTexCoordsBuffer = getSquareCornersBuffer(this.gl, 0, 0, 1, 1);\n\n draw(...textures: (WebGLTexture | null)[]) {\n const { gl, shader } = this;\n shader.bind();\n\n const numTextures = textures.length;\n for (let i = 0; i < numTextures; ++i) {\n gl.activeTexture(gl.TEXTURE0 + i);\n gl.bindTexture(gl.TEXTURE_2D, textures[i]);\n }\n\n gl.uniformMatrix4fv(\n shader.uniform(\"uProjectionMatrix\"),\n false,\n identityMat4,\n );\n\n const aVertexPosition = shader.attribute(\"aVertexPosition\");\n this.copyVertexPositionsBuffer.bindToVertexAttrib(\n aVertexPosition,\n /*components=*/ 2,\n );\n\n const aTexCoord = shader.attribute(\"aTexCoord\");\n this.copyTexCoordsBuffer.bindToVertexAttrib(aTexCoord, /*components=*/ 2);\n\n gl.drawArrays(gl.TRIANGLE_FAN, 0, 4);\n\n gl.disableVertexAttribArray(aVertexPosition);\n gl.disableVertexAttribArray(aTexCoord);\n\n for (let i = 0; i < numTextures; ++i) {\n gl.activeTexture(gl.TEXTURE0 + i);\n gl.bindTexture(gl.TEXTURE_2D, null);\n }\n }\n\n static get(\n gl: GL,\n shaderModule: ShaderModule = defineCopyFragmentShader,\n numTextures = 1,\n ) {\n return gl.memoize.get(\n `OffscreenCopyHelper:${numTextures}:${getObjectId(shaderModule)}`,\n () =>\n new OffscreenCopyHelper(\n gl,\n elementWiseTextureShader(gl, shaderModule, numTextures),\n ),\n );\n }\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n DATA_TYPE_BYTES,\n DATA_TYPE_SIGNED,\n DataType,\n} from \"#src/util/data_type.js\";\nimport type {\n AttributeIndex,\n ShaderBuilder,\n ShaderCodePart,\n} from \"#src/webgl/shader.js\";\n\nexport const glsl_mixLinear = `\nfloat mixLinear(float x, float y, float a) { return mix(x, y, a); }\n`;\n\n// Hue, saturation, and value are in [0, 1] range.\nexport const glsl_hsvToRgb = `\nvec3 hueToRgb(float hue) {\n float hue6 = hue * 6.0;\n float r = abs(hue6 - 3.0) - 1.0;\n float g = 2.0 - abs(hue6 - 2.0);\n float b = 2.0 - abs(hue6 - 4.0);\n return clamp(vec3(r, g, b), 0.0, 1.0);\n}\nvec3 hsvToRgb(vec3 c) {\n vec3 hueRgb = hueToRgb(c.x);\n return c.z * ((hueRgb - 1.0) * c.y + 1.0);\n}\n`;\n\nexport const glsl_uint64 = `\nstruct uint64_t {\n highp uvec2 value;\n};\nstruct uint64x2_t {\n highp uvec4 value;\n};\nuint64_t mixLinear(uint64_t x, uint64_t y, float a) {\n return x;\n}\nuint64_t toUint64(uint64_t x) { return x; }\n`;\n\nexport const glsl_unpackUint64leFromUint32 = [\n glsl_uint64,\n `\nuint64_t unpackUint64leFromUint32(highp uvec2 x) {\n uint64_t result;\n result.value = x;\n return result;\n}\nuint64x2_t unpackUint64leFromUint32(highp uvec4 x) {\n uint64x2_t result;\n result.value = x;\n return result;\n}\n`,\n];\n\nexport const glsl_equalUint64 = [\n glsl_uint64,\n `\nbool equals(uint64_t a, uint64_t b) {\n return a.value == b.value;\n}\n`,\n];\n\nexport const glsl_compareLessThanUint64 = [\n glsl_uint64,\n `\nbool compareLessThan(uint64_t a, uint64_t b) {\n return (a.value[1] < b.value[1])||\n (a.value[1] == b.value[1] && a.value[0] < b.value[0]);\n}\n`,\n];\n\nexport const glsl_subtractUint64 = [\n glsl_uint64,\n `\nuint64_t subtract(uint64_t a, uint64_t b) {\n if (a.value[0] < b.value[0]) {\n --a.value[1];\n }\n a.value -= b.value;\n return a;\n}\n`,\n];\n\nexport const glsl_addUint64 = [\n glsl_uint64,\n `\nuint64_t add(uint64_t a, uint64_t b) {\n a.value[0] += b.value[0];\n if (a.value[0] < b.value[0]) {\n ++a.value[1];\n }\n a.value[1] += b.value[1];\n return a;\n}\n`,\n];\n\nexport const glsl_addSaturateUint64 = [\n glsl_addUint64,\n glsl_compareLessThanUint64,\n `\nuint64_t addSaturate(uint64_t a, uint64_t b) {\n a = add(a, b);\n if (compareLessThan(a, b)) {\n a.value = uvec2(0xffffffffu, 0xffffffffu);\n }\n return a;\n}\n`,\n];\n\nexport const glsl_subtractSaturateUint64 = [\n glsl_subtractUint64,\n glsl_compareLessThanUint64,\n `\nuint64_t subtractSaturate(uint64_t a, uint64_t b) {\n b = subtract(a, b);\n if (compareLessThan(a, b)) {\n b.value = uvec2(0u, 0u);\n }\n return b;\n}\n`,\n];\n\nexport const glsl_shiftRightUint64 = [\n glsl_uint64,\n `\nuint64_t shiftRight(uint64_t a, int shift) {\n if (shift >= 32) {\n return uint64_t(uvec2(a.value[1] >> (shift - 32), 0u));\n } else if (shift == 0) {\n return a;\n } else {\n return uint64_t(uvec2((a.value[0] >> shift) | (a.value[1] << (32 - shift)), a.value[1] >> shift));\n }\n}\n`,\n];\n\nexport const glsl_shiftLeftUint64 = [\n glsl_uint64,\n `\nuint64_t shiftLeft(uint64_t a, int shift) {\n if (shift >= 32) {\n return uint64_t(uvec2(0u, a.value[0] << (shift - 32)));\n } else if (shift == 0) {\n return a;\n } else {\n return uint64_t(uvec2(a.value[0] << shift, (a.value[1] << shift) | (a.value[0] >> (32 - shift))));\n }\n}\n`,\n];\n\nexport const glsl_uint8 = [\n glsl_uint64,\n `\nstruct uint8_t {\n highp uint value;\n};\nstruct uint8x2_t {\n highp uvec2 value;\n};\nstruct uint8x3_t {\n highp uvec3 value;\n};\nstruct uint8x4_t {\n highp uvec4 value;\n};\nuint8_t mixLinear(uint8_t x, uint8_t y, highp float a) {\n return uint8_t(uint(round(mix(float(x.value), float(y.value), a))));\n}\nhighp uint toRaw(uint8_t x) { return x.value; }\nhighp float toNormalized(uint8_t x) { return float(x.value) / 255.0; }\nhighp uvec2 toRaw(uint8x2_t x) { return x.value; }\nhighp vec2 toNormalized(uint8x2_t x) { return vec2(x.value) / 255.0; }\nhighp uvec3 toRaw(uint8x3_t x) { return x.value; }\nvec3 toNormalized(uint8x3_t x) { return vec3(x.value) / 255.0; }\nhighp uvec4 toRaw(uint8x4_t x) { return x.value; }\nvec4 toNormalized(uint8x4_t x) { return vec4(x.value) / 255.0; }\nuint64_t toUint64(uint8_t x) {\n uint64_t result;\n result.value[0] = x.value;\n result.value[1] = 0u;\n return result;\n}\nuint8_t uint8FromFloat(highp float x) {\n return uint8_t(uint(clamp(x, 0.0, 255.0)));\n}\n`,\n];\n\nexport const glsl_int8 = [\n glsl_uint64,\n `\nstruct int8_t {\n highp int value;\n};\nstruct int8x2_t {\n highp ivec2 value;\n};\nstruct int8x3_t {\n highp ivec3 value;\n};\nstruct int8x4_t {\n highp ivec4 value;\n};\nint8_t mixLinear(int8_t x, int8_t y, highp float a) {\n return int8_t(int(round(mix(float(x.value), float(y.value), a))));\n}\nhighp int toRaw(int8_t x) { return x.value; }\nhighp ivec2 toRaw(int8x2_t x) { return x.value; }\nhighp ivec3 toRaw(int8x3_t x) { return x.value; }\nhighp ivec4 toRaw(int8x4_t x) { return x.value; }\nuint64_t toUint64(int8_t x) {\n uint64_t result;\n result.value[0] = uint(x.value);\n result.value[1] = uint(x.value >> 31);\n return result;\n}\nint8_t int8FromFloat(highp float x) {\n return int8_t(int(clamp(x, -128.0, 127.0)));\n}\n`,\n];\n\nexport const glsl_float = `\nhighp float toRaw(highp float x) { return x; }\nhighp float toNormalized(highp float x) { return x; }\nvec2 toRaw(vec2 x) { return x; }\nvec2 toNormalized(vec2 x) { return x; }\nvec3 toRaw(vec3 x) { return x; }\nvec3 toNormalized(vec3 x) { return x; }\nvec4 toRaw(vec4 x) { return x; }\nvec4 toNormalized(vec4 x) { return x; }\n`;\n\nexport const glsl_uint16 = [\n glsl_uint64,\n `\nstruct uint16_t {\n highp uint value;\n};\nstruct uint16x2_t {\n highp uvec2 value;\n};\nuint16_t mixLinear(uint16_t x, uint16_t y, highp float a) {\n return uint16_t(uint(round(mix(float(x.value), float(y.value), a))));\n}\nhighp uint toRaw(uint16_t x) { return x.value; }\nhighp float toNormalized(uint16_t x) { return float(toRaw(x)) / 65535.0; }\nhighp uvec2 toRaw(uint16x2_t x) { return x.value; }\nhighp vec2 toNormalized(uint16x2_t x) { return vec2(toRaw(x)) / 65535.0; }\nuint64_t toUint64(uint16_t x) {\n uint64_t result;\n result.value[0] = x.value;\n result.value[1] = 0u;\n return result;\n}\nuint16_t uint16FromFloat(highp float x) {\n return uint16_t(uint(clamp(x, 0.0, 65535.0)));\n}\n`,\n];\n\nexport const glsl_int16 = [\n glsl_uint64,\n `\nstruct int16_t {\n highp int value;\n};\nstruct int16x2_t {\n highp ivec2 value;\n};\nint16_t mixLinear(int16_t x, int16_t y, highp float a) {\n return int16_t(int(round(mix(float(x.value), float(y.value), a))));\n}\nhighp int toRaw(int16_t x) { return x.value; }\nhighp ivec2 toRaw(int16x2_t x) { return x.value; }\nuint64_t toUint64(int16_t x) {\n uint64_t result;\n result.value[0] = uint(x.value);\n result.value[1] = uint(x.value >> 31);\n return result;\n}\nint16_t int16FromFloat(highp float x) {\n return int16_t(int(clamp(x, -32768.0, 32767.0)));\n}\n`,\n];\n\nexport const glsl_uint32 = [\n glsl_uint64,\n `\nstruct uint32_t {\n highp uint value;\n};\nuint32_t mixLinear(uint32_t x, uint32_t y, highp float a) {\n return uint32_t(uint(round(mix(float(x.value), float(y.value), a))));\n}\nhighp float toNormalized(uint32_t x) { return float(x.value) / 4294967295.0; }\nhighp uint toRaw(uint32_t x) { return x.value; }\nuint64_t toUint64(uint32_t x) {\n uint64_t result;\n result.value[0] = x.value;\n result.value[1] = 0u;\n return result;\n}\nuint32_t uint32FromFloat(highp float x) {\n return uint32_t(uint(clamp(x, 0.0, 4294967295.0)));\n}\n`,\n];\n\nexport const glsl_int32 = [\n glsl_uint64,\n `\nstruct int32_t {\n highp int value;\n};\nint32_t mixLinear(int32_t x, int32_t y, highp float a) {\n return int32_t(int(round(mix(float(x.value), float(y.value), a))));\n}\nhighp int toRaw(int32_t x) { return x.value; }\nuint64_t toUint64(int32_t x) {\n uint64_t result;\n result.value[0] = uint(x.value);\n result.value[1] = uint(x.value >> 31);\n return result;\n}\nint32_t int32FromFloat(highp float x) {\n return int32_t(int(clamp(x, 2147483648.0, 2147483647.0)));\n}\n`,\n];\n\nexport const glsl_getFortranOrderIndex = `\nhighp int getFortranOrderIndex(ivec3 subscripts, ivec3 size) {\n return subscripts.x + size.x * (subscripts.y + size.y * subscripts.z);\n}\n`;\n\nexport const glsl_log2Exact = `\nhighp uint log2Exact(highp uint i) {\n highp uint r;\n r = uint((i & 0xAAAAAAAAu) != 0u);\n r |= uint((i & 0xFFFF0000u) != 0u) << 4;\n r |= uint((i & 0xFF00FF00u) != 0u) << 3;\n r |= uint((i & 0xF0F0F0F0u) != 0u) << 2;\n r |= uint((i & 0xCCCCCCCCu) != 0u) << 1;\n return r;\n}\n`;\n\n// Clip line endpoints to the OpenGL viewing volume depth range.\n// https://www.khronos.org/opengl/wiki/Vertex_Post-Processing#Clipping\n//\n// This is similar to the clipping that the OpenGL implementation itself would do for lines, except\n// that we only clip based on `z`.\nexport const glsl_clipLineToDepthRange = `\nbool clipLineToDepthRange(inout highp vec4 a, inout highp vec4 b) {\n highp float tmin = 0.0, tmax = 1.0;\n highp float k1 = b.w - a.w + a.z - b.z;\n highp float k2 = a.w - b.w + a.z - b.z;\n highp float q1 = (a.z - a.w) / k1;\n highp float q2 = (a.z + a.w) / k2;\n if (k1 > 0.0) tmin = max(tmin, q1);\n else if (k1 < 0.0) tmax = min(tmax, q1);\n if (k2 > 0.0) tmax = min(tmax, q2);\n else if (k2 < 0.0) tmin = max(tmin, q2);\n if (tmin <= tmax) {\n highp vec4 tempA = a;\n highp vec4 tempB = b;\n a = mix(tempA, tempB, tmin);\n b = mix(tempA, tempB, tmax);\n return true;\n }\n return false;\n}\n`;\n\n// https://stackoverflow.com/questions/4200224/random-noise-functions-for-glsl\nexport const glsl_simpleFloatHash = `\nhighp float simpleFloatHash(highp vec2 co) {\n return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);\n}\n`;\n\nexport const glsl_shiftLeftSaturateUint32 = `\nhighp uint shiftLeftSaturate(highp uint x, int shiftAmount) {\n highp uint result = x << shiftAmount;\n if ((result >> shiftAmount) != x) return 0xffffffffu;\n return result;\n}\n`;\n\nexport const glsl_addSaturateUint32 = `\nhighp uint addSaturate(highp uint x, highp uint y) {\n highp uint result = x + y;\n if (result < x) return 0xffffffffu;\n return result;\n}\n`;\n\nexport const glsl_subtractSaturateUint32 = `\nhighp uint subtractSaturate(highp uint x, highp uint y) {\n highp uint result = x - y;\n if (result > x) return 0u;\n return result;\n}\n`;\n\nexport const glsl_addSaturateInt32 = [\n glsl_addSaturateUint32,\n `\nhighp int addSaturate(highp int x, highp uint y) {\n if (x >= 0) {\n return int(min(addSaturate(y, uint(x)), 0x7fffffffu));\n } else if (y >= uint(-x)) {\n return int(min(y - uint(-x), 0x7fffffffu));\n } else {\n return -int(min(uint(-x) - y, 0x80000000u));\n }\n}\n`,\n];\n\nexport const glsl_subtractSaturateInt32 = [\n glsl_addSaturateUint32,\n `\nhighp int subtractSaturate(highp int x, highp uint y) {\n if (x < 0) {\n return -int(min(addSaturate(uint(-x), uint(y)), 0x80000000u));\n } else if (uint(x) >= y) {\n return x - int(y);\n } else {\n return -int(min(y - uint(x), 0x80000000u));\n }\n}\n`,\n];\n\nexport function getShaderType(dataType: DataType, numComponents = 1) {\n switch (dataType) {\n case DataType.FLOAT32:\n if (numComponents === 1) {\n return \"float\";\n }\n if (numComponents > 1 && numComponents <= 4) {\n return `vec${numComponents}`;\n }\n break;\n case DataType.UINT8:\n case DataType.INT8:\n case DataType.UINT16:\n case DataType.INT16:\n case DataType.UINT32:\n case DataType.INT32:\n case DataType.UINT64: {\n const prefix = DATA_TYPE_SIGNED[dataType] ? \"\" : \"u\";\n const bits = DATA_TYPE_BYTES[dataType] * 8;\n if (numComponents === 1) {\n return `${prefix}int${bits}_t`;\n }\n if (numComponents > 1 && numComponents * bits <= 32) {\n return `${prefix}int${bits}x${numComponents}_t`;\n }\n break;\n }\n }\n throw new Error(\n `No shader type for ${DataType[dataType]}[${numComponents}].`,\n );\n}\n\nexport const dataTypeShaderDefinition: Record = {\n [DataType.UINT8]: glsl_uint8,\n [DataType.INT8]: glsl_int8,\n [DataType.UINT16]: glsl_uint16,\n [DataType.INT16]: glsl_int16,\n [DataType.UINT32]: glsl_uint32,\n [DataType.INT32]: glsl_int32,\n [DataType.UINT64]: glsl_uint64,\n [DataType.FLOAT32]: glsl_float,\n};\n\nexport function getShaderVectorType(\n typeName: \"float\" | \"int\" | \"uint\",\n n: number,\n) {\n if (n === 1) return typeName;\n if (typeName === \"float\") return `vec${n}`;\n return `${typeName[0]}vec${n}`;\n}\n\nexport const webglTypeSizeInBytes: { [webglType: number]: number } = {\n [WebGL2RenderingContext.UNSIGNED_BYTE]: 1,\n [WebGL2RenderingContext.BYTE]: 1,\n [WebGL2RenderingContext.UNSIGNED_SHORT]: 2,\n [WebGL2RenderingContext.SHORT]: 2,\n [WebGL2RenderingContext.FLOAT]: 4,\n [WebGL2RenderingContext.INT]: 4,\n [WebGL2RenderingContext.UNSIGNED_INT]: 4,\n};\n\nexport function defineVectorArrayVertexShaderInput(\n builder: ShaderBuilder,\n typeName: \"float\" | \"int\" | \"uint\",\n attributeType: number,\n normalized: boolean,\n name: string,\n vectorRank: number,\n arraySize = 1,\n) {\n let numAttributes = 0;\n let n = vectorRank * arraySize;\n while (n > 0) {\n const components = Math.min(4, n);\n const t = getShaderVectorType(typeName, components);\n n -= components;\n builder.addAttribute(\"highp \" + t, `a${name}${numAttributes}`);\n ++numAttributes;\n }\n n = vectorRank * arraySize;\n let code = \"\";\n for (let arrayIndex = 0; arrayIndex < arraySize; ++arrayIndex) {\n code += `highp ${typeName}[${vectorRank}] get${name}${arrayIndex}() {\n highp ${typeName}[${vectorRank}] result;\n`;\n for (let vectorIndex = 0; vectorIndex < vectorRank; ++vectorIndex) {\n const i = arrayIndex * vectorRank + vectorIndex;\n const attributeIndex = Math.floor(i / 4);\n const componentIndex = i % 4;\n code += ` result[${vectorIndex}] = a${name}${attributeIndex}`;\n if (componentIndex !== 0 || i !== n - 1) {\n code += `[${componentIndex}]`;\n }\n code += \";\\n\";\n }\n code += \" return result;\\n\";\n code += \"}\\n\";\n }\n builder.addVertexCode(code);\n const elementSize = webglTypeSizeInBytes[attributeType];\n builder.addInitializer((shader) => {\n const locations: AttributeIndex[] = [];\n for (\n let attributeIndex = 0;\n attributeIndex < numAttributes;\n ++attributeIndex\n ) {\n locations[attributeIndex] = shader.attribute(`a${name}${attributeIndex}`);\n }\n shader.vertexShaderInputBinders[name] = {\n enable(divisor: number) {\n const { gl } = shader;\n for (\n let attributeIndex = 0;\n attributeIndex < numAttributes;\n ++attributeIndex\n ) {\n const location = locations[attributeIndex];\n gl.enableVertexAttribArray(location);\n gl.vertexAttribDivisor(location, divisor);\n }\n },\n disable() {\n const { gl } = shader;\n for (\n let attributeIndex = 0;\n attributeIndex < numAttributes;\n ++attributeIndex\n ) {\n const location = locations[attributeIndex];\n gl.vertexAttribDivisor(location, 0);\n gl.disableVertexAttribArray(location);\n }\n },\n bind(stride: number, offset: number) {\n const { gl } = shader;\n for (\n let attributeIndex = 0;\n attributeIndex < numAttributes;\n ++attributeIndex\n ) {\n const location = locations[attributeIndex];\n const numComponents = Math.min(4, n - 4 * attributeIndex);\n if (typeName === \"float\") {\n gl.vertexAttribPointer(\n location,\n /*size=*/ numComponents,\n attributeType,\n normalized,\n stride,\n offset,\n );\n } else {\n gl.vertexAttribIPointer(\n location,\n /*size=*/ Math.min(4, n - 4 * attributeIndex),\n attributeType,\n stride,\n offset,\n );\n }\n offset += elementSize * numComponents;\n }\n },\n };\n });\n}\n","/**\n * @license\n * Copyright 2020 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @file Defines facilities for GPU computation of empirical cumulative distribution functions.\n *\n * This is based on the technique described in\n * http://shaderwrangler.com/publications/histogram/\n *\n * In particular, the \"scatter\" operation required to compute a histogram is performed by\n * rendering point primitives.\n */\n\nimport type { WatchableValueInterface } from \"#src/trackable_value.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport type { DataTypeInterval } from \"#src/util/lerp.js\";\nimport { VisibilityPriorityAggregator } from \"#src/visibility_priority/frontend.js\";\nimport { getMemoizedBuffer } from \"#src/webgl/buffer.js\";\nimport type { GL } from \"#src/webgl/context.js\";\nimport type { TextureBuffer } from \"#src/webgl/offscreen.js\";\nimport {\n FramebufferConfiguration,\n makeTextureBuffers,\n} from \"#src/webgl/offscreen.js\";\nimport { ShaderBuilder } from \"#src/webgl/shader.js\";\nimport { glsl_simpleFloatHash } from \"#src/webgl/shader_lib.js\";\nimport { setRawTextureParameters } from \"#src/webgl/texture.js\";\n\nconst DEBUG_HISTOGRAMS = false;\n\nexport interface HistogramChannelSpecification {\n // Channel coordinates.\n channel: Uint32Array;\n}\n\nexport class HistogramSpecifications extends RefCounted {\n framebuffers: FramebufferConfiguration[] = [];\n producerVisibility = new VisibilityPriorityAggregator();\n frameNumber = -1;\n constructor(\n public channels: WatchableValueInterface,\n public properties: WatchableValueInterface,\n public bounds: WatchableValueInterface,\n public visibility = new VisibilityPriorityAggregator(),\n ) {\n super();\n }\n\n getFramebuffers(gl: GL) {\n const { framebuffers } = this;\n const count = this.bounds.value.length;\n while (framebuffers.length < count) {\n const framebuffer = new FramebufferConfiguration(gl, {\n colorBuffers: makeTextureBuffers(\n gl,\n 1,\n WebGL2RenderingContext.R32F,\n WebGL2RenderingContext.RED,\n WebGL2RenderingContext.FLOAT,\n ),\n });\n framebuffers.push(framebuffer);\n }\n return framebuffers;\n }\n\n get visibleHistograms(): number {\n if (!this.visibility.visible) return 0;\n return this.bounds.value.length;\n }\n\n disposed() {\n for (const framebuffer of this.framebuffers) {\n framebuffer.dispose();\n }\n this.framebuffers.length = 0;\n }\n}\n\nconst histogramDataSamplerTextureUnit = Symbol(\n \"histogramDataSamplerTextureUnit\",\n);\nconst histogramDepthTextureUnit = Symbol(\"histogramDepthTextureUnit\");\n\nconst histogramSamplesPerInstance = 4096;\n\n// Number of points to sample in computing the histogram. Increasing this increases the precision\n// of the histogram but also slows down rendering.\nconst histogramSamples = 2 ** 14;\n\n/**\n * Generates a histogram from a single-channel uint8 texture.\n */\nexport class TextureHistogramGenerator extends RefCounted {\n private shader = this.registerDisposer(\n (() => {\n const builder = new ShaderBuilder(this.gl);\n builder.addOutputBuffer(\"vec4\", \"outputValue\", 0);\n builder.addAttribute(\"float\", \"aInput1\");\n builder.addTextureSampler(\n \"sampler2D\",\n \"uDataSampler\",\n histogramDataSamplerTextureUnit,\n );\n builder.addTextureSampler(\n \"sampler2D\",\n \"uDepthSampler\",\n histogramDepthTextureUnit,\n );\n // builder.addUniform('float', 'uRandomSeed');\n builder.addVertexCode(glsl_simpleFloatHash);\n builder.setVertexMain(`\nfloat uRandomSeed = 0.0;\nvec2 p = vec2(simpleFloatHash(vec2(aInput1 + float(gl_VertexID), uRandomSeed + float(gl_InstanceID))),\n simpleFloatHash(vec2(aInput1 + float(gl_VertexID) + 10.0, 5.0 + uRandomSeed + float(gl_InstanceID))));\nfloat dataValue = texture(uDataSampler, p).x;\nfloat stencilValue = texture(uDepthSampler, p).x;\nif (stencilValue == 1.0) {\n gl_Position = vec4(2.0, 2.0, 2.0, 1.0);\n} else {\n gl_Position = vec4(2.0 * (dataValue * 255.0 + 0.5) / 256.0 - 1.0, 0.0, 0.0, 1.0);\n}\ngl_PointSize = 1.0;\n`);\n builder.setFragmentMain(`\noutputValue = vec4(1.0, 1.0, 1.0, 1.0);\n`);\n return builder.build();\n })(),\n );\n\n private inputIndexBuffer = this.registerDisposer(\n getMemoizedBuffer(\n this.gl,\n WebGL2RenderingContext.ARRAY_BUFFER,\n () => new Uint8Array(histogramSamplesPerInstance),\n ),\n );\n\n constructor(public gl: GL) {\n super();\n }\n\n static get(gl: GL) {\n return gl.memoize.get(\n \"textureHistogramGeneration\",\n () => new TextureHistogramGenerator(gl),\n );\n }\n\n compute(\n count: number,\n depthTexture: WebGLTexture | null,\n inputTextures: TextureBuffer[],\n histogramSpecifications: HistogramSpecifications,\n frameNumber: number,\n ) {\n const { gl } = this;\n const { shader } = this;\n const outputFramebuffers = histogramSpecifications.getFramebuffers(gl);\n shader.bind();\n gl.enable(WebGL2RenderingContext.BLEND);\n gl.disable(WebGL2RenderingContext.SCISSOR_TEST);\n gl.disable(WebGL2RenderingContext.DEPTH_TEST);\n gl.blendFunc(WebGL2RenderingContext.ONE, WebGL2RenderingContext.ONE);\n this.inputIndexBuffer.value.bindToVertexAttrib(\n shader.attribute(\"aInput1\"),\n 1,\n WebGL2RenderingContext.UNSIGNED_BYTE,\n /*normalized=*/ true,\n );\n const dataUnit = shader.textureUnit(histogramDataSamplerTextureUnit);\n const depthUnit = shader.textureUnit(histogramDepthTextureUnit);\n gl.activeTexture(WebGL2RenderingContext.TEXTURE0 + depthUnit);\n gl.bindTexture(WebGL2RenderingContext.TEXTURE_2D, depthTexture);\n setRawTextureParameters(gl);\n gl.activeTexture(WebGL2RenderingContext.TEXTURE0 + dataUnit);\n const oldFrameNumber = histogramSpecifications.frameNumber;\n histogramSpecifications.frameNumber = frameNumber;\n for (let i = 0; i < count; ++i) {\n gl.bindTexture(\n WebGL2RenderingContext.TEXTURE_2D,\n inputTextures[i].texture,\n );\n setRawTextureParameters(gl);\n outputFramebuffers[i].bind(256, 1);\n if (frameNumber !== oldFrameNumber) {\n gl.clearColor(0, 0, 0, 0);\n gl.clear(WebGL2RenderingContext.COLOR_BUFFER_BIT);\n }\n gl.drawArraysInstanced(\n WebGL2RenderingContext.POINTS,\n 0,\n histogramSamplesPerInstance,\n histogramSamples / histogramSamplesPerInstance,\n );\n\n if (DEBUG_HISTOGRAMS) {\n const tempBuffer = new Float32Array(256 * 4);\n gl.readPixels(\n 0,\n 0,\n 256,\n 1,\n WebGL2RenderingContext.RGBA,\n WebGL2RenderingContext.FLOAT,\n tempBuffer,\n );\n const tempBuffer2 = new Float32Array(256);\n for (let j = 0; j < 256; ++j) {\n tempBuffer2[j] = tempBuffer[j * 4];\n }\n console.log(\"histogram\", tempBuffer2.join(\" \"));\n }\n }\n gl.disable(WebGL2RenderingContext.BLEND);\n }\n}\n","/**\n * @license\n * Copyright 2020 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @file Defines lerp/invlerp functionality for all supported data types.\n */\n\nimport { DataType, DATA_TYPE_SIGNED } from \"#src/util/data_type.js\";\nimport type { DataTypeInterval } from \"#src/util/lerp.js\";\nimport { Uint64 } from \"#src/util/uint64.js\";\nimport type {\n ShaderBuilder,\n ShaderCodePart,\n ShaderProgram,\n} from \"#src/webgl/shader.js\";\nimport {\n dataTypeShaderDefinition,\n getShaderType,\n glsl_addSaturateInt32,\n glsl_addSaturateUint32,\n glsl_addSaturateUint64,\n glsl_compareLessThanUint64,\n glsl_equalUint64,\n glsl_shiftLeftSaturateUint32,\n glsl_shiftLeftUint64,\n glsl_shiftRightUint64,\n glsl_subtractSaturateInt32,\n glsl_subtractSaturateUint32,\n glsl_subtractSaturateUint64,\n glsl_subtractUint64,\n glsl_uint64,\n} from \"#src/webgl/shader_lib.js\";\n\nexport const dataTypeShaderLerpParametersType: Record = {\n [DataType.UINT8]: \"vec2\",\n [DataType.INT8]: \"vec2\",\n [DataType.UINT16]: \"vec2\",\n [DataType.INT16]: \"vec2\",\n [DataType.FLOAT32]: \"vec2\",\n [DataType.UINT32]: \"Uint32LerpParameters\",\n [DataType.INT32]: \"Int32LerpParameters\",\n [DataType.UINT64]: \"Uint64LerpParameters\",\n};\n\nconst glsl_dataTypeLerpParameters: Record = {\n [DataType.UINT8]: \"\",\n [DataType.INT8]: \"\",\n [DataType.UINT16]: \"\",\n [DataType.INT16]: \"\",\n [DataType.FLOAT32]: \"\",\n [DataType.UINT32]: `\nstruct Uint32LerpParameters {\n uint offset;\n int shift;\n float multiplier;\n};\n`,\n [DataType.INT32]: `\nstruct Int32LerpParameters {\n int offset;\n int shift;\n float multiplier;\n};\n`,\n [DataType.UINT64]: [\n glsl_uint64,\n `\nstruct Uint64LerpParameters {\n uint64_t offset;\n int shift;\n float multiplier;\n};\n`,\n ],\n};\n\nconst glsl_computeInvlerpFloat = `\nfloat computeInvlerp(float inputValue, vec2 p) {\n float outputValue = inputValue;\n outputValue = (outputValue - p[0]) * p[1];\n return outputValue;\n}\n`;\n\nfunction getIntFloatInvlerpImpl(dataType: DataType) {\n const shaderDataType = getShaderType(dataType);\n const code = `\nfloat computeInvlerp(${shaderDataType} inputValue, vec2 p) {\n return computeInvlerp(float(toRaw(inputValue)), p);\n}\n`;\n return [dataTypeShaderDefinition[dataType], glsl_computeInvlerpFloat, code];\n}\n\nfunction getInt32InvlerpImpl(dataType: DataType) {\n const shaderDataType = getShaderType(dataType);\n const scalarType = dataType === DataType.INT32 ? \"int\" : \"uint\";\n const pType = dataTypeShaderLerpParametersType[dataType];\n return [\n dataTypeShaderDefinition[dataType],\n glsl_dataTypeLerpParameters[dataType],\n `\nfloat computeInvlerp(${scalarType} v, ${pType} p) {\n uint x;\n if (v >= p.offset) {\n x = uint(v - p.offset);\n } else {\n x = uint(p.offset - v);\n p.multiplier = -p.multiplier;\n }\n x >>= p.shift;\n return float(x) * p.multiplier;\n}\nfloat computeInvlerp(${shaderDataType} inputValue, ${pType} p) {\n return computeInvlerp(toRaw(inputValue), p);\n}\n`,\n ];\n}\n\nexport const glsl_dataTypeComputeInvlerp: Record = {\n [DataType.UINT8]: getIntFloatInvlerpImpl(DataType.UINT8),\n [DataType.INT8]: getIntFloatInvlerpImpl(DataType.INT8),\n [DataType.UINT16]: getIntFloatInvlerpImpl(DataType.UINT16),\n [DataType.INT16]: getIntFloatInvlerpImpl(DataType.INT16),\n [DataType.FLOAT32]: glsl_computeInvlerpFloat,\n [DataType.UINT32]: getInt32InvlerpImpl(DataType.UINT32),\n [DataType.INT32]: getInt32InvlerpImpl(DataType.INT32),\n [DataType.UINT64]: [\n glsl_uint64,\n glsl_compareLessThanUint64,\n glsl_subtractUint64,\n glsl_shiftRightUint64,\n glsl_dataTypeLerpParameters[DataType.UINT64],\n `\nfloat computeInvlerp(uint64_t inputValue, Uint64LerpParameters p) {\n if (compareLessThan(inputValue, p.offset)) {\n inputValue = subtract(p.offset, inputValue);\n p.multiplier = -p.multiplier;\n } else {\n inputValue = subtract(inputValue, p.offset);\n }\n uint shifted = shiftRight(inputValue, p.shift).value[0];\n return float(shifted) * p.multiplier;\n}\n`,\n ],\n};\n\nfunction getFloatLerpImpl(dataType: DataType) {\n const shaderDataType = getShaderType(dataType);\n let code = `\n${shaderDataType} computeLerp(float inputValue, vec2 p) {\n inputValue = inputValue / p[1] + p[0];\n`;\n if (dataType === DataType.FLOAT32) {\n code += \"return inputValue;\\n\";\n } else {\n code += `return ${DataType[\n dataType\n ].toLowerCase()}FromFloat(round(inputValue));\\n`;\n }\n code += `\n}\n`;\n return [dataTypeShaderDefinition[dataType], code];\n}\n\nfunction getInt32LerpImpl(dataType: DataType) {\n const shaderDataType = getShaderType(dataType);\n const pType = dataTypeShaderLerpParametersType[dataType];\n return [\n dataTypeShaderDefinition[dataType],\n glsl_dataTypeLerpParameters[dataType],\n glsl_shiftLeftSaturateUint32,\n dataType === DataType.UINT32\n ? glsl_addSaturateUint32\n : glsl_addSaturateInt32,\n dataType === DataType.UINT32\n ? glsl_subtractSaturateUint32\n : glsl_subtractSaturateInt32,\n `\n${shaderDataType} computeLerp(float inputValue, ${pType} p) {\n inputValue = inputValue / p.multiplier;\n uint x = uint(clamp(round(abs(inputValue)), 0.0, 4294967295.0));\n uint xShifted = shiftLeftSaturate(x, p.shift);\n if (inputValue >= 0.0) {\n return ${shaderDataType}(addSaturate(p.offset, xShifted));\n } else {\n return ${shaderDataType}(subtractSaturate(p.offset, xShifted));\n }\n}\n`,\n ];\n}\n\nexport const glsl_dataTypeComputeLerp: Record = {\n [DataType.UINT8]: getFloatLerpImpl(DataType.UINT8),\n [DataType.INT8]: getFloatLerpImpl(DataType.INT8),\n [DataType.UINT16]: getFloatLerpImpl(DataType.UINT16),\n [DataType.INT16]: getFloatLerpImpl(DataType.INT16),\n [DataType.FLOAT32]: getFloatLerpImpl(DataType.FLOAT32),\n [DataType.UINT32]: getInt32LerpImpl(DataType.UINT32),\n [DataType.INT32]: getInt32LerpImpl(DataType.INT32),\n [DataType.UINT64]: [\n glsl_uint64,\n glsl_compareLessThanUint64,\n glsl_equalUint64,\n glsl_addSaturateUint64,\n glsl_subtractSaturateUint64,\n glsl_shiftRightUint64,\n glsl_shiftLeftUint64,\n glsl_dataTypeLerpParameters[DataType.UINT64],\n `\nuint64_t computeLerp(float inputValue, Uint64LerpParameters p) {\n inputValue = inputValue / p.multiplier;\n uint64_t x = uint64_t(uvec2(uint(clamp(round(abs(inputValue)), 0.0, 4294967295.0)), 0u));\n uint64_t shifted = shiftLeft(x, p.shift);\n if (!equals(shiftRight(shifted, p.shift), x)) {\n return uint64_t(uvec2(0xffffffffu, 0xffffffffu));\n }\n if (inputValue >= 0.0) {\n return addSaturate(p.offset, shifted);\n } else {\n return subtractSaturate(p.offset, shifted);\n }\n}\n`,\n ],\n};\n\nfunction defineLerpUniforms(\n builder: ShaderBuilder,\n name: string,\n dataType: DataType,\n): ShaderCodePart {\n const pName = `uLerpParams_${name}`;\n const bName = `uLerpBounds_${name}`;\n const sName = `uLerpScalar_${name}`;\n let code = \"\";\n switch (dataType) {\n case DataType.INT8:\n case DataType.UINT8:\n case DataType.INT16:\n case DataType.UINT16:\n // {uint,int}{8,16} can be converted with float32 without any loss of precision\n // fallthrough\n case DataType.FLOAT32:\n builder.addUniform(\"vec2\", pName);\n break;\n case DataType.INT32:\n case DataType.UINT32: {\n const pType = dataTypeShaderLerpParametersType[dataType];\n builder.addUniform(\n `${dataType === DataType.INT32 ? \"i\" : \"u\"}vec2`,\n bName,\n );\n builder.addUniform(\"float\", sName);\n code += `\n#define ${pName} ${pType}(${bName}[0], int(${bName}[1]), ${sName})\n`;\n break;\n }\n case DataType.UINT64: {\n builder.addUniform(\"uvec3\", bName);\n builder.addUniform(\"float\", sName);\n code += `\n#define ${pName} Uint64LerpParameters(uint64_t(${bName}.xy), int(${bName}[2]), ${sName})\n`;\n break;\n }\n }\n return [glsl_dataTypeLerpParameters[dataType], code];\n}\n\nexport function defineInvlerpShaderFunction(\n builder: ShaderBuilder,\n name: string,\n dataType: DataType,\n clamp = false,\n): ShaderCodePart {\n const shaderType = getShaderType(dataType);\n let code = `\nfloat ${name}(${shaderType} inputValue) {\n float v = computeInvlerp(inputValue, uLerpParams_${name});\n ${!clamp ? \"\" : \"v = clamp(v, 0.0, 1.0);\"}\n defaultMaxProjectionIntensity = v;\n return v;\n}\n`;\n if (dataType !== DataType.UINT64 && dataType !== DataType.FLOAT32) {\n const scalarType = DATA_TYPE_SIGNED[dataType] ? \"int\" : \"uint\";\n code += `\nfloat ${name}(${scalarType} inputValue) {\n return ${name}(${shaderType}(inputValue));\n}\n`;\n }\n return [\n dataTypeShaderDefinition[dataType],\n defineLerpUniforms(builder, name, dataType),\n glsl_dataTypeComputeInvlerp[dataType],\n code,\n ];\n}\n\nexport function defineLerpShaderFunction(\n builder: ShaderBuilder,\n name: string,\n dataType: DataType,\n): ShaderCodePart {\n return [\n dataTypeShaderDefinition[dataType],\n defineLerpUniforms(builder, name, dataType),\n glsl_dataTypeComputeLerp[dataType],\n `\n${getShaderType(dataType)} ${name}(float inputValue) {\n return computeLerp(inputValue, uLerpParams_${name});\n}\n`,\n ];\n}\n\nconst tempUint64 = new Uint64();\n\nexport function enableLerpShaderFunction(\n shader: ShaderProgram,\n name: string,\n dataType: DataType,\n interval: DataTypeInterval,\n) {\n const { gl } = shader;\n switch (dataType) {\n case DataType.INT8:\n case DataType.UINT8:\n case DataType.INT16:\n case DataType.UINT16:\n case DataType.FLOAT32:\n gl.uniform2f(\n shader.uniform(`uLerpParams_${name}`),\n interval[0] as number,\n 1 / ((interval[1] as number) - (interval[0] as number)),\n );\n break;\n case DataType.INT32:\n case DataType.UINT32: {\n const lower = interval[0] as number;\n const diff = (interval[1] as number) - lower;\n const shift = Math.max(0, Math.ceil(Math.log2(Math.abs(diff))) - 24);\n const scalar = 2 ** shift / diff;\n const bLocation = shader.uniform(`uLerpBounds_${name}`);\n if (dataType === DataType.UINT32) {\n gl.uniform2ui(bLocation, lower, shift);\n } else {\n gl.uniform2i(bLocation, lower, shift);\n }\n gl.uniform1f(shader.uniform(`uLerpScalar_${name}`), scalar);\n break;\n }\n case DataType.UINT64: {\n const lower = interval[0] as Uint64;\n const upper = interval[1] as Uint64;\n Uint64.absDifference(tempUint64, upper, lower);\n const numBits =\n tempUint64.high > 0\n ? 32 + Math.ceil(Math.log2(tempUint64.high))\n : Math.ceil(Math.log2(tempUint64.low));\n const shift = Math.max(0, numBits - 24);\n Uint64.rshift(tempUint64, tempUint64, shift);\n let scalar = 1 / tempUint64.low;\n if (Uint64.compare(lower, upper) > 0) {\n scalar *= -1;\n }\n const bLocation = shader.uniform(`uLerpBounds_${name}`);\n gl.uniform3ui(bLocation, lower.low, lower.high, shift);\n gl.uniform1f(shader.uniform(`uLerpScalar_${name}`), scalar);\n }\n }\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @file Defines a generic interface for a simple state tracking mechanism.\n */\n\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport { verifyObject, verifyOptionalObjectProperty } from \"#src/util/json.js\";\nimport type { NullaryReadonlySignal } from \"#src/util/signal.js\";\nimport { NullarySignal } from \"#src/util/signal.js\";\n\nexport interface JsonRestorable {\n restoreState: (x: any) => void;\n}\n\nexport function optionallyRestoreFromJsonMember(\n obj: any,\n member: string,\n restorable: JsonRestorable,\n) {\n verifyOptionalObjectProperty(obj, member, (x) => restorable.restoreState(x));\n}\n\nexport interface Trackable extends JsonRestorable {\n restoreState: (x: any) => void;\n reset: () => void;\n changed: NullaryReadonlySignal;\n toJSON: () => any;\n}\n\nexport class CompoundTrackable extends RefCounted implements Trackable {\n children = new Map();\n changed = new NullarySignal();\n\n add(key: string, value: Trackable): () => void {\n const { children } = this;\n if (children.has(key)) {\n throw new Error(`Key ${JSON.stringify(key)} already registered.`);\n }\n this.children.set(key, value);\n value.changed.add(this.changed.dispatch);\n this.changed.dispatch();\n return () => {\n this.remove(key);\n };\n }\n\n remove(key: string): void {\n const { children } = this;\n if (children.has(key)) {\n throw new Error(`Key ${JSON.stringify(key)} not registered.`);\n }\n const value = children.get(key)!;\n this.children.delete(key);\n value.changed.remove(this.changed.dispatch);\n this.changed.dispatch();\n }\n\n disposed() {\n const { changed } = this;\n for (const value of this.children.values()) {\n value.changed.remove(changed.dispatch);\n }\n this.children = undefined;\n super.disposed();\n }\n\n toJSON() {\n const result = this.baseJSON();\n for (const [key, value] of this.children) {\n result[key] = value.toJSON();\n }\n return result;\n }\n\n baseJSON() {\n return <{ [key: string]: any }>{};\n }\n\n reset() {\n for (const value of this.children.values()) {\n value.reset();\n }\n }\n\n restoreState(x: any) {\n verifyObject(x);\n for (const [key, value] of this.children) {\n try {\n if (Object.prototype.hasOwnProperty.call(x, key)) {\n const subValue = x[key];\n if (subValue === undefined) {\n continue;\n }\n value.restoreState(subValue);\n }\n } catch (restoreError) {\n throw new Error(\n `Error restoring property ${JSON.stringify(key)}: ${\n restoreError.message\n }`,\n );\n }\n }\n }\n}\n\nexport class PersistentCompoundTrackable extends CompoundTrackable {\n lastState: { [key: string]: any } = {};\n\n restoreState(x: any) {\n verifyObject(x);\n this.lastState = x;\n super.restoreState(x);\n }\n\n reset() {\n this.lastState = {};\n super.reset();\n }\n\n baseJSON() {\n const result = Object.assign(super.baseJSON(), this.lastState);\n for (const key of this.children.keys()) {\n delete result[key];\n }\n return result;\n }\n\n toJSON() {\n const result = super.toJSON();\n this.lastState = result;\n return result;\n }\n add(key: string, value: Trackable) {\n const result = super.add(key, value);\n const existingValue = this.lastState[key];\n if (existingValue !== undefined) {\n value.reset();\n value.restoreState(existingValue);\n }\n return result;\n }\n}\n\n/**\n * Cache used by getCachedJson.\n */\nconst jsonCache = new WeakMap();\n\n/**\n * Returns a JSON representation of a Trackable object.\n *\n * Recursively caches the result, such that it is only necessary to traverse the changed portions of\n * the object.\n *\n * The returned value must not be modified.\n */\nexport function getCachedJson(root: Trackable): {\n value: any;\n generation: number;\n} {\n let cacheState = jsonCache.get(root);\n const generation = root.changed.count;\n if (cacheState !== undefined) {\n if (cacheState.generation === generation) {\n return cacheState;\n }\n }\n let value: any;\n if (root instanceof CompoundTrackable) {\n value = root.baseJSON();\n for (const [k, v] of root.children) {\n value[k] = getCachedJson(v).value;\n }\n } else {\n value = root.toJSON();\n }\n if (cacheState === undefined) {\n cacheState = { generation, value };\n jsonCache.set(root, cacheState);\n } else {\n cacheState.generation = generation;\n cacheState.value = value;\n }\n return cacheState;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n CoordinateSpace,\n DimensionId,\n} from \"#src/coordinate_transform.js\";\nimport {\n clampAndRoundCoordinateToVoxelCenter,\n dimensionNamesFromJson,\n emptyInvalidCoordinateSpace,\n getBoundingBoxCenter,\n getCenterBound,\n} from \"#src/coordinate_transform.js\";\nimport type { WatchableValueInterface } from \"#src/trackable_value.js\";\nimport { arraysEqual } from \"#src/util/array.js\";\nimport type { Borrowed, Owned } from \"#src/util/disposable.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport { mat3, mat4, quat, vec3 } from \"#src/util/geom.js\";\nimport {\n parseArray,\n parseFiniteVec,\n verifyBoolean,\n verifyEnumString,\n verifyFiniteFloat,\n verifyFinitePositiveFloat,\n verifyObject,\n verifyObjectProperty,\n verifyOptionalObjectProperty,\n} from \"#src/util/json.js\";\nimport { NullarySignal } from \"#src/util/signal.js\";\nimport type { Trackable } from \"#src/util/trackable.js\";\nimport { optionallyRestoreFromJsonMember } from \"#src/util/trackable.js\";\nimport { TrackableEnum } from \"#src/util/trackable_enum.js\";\nimport * as vector from \"#src/util/vector.js\";\n\nexport enum NavigationLinkType {\n LINKED = 0,\n RELATIVE = 1,\n UNLINKED = 2,\n}\n\nexport enum NavigationSimpleLinkType {\n LINKED = 0,\n UNLINKED = 2,\n}\n\nexport class TrackableNavigationLink extends TrackableEnum {\n constructor(value = NavigationLinkType.LINKED) {\n super(NavigationLinkType, value);\n }\n}\n\nexport class TrackableNavigationSimpleLink extends TrackableEnum {\n constructor(value = NavigationSimpleLinkType.LINKED) {\n super(NavigationSimpleLinkType, value);\n }\n}\n\nconst tempVec3 = vec3.create();\nconst tempQuat = quat.create();\n\nfunction makeLinked<\n T extends RefCounted & { changed: NullarySignal },\n Difference,\n>(\n self: T,\n peer: T,\n link: TrackableNavigationLink,\n operations: {\n assign: (target: T, source: T) => void;\n isValid: (a: T) => boolean;\n difference: (a: T, b: T) => Difference;\n add: (target: T, source: T, amount: Difference) => void;\n subtract: (target: T, source: T, amount: Difference) => void;\n },\n): T {\n let updatingSelf = false;\n const updatingPeer = false;\n let selfMinusPeer: Difference | undefined;\n self.registerDisposer(peer);\n const handlePeerUpdate = () => {\n if (updatingPeer) {\n return;\n }\n updatingSelf = true;\n switch (link.value) {\n case NavigationLinkType.UNLINKED:\n if (operations.isValid(self)) {\n break;\n }\n // fallthrough\n case NavigationLinkType.LINKED:\n operations.assign(self, peer);\n break;\n case NavigationLinkType.RELATIVE:\n operations.add(self, peer, selfMinusPeer!);\n break;\n }\n updatingSelf = false;\n };\n const handleSelfUpdate = () => {\n if (updatingSelf) {\n return;\n }\n switch (link.value) {\n case NavigationLinkType.UNLINKED:\n break;\n case NavigationLinkType.LINKED:\n operations.assign(peer, self);\n break;\n case NavigationLinkType.RELATIVE:\n operations.subtract(peer, self, selfMinusPeer!);\n break;\n }\n };\n let previousLinkValue = NavigationLinkType.UNLINKED;\n const handleLinkUpdate = () => {\n const linkValue = link.value;\n if (linkValue !== previousLinkValue) {\n switch (linkValue) {\n case NavigationLinkType.UNLINKED:\n selfMinusPeer = undefined;\n break;\n case NavigationLinkType.LINKED:\n selfMinusPeer = undefined;\n operations.assign(self, peer);\n break;\n case NavigationLinkType.RELATIVE:\n selfMinusPeer = operations.difference(self, peer);\n break;\n }\n }\n previousLinkValue = linkValue;\n self.changed.dispatch();\n };\n self.registerDisposer(self.changed.add(handleSelfUpdate));\n self.registerDisposer(peer.changed.add(handlePeerUpdate));\n self.registerDisposer(link.changed.add(handleLinkUpdate));\n handleLinkUpdate();\n return self;\n}\n\nfunction makeSimpleLinked(\n self: T,\n peer: T,\n link: TrackableNavigationSimpleLink,\n operations: {\n assign: (target: T, source: T) => void;\n isValid: (a: T) => boolean;\n },\n) {\n return makeLinked(self, peer, link as any, operations as any);\n}\n\nexport class Position extends RefCounted {\n private coordinates_: Float32Array = vector.kEmptyFloat32Vec;\n private curCoordinateSpace: CoordinateSpace | undefined;\n changed = new NullarySignal();\n constructor(\n public coordinateSpace: WatchableValueInterface,\n ) {\n super();\n this.registerDisposer(\n coordinateSpace.changed.add(() => {\n this.handleCoordinateSpaceChanged();\n }),\n );\n }\n\n get valid() {\n return this.coordinateSpace.value.valid;\n }\n\n /**\n * Returns the position in voxels.\n */\n get value() {\n this.handleCoordinateSpaceChanged();\n return this.coordinates_;\n }\n\n reset() {\n this.curCoordinateSpace = undefined;\n this.coordinates_ = vector.kEmptyFloat32Vec;\n this.changed.dispatch();\n }\n\n set value(coordinates: Float32Array) {\n const { curCoordinateSpace } = this;\n if (\n curCoordinateSpace === undefined ||\n !curCoordinateSpace.valid ||\n curCoordinateSpace.rank !== coordinates.length\n ) {\n return;\n }\n const { coordinates_ } = this;\n coordinates_.set(coordinates);\n this.changed.dispatch();\n }\n\n private handleCoordinateSpaceChanged() {\n const coordinateSpace = this.coordinateSpace.value;\n const prevCoordinateSpace = this.curCoordinateSpace;\n if (coordinateSpace === prevCoordinateSpace) return;\n this.curCoordinateSpace = coordinateSpace;\n const { rank } = coordinateSpace;\n if (!coordinateSpace.valid) return;\n if (prevCoordinateSpace === undefined || !prevCoordinateSpace.valid) {\n let { coordinates_ } = this;\n if (coordinates_ !== undefined && coordinates_.length === rank) {\n // Use the existing voxel coordinates if rank is the same. Otherwise, ignore.\n } else {\n coordinates_ = this.coordinates_ = new Float32Array(rank);\n getBoundingBoxCenter(coordinates_, coordinateSpace.bounds);\n const { voxelCenterAtIntegerCoordinates } = coordinateSpace.bounds;\n for (let i = 0; i < rank; ++i) {\n if (voxelCenterAtIntegerCoordinates[i]) {\n coordinates_[i] = Math.round(coordinates_[i]);\n } else {\n coordinates_[i] = Math.floor(coordinates_[i]) + 0.5;\n }\n }\n }\n this.changed.dispatch();\n return;\n }\n // Match dimensions by ID.\n const newCoordinates = new Float32Array(rank);\n const prevCoordinates = this.coordinates_;\n const { ids, scales: newScales } = coordinateSpace;\n const { ids: prevDimensionIds, scales: oldScales } = prevCoordinateSpace;\n for (let newDim = 0; newDim < rank; ++newDim) {\n const newDimId = ids[newDim];\n const oldDim = prevDimensionIds.indexOf(newDimId);\n if (oldDim === -1) {\n newCoordinates[newDim] = getCenterBound(\n coordinateSpace.bounds.lowerBounds[newDim],\n coordinateSpace.bounds.upperBounds[newDim],\n );\n } else {\n newCoordinates[newDim] =\n prevCoordinates[oldDim] * (oldScales[oldDim] / newScales[newDim]);\n }\n }\n this.coordinates_ = newCoordinates;\n this.changed.dispatch();\n }\n\n toJSON() {\n if (!this.valid && this.coordinates_.length === 0) return undefined;\n this.handleCoordinateSpaceChanged();\n const { value } = this;\n if (value.length === 0) return undefined;\n return Array.from(value);\n }\n\n restoreState(obj: any) {\n if (obj === undefined) {\n this.reset();\n return;\n }\n this.curCoordinateSpace = undefined;\n this.coordinates_ = Float32Array.from(parseArray(obj, verifyFiniteFloat));\n this.handleCoordinateSpaceChanged();\n this.changed.dispatch();\n }\n\n snapToVoxel() {\n this.handleCoordinateSpaceChanged();\n const {\n bounds: { voxelCenterAtIntegerCoordinates },\n } = this.coordinateSpace.value;\n const { coordinates_ } = this;\n const rank = coordinates_.length;\n for (let i = 0; i < rank; ++i) {\n if (voxelCenterAtIntegerCoordinates[i]) {\n coordinates_[i] = Math.round(coordinates_[i]);\n } else {\n coordinates_[i] = Math.floor(coordinates_[i]) + 0.5;\n }\n }\n this.changed.dispatch();\n }\n\n assign(other: Borrowed) {\n other.handleCoordinateSpaceChanged();\n const { curCoordinateSpace, coordinates_ } = other;\n this.curCoordinateSpace = curCoordinateSpace;\n this.coordinates_ = Float32Array.from(coordinates_);\n this.changed.dispatch();\n }\n\n /**\n * Get the offset of `a` relative to `b`.\n */\n static getOffset(a: Position, b: Position): Float32Array | undefined {\n const aCoordinates = a.coordinates_;\n const bCoordinates = b.coordinates_;\n const rank = aCoordinates.length;\n if (rank === bCoordinates.length) {\n return vector.subtract(\n new Float32Array(aCoordinates.length),\n aCoordinates,\n bCoordinates,\n );\n }\n return undefined;\n }\n static addOffset(\n target: Position,\n source: Position,\n offset: Float32Array | undefined,\n scale = 1,\n ): void {\n target.handleCoordinateSpaceChanged();\n const { value: sourceCoordinates } = source;\n if (offset !== undefined && sourceCoordinates.length === offset.length) {\n vector.scaleAndAdd(target.value, sourceCoordinates, offset, scale);\n target.changed.dispatch();\n }\n }\n\n get legacyJsonView() {\n const self = this;\n return {\n changed: self.changed,\n toJSON() {\n return self.toJSON();\n },\n reset() {\n self.reset();\n },\n restoreState(obj: unknown) {\n if (obj === undefined || Array.isArray(obj)) {\n self.restoreState(obj);\n return;\n }\n verifyObject(obj);\n optionallyRestoreFromJsonMember(obj, \"voxelCoordinates\", self);\n },\n };\n }\n}\n\nexport enum VelocityBoundaryBehavior {\n STOP = 0,\n LOOP = 1,\n REVERSE = 2,\n}\n\nexport const DEFAULT_PLAYBACK_VELOCITY = 10;\n\nexport class DimensionPlaybackVelocity {\n // Velocity in global coordinates per second.\n velocity: number = DEFAULT_PLAYBACK_VELOCITY;\n atBoundary: VelocityBoundaryBehavior = VelocityBoundaryBehavior.REVERSE;\n paused = true;\n}\n\nexport function dimensionVelocitiesEqual(\n a: DimensionPlaybackVelocity,\n b: DimensionPlaybackVelocity,\n): boolean {\n return (\n a.velocity === b.velocity &&\n a.atBoundary === b.atBoundary &&\n a.paused === b.paused\n );\n}\n\nfunction dimensionVelocityFromJson(obj: unknown) {\n verifyObject(obj);\n return {\n velocity: verifyOptionalObjectProperty(\n obj,\n \"velocity\",\n verifyFiniteFloat,\n DEFAULT_PLAYBACK_VELOCITY,\n ),\n atBoundary: verifyOptionalObjectProperty(\n obj,\n \"atBoundary\",\n (value) => verifyEnumString(value, VelocityBoundaryBehavior),\n VelocityBoundaryBehavior.STOP,\n ),\n paused: verifyOptionalObjectProperty(obj, \"paused\", verifyBoolean, true),\n };\n}\n\nfunction dimensionVelocityToJson(info: DimensionPlaybackVelocity) {\n const { velocity, atBoundary, paused } = info;\n return {\n velocity: velocity,\n atBoundary:\n atBoundary === VelocityBoundaryBehavior.STOP\n ? undefined\n : VelocityBoundaryBehavior[atBoundary].toLowerCase(),\n paused: paused ? undefined : false,\n };\n}\n\nexport class CoordinateSpacePlaybackVelocity extends RefCounted {\n private velocities_: (Readonly | undefined)[];\n private curCoordinateSpace: CoordinateSpace | undefined;\n changed = new NullarySignal();\n constructor(\n public coordinateSpace: WatchableValueInterface,\n ) {\n super();\n this.registerDisposer(\n coordinateSpace.changed.add(() => {\n this.handleCoordinateSpaceChanged();\n }),\n );\n this.curCoordinateSpace = coordinateSpace.value;\n this.velocities_ = new Array(this.curCoordinateSpace?.rank ?? 0);\n }\n\n get valid() {\n return this.coordinateSpace.value.valid;\n }\n\n get value(): (Readonly | undefined)[] {\n this.handleCoordinateSpaceChanged();\n return this.velocities_;\n }\n\n set value(velocities: (Readonly | undefined)[]) {\n const { curCoordinateSpace } = this;\n if (\n curCoordinateSpace === undefined ||\n curCoordinateSpace.rank !== velocities.length\n ) {\n return;\n }\n this.velocities_ = velocities;\n this.changed.dispatch();\n }\n\n get(id: DimensionId): DimensionPlaybackVelocity | undefined {\n const ids = this.coordinateSpace.value?.ids;\n if (ids === undefined) return;\n const index = ids.indexOf(id);\n if (index === -1) return;\n const velocities = this.value;\n return velocities[index];\n }\n\n dimensionVelocity(\n owner: RefCounted,\n id: DimensionId,\n ): WatchableValueInterface {\n const changed = new NullarySignal();\n let index = -1;\n const updateIndex = () => {\n const ids = this.coordinateSpace.value?.ids;\n if (ids === undefined) {\n index = -1;\n } else if (index === -1 || ids[index] !== id) {\n index = ids.indexOf(id);\n }\n };\n const getVelocity = () => {\n updateIndex();\n if (index === -1) return undefined;\n return this.value[index];\n };\n const setVelocity = (\n newVelocity: Readonly | undefined,\n ) => {\n updateIndex();\n if (index === -1) return;\n const velocities = this.value;\n const oldVelocity = velocities[index];\n if (oldVelocity === newVelocity) return;\n velocities[index] = newVelocity;\n this.changed.dispatch();\n };\n const prevVelocity = getVelocity();\n owner.registerDisposer(\n this.changed.add(() => {\n const curVelocity = getVelocity();\n if (curVelocity !== prevVelocity) {\n changed.dispatch();\n }\n }),\n );\n return {\n get value() {\n return getVelocity();\n },\n set value(newVelocity: Readonly | undefined) {\n setVelocity(newVelocity);\n },\n changed,\n };\n }\n\n modifyDimension(\n id: DimensionId,\n callback: (\n oldInfo: DimensionPlaybackVelocity | undefined,\n ) => DimensionPlaybackVelocity | undefined,\n ) {\n const ids = this.coordinateSpace.value?.ids;\n if (ids === undefined) return;\n const index = ids.indexOf(id);\n if (index === -1) return;\n const velocities = this.value;\n const oldInfo = velocities[index];\n const newInfo = callback(oldInfo);\n if (oldInfo === newInfo) return;\n velocities[index] = newInfo;\n this.changed.dispatch();\n }\n\n togglePlayback(id: DimensionId, newValue: boolean | undefined = undefined) {\n this.modifyDimension(id, (oldInfo = new DimensionPlaybackVelocity()) => {\n return { ...oldInfo, paused: newValue ?? !oldInfo.paused };\n });\n }\n\n playbackEnabled(id: DimensionId): WatchableValueInterface {\n const self = this;\n return {\n changed: this.changed,\n get value() {\n return self.get(id) !== undefined;\n },\n set value(enabled: boolean) {\n self.modifyDimension(id, (oldInfo) =>\n enabled ? (oldInfo ?? new DimensionPlaybackVelocity()) : undefined,\n );\n },\n };\n }\n\n multiplyVelocity(id: DimensionId, factor: number) {\n this.modifyDimension(id, (oldInfo = new DimensionPlaybackVelocity()) => {\n let newVelocity = Math.round(oldInfo.velocity * factor);\n if (newVelocity === 0) {\n newVelocity = Math.sign(oldInfo.velocity) || 1;\n }\n return { ...oldInfo, velocity: newVelocity };\n });\n }\n\n private handleCoordinateSpaceChanged() {\n const coordinateSpace = this.coordinateSpace.value;\n const prevCoordinateSpace = this.curCoordinateSpace;\n if (coordinateSpace === prevCoordinateSpace) return;\n this.curCoordinateSpace = coordinateSpace;\n const { rank } = coordinateSpace;\n if (!coordinateSpace.valid) return;\n if (prevCoordinateSpace === undefined) {\n let { velocities_ } = this;\n if (velocities_.length === rank) {\n // Use the existing velocities if rank is the same. Otherwise, ignore.\n } else {\n velocities_ = new Array<\n Readonly | undefined\n >(rank);\n }\n this.changed.dispatch();\n return;\n }\n // Match dimensions by ID.\n const newVelocities = new Array<\n Readonly | undefined\n >(rank);\n const prevVelocities = this.velocities_;\n const { ids } = coordinateSpace;\n const { ids: prevDimensionIds } = prevCoordinateSpace;\n for (let newDim = 0; newDim < rank; ++newDim) {\n const newDimId = ids[newDim];\n const oldDim = prevDimensionIds.indexOf(newDimId);\n if (oldDim !== -1) {\n newVelocities[newDim] = prevVelocities[oldDim];\n }\n }\n this.velocities_ = newVelocities;\n this.changed.dispatch();\n }\n\n toJSON() {\n this.handleCoordinateSpaceChanged();\n const { velocities_: velocities, curCoordinateSpace } = this;\n if (\n !curCoordinateSpace?.valid ||\n !velocities.some((velocity) => velocity !== undefined)\n ) {\n return undefined;\n }\n const obj: Record = {};\n const { names, rank } = curCoordinateSpace;\n for (let i = 0; i < rank; ++i) {\n const info = velocities[i];\n if (info === undefined) continue;\n obj[names[i]] = dimensionVelocityToJson(info);\n }\n return obj;\n }\n\n reset() {\n this.handleCoordinateSpaceChanged();\n this.velocities_ = new Array(this.curCoordinateSpace?.rank ?? 0);\n }\n\n restoreState(obj: any) {\n if (obj === undefined) {\n this.reset();\n return;\n }\n verifyObject(obj);\n const curCoordinateSpace = (this.curCoordinateSpace =\n this.coordinateSpace.value);\n this.velocities_ = new Array(curCoordinateSpace?.rank ?? 0);\n if (curCoordinateSpace === undefined) {\n throw new Error(\"Must specify dimensions in order to specify velocities\");\n }\n const velocities = (this.velocities_ = new Array(\n curCoordinateSpace?.rank ?? 0,\n ));\n const { names } = curCoordinateSpace;\n for (const key of Object.keys(obj)) {\n const i = names.indexOf(key);\n if (i === -1) {\n throw new Error(`Invalid dimension name: ${JSON.stringify(key)}`);\n }\n velocities[i] = verifyObjectProperty(obj, key, dimensionVelocityFromJson);\n }\n this.changed.dispatch();\n }\n\n assign(other: Borrowed) {\n const otherVelocities = other.value;\n const velocities = this.value;\n const rank = velocities.length;\n let changed = false;\n for (let i = 0; i < rank; ++i) {\n const newVelocity = otherVelocities[i];\n const curVelocity = velocities[i];\n if (newVelocity !== curVelocity) {\n if (\n curVelocity === undefined ||\n newVelocity === undefined ||\n !dimensionVelocitiesEqual(curVelocity, newVelocity)\n ) {\n changed = true;\n }\n velocities[i] = newVelocity;\n }\n }\n if (changed) {\n this.changed.dispatch();\n }\n }\n}\n\nexport class LinkedCoordinateSpacePlaybackVelocity extends RefCounted {\n changed = new NullarySignal();\n velocity = this.registerDisposer(\n new CoordinateSpacePlaybackVelocity(this.peer.coordinateSpace),\n );\n\n constructor(\n public peer: Owned,\n public positionLink: TrackableLinkInterface,\n ) {\n super();\n this.registerDisposer(peer);\n this.velocity.changed.add(() => {\n if (this.positionLink.value === NavigationLinkType.UNLINKED) {\n this.changed.dispatch();\n } else {\n this.peer.assign(this.velocity);\n }\n });\n const updateSelf = () => {\n if (this.positionLink.value !== NavigationLinkType.UNLINKED) {\n this.velocity.assign(this.peer);\n }\n };\n this.registerDisposer(peer.changed.add(updateSelf));\n updateSelf();\n }\n\n toJSON() {\n if (this.positionLink.value !== NavigationLinkType.UNLINKED) {\n return undefined;\n }\n return this.velocity.toJSON();\n }\n\n reset() {\n if (this.positionLink.value === NavigationLinkType.UNLINKED) {\n this.velocity.reset();\n }\n }\n\n restoreState(obj: unknown) {\n if (this.positionLink.value === NavigationLinkType.UNLINKED) {\n this.velocity.restoreState(obj);\n }\n }\n\n copyToPeer() {\n if (this.positionLink.value === NavigationLinkType.UNLINKED) {\n this.peer.assign(this.velocity);\n }\n }\n}\n\ninterface DimensionPlaybackState {\n dimensionIndex: number;\n prevCoordinate: number;\n prevTime: number;\n generation: number;\n}\n\nexport class PlaybackManager extends RefCounted {\n private dimensionStates = new Map();\n private lastUpdateGeneration = 0;\n private unregisterUpdateStartedCallback: (() => void) | undefined;\n\n constructor(\n public display: { updateStarted: NullarySignal; scheduleRedraw(): void },\n public position: Position,\n public velocity: CoordinateSpacePlaybackVelocity,\n ) {\n super();\n this.handleVelocityChanged();\n this.registerDisposer(\n velocity.changed.add(() => this.handleVelocityChanged()),\n );\n }\n\n disposed() {\n this.unregisterUpdateStartedCallback?.();\n super.disposed();\n }\n\n private handleVelocityChanged() {\n const { dimensionStates } = this;\n const ids = this.position.coordinateSpace.value?.ids ?? [];\n const rank = ids.length;\n const velocities = this.velocity.value;\n const generation = ++this.lastUpdateGeneration;\n const positionVector = this.position.value;\n const curTime = Date.now();\n for (let i = 0; i < rank; ++i) {\n const velocity = velocities[i];\n if (velocity === undefined) continue;\n if (velocity.velocity === 0 || velocity.paused) continue;\n const id = ids[i];\n const state = dimensionStates.get(id);\n if (state === undefined) {\n dimensionStates.set(id, {\n prevTime: curTime,\n dimensionIndex: i,\n prevCoordinate: positionVector[i],\n generation,\n });\n } else {\n state.generation = generation;\n state.dimensionIndex = i;\n }\n }\n for (const [id, state] of dimensionStates) {\n if (state.generation !== generation) {\n dimensionStates.delete(id);\n }\n }\n if (dimensionStates.size === 0) {\n const { unregisterUpdateStartedCallback } = this;\n if (unregisterUpdateStartedCallback !== undefined) {\n unregisterUpdateStartedCallback();\n this.unregisterUpdateStartedCallback = undefined;\n }\n } else {\n if (this.unregisterUpdateStartedCallback === undefined) {\n this.unregisterUpdateStartedCallback = this.display.updateStarted.add(\n () => this.updateStarted(),\n );\n this.display.scheduleRedraw();\n }\n }\n }\n\n private updateStarted() {\n const coordinateSpace = this.position.coordinateSpace.value;\n if (coordinateSpace === undefined) {\n return;\n }\n const ids = coordinateSpace.ids;\n const positionVector = this.position.value;\n let positionChanged = false;\n let velocityChanged = false;\n const curTime = Date.now();\n const velocities = this.velocity.value;\n const {\n bounds: { lowerBounds, upperBounds },\n } = coordinateSpace;\n for (const [id, dimensionState] of this.dimensionStates) {\n const { dimensionIndex } = dimensionState;\n if (ids[dimensionIndex] !== id) continue;\n const velocity = velocities[dimensionIndex];\n if (\n Math.floor(positionVector[dimensionIndex]) !==\n Math.floor(dimensionState.prevCoordinate)\n ) {\n // Pause this dimension.\n if (velocity?.paused === false) {\n velocities[dimensionIndex] = { ...velocity, paused: true };\n velocityChanged = true;\n }\n continue;\n }\n const timeDelta = curTime - dimensionState.prevTime;\n const velocityValue = velocity?.velocity ?? 0;\n const delta = (timeDelta * velocityValue) / 1000;\n if (delta === 0) continue;\n let newCoordinate = positionVector[dimensionIndex] + delta;\n const lowerBound = lowerBounds[dimensionIndex];\n const upperBound = Math.ceil(upperBounds[dimensionIndex] - 1);\n const limit = delta > 0 ? upperBound : lowerBound;\n const oppositeLimit = delta > 0 ? lowerBound : upperBound;\n const deltaSign = Math.sign(delta);\n if (\n Number.isFinite(limit) &&\n newCoordinate * deltaSign >= limit * deltaSign\n ) {\n switch (velocity!.atBoundary) {\n case VelocityBoundaryBehavior.LOOP:\n if (Number.isFinite(oppositeLimit)) {\n newCoordinate = oppositeLimit;\n break;\n }\n // fallthrough\n case VelocityBoundaryBehavior.STOP:\n velocities[dimensionIndex] = { ...velocity!, paused: true };\n velocityChanged = true;\n newCoordinate = limit;\n break;\n case VelocityBoundaryBehavior.REVERSE:\n velocities[dimensionIndex] = {\n ...velocity!,\n velocity: -velocityValue,\n };\n velocityChanged = true;\n newCoordinate = limit;\n break;\n }\n }\n positionVector[dimensionIndex] = newCoordinate;\n dimensionState.prevCoordinate = positionVector[dimensionIndex];\n dimensionState.prevTime = curTime;\n positionChanged = true;\n }\n if (positionChanged) {\n this.position.changed.dispatch();\n }\n if (velocityChanged) {\n this.velocity.changed.dispatch();\n }\n this.display.scheduleRedraw();\n }\n}\n\ntype TrackableLinkInterface =\n | TrackableNavigationLink\n | TrackableNavigationSimpleLink;\n\nfunction restoreLinkedFromJson(\n link: TrackableLinkInterface,\n value: { restoreState(obj: unknown): void },\n json: any,\n) {\n if (json === undefined || Object.keys(json).length === 0) {\n link.value = NavigationLinkType.LINKED;\n return;\n }\n verifyObject(json);\n link.value = NavigationLinkType.UNLINKED;\n verifyObjectProperty(json, \"value\", (x) => {\n if (x !== undefined) {\n value.restoreState(x);\n }\n });\n verifyObjectProperty(json, \"link\", (x) => link.restoreState(x));\n}\n\ninterface LinkableState extends RefCounted, Trackable {\n assign(other: T): void;\n}\n\nabstract class LinkedBase<\n T extends LinkableState,\n Link extends TrackableLinkInterface = TrackableNavigationLink,\n> implements Trackable\n{\n value: T;\n get changed() {\n return this.value.changed;\n }\n constructor(\n public peer: Owned,\n public link: Link = new TrackableNavigationLink() as any,\n ) {}\n\n toJSON() {\n const { link } = this;\n if (link.value === NavigationLinkType.LINKED) {\n return undefined;\n }\n return { link: link.toJSON(), value: this.getValueJson() };\n }\n\n protected getValueJson(): any {\n return this.value.toJSON();\n }\n\n reset() {\n this.link.value = NavigationLinkType.LINKED;\n }\n\n restoreState(obj: any) {\n restoreLinkedFromJson(this.link, this.value, obj);\n }\n\n copyToPeer() {\n if (this.link.value !== NavigationLinkType.LINKED) {\n this.link.value = NavigationLinkType.UNLINKED;\n this.peer.assign(this.value);\n this.link.value = NavigationLinkType.LINKED;\n }\n }\n}\n\nabstract class SimpleLinkedBase<\n T extends RefCounted & Trackable & { assign(other: T): void },\n >\n extends LinkedBase\n implements Trackable {}\n\nexport class LinkedPosition extends LinkedBase {\n value = makeLinked(\n new Position(this.peer.coordinateSpace),\n this.peer,\n this.link,\n {\n assign: (a: Position, b: Position) => a.assign(b),\n isValid: (a: Position) => {\n return a.valid;\n },\n difference: Position.getOffset,\n add: Position.addOffset,\n subtract: (\n target: Position,\n source: Position,\n amount: Float32Array | undefined,\n ) => {\n Position.addOffset(target, source, amount, -1);\n },\n },\n );\n}\n\nfunction quaternionIsIdentity(q: quat) {\n return q[0] === 0 && q[1] === 0 && q[2] === 0 && q[3] === 1;\n}\n\nexport class OrientationState extends RefCounted {\n orientation: quat;\n changed = new NullarySignal();\n\n constructor(orientation?: quat) {\n super();\n if (orientation == null) {\n orientation = quat.create();\n }\n this.orientation = orientation;\n }\n toJSON() {\n const { orientation } = this;\n quat.normalize(this.orientation, this.orientation);\n if (quaternionIsIdentity(orientation)) {\n return undefined;\n }\n return Array.prototype.slice.call(this.orientation);\n }\n restoreState(obj: any) {\n try {\n parseFiniteVec(this.orientation, obj);\n quat.normalize(this.orientation, this.orientation);\n } catch (ignoredError) {\n quat.identity(this.orientation);\n }\n this.changed.dispatch();\n }\n\n reset() {\n quat.identity(this.orientation);\n this.changed.dispatch();\n }\n\n snap() {\n const mat = mat3.create();\n mat3.fromQuat(mat, this.orientation);\n const usedAxes = [false, false, false];\n for (let i = 0; i < 3; ++i) {\n let maxComponent = 0;\n let argmaxComponent = 0;\n for (let j = 0; j < 3; ++j) {\n const value = mat[i * 3 + j];\n mat[i * 3 + j] = 0;\n if (usedAxes[j]) {\n continue;\n }\n if (Math.abs(value) > Math.abs(maxComponent)) {\n maxComponent = value;\n argmaxComponent = j;\n }\n }\n mat[i * 3 + argmaxComponent] = Math.sign(maxComponent);\n usedAxes[argmaxComponent] = true;\n }\n quat.fromMat3(this.orientation, mat);\n this.changed.dispatch();\n }\n\n /**\n * Returns a new OrientationState with orientation fixed to peerToSelf * peer.orientation. Any\n * changes to the returned OrientationState will cause a corresponding change in peer, and vice\n * versa.\n */\n static makeRelative(peer: OrientationState, peerToSelf: quat) {\n const self = new OrientationState(\n quat.multiply(quat.create(), peer.orientation, peerToSelf),\n );\n let updatingPeer = false;\n self.registerDisposer(\n peer.changed.add(() => {\n if (!updatingPeer) {\n updatingSelf = true;\n quat.multiply(self.orientation, peer.orientation, peerToSelf);\n self.changed.dispatch();\n updatingSelf = false;\n }\n }),\n );\n let updatingSelf = false;\n const selfToPeer = quat.invert(quat.create(), peerToSelf);\n self.registerDisposer(\n self.changed.add(() => {\n if (!updatingSelf) {\n updatingPeer = true;\n quat.multiply(peer.orientation, self.orientation, selfToPeer);\n peer.changed.dispatch();\n updatingPeer = false;\n }\n }),\n );\n return self;\n }\n\n assign(other: Borrowed) {\n quat.copy(this.orientation, other.orientation);\n this.changed.dispatch();\n }\n}\n\nexport class LinkedOrientationState extends LinkedBase {\n value = makeLinked(new OrientationState(), this.peer, this.link, {\n assign: (a: OrientationState, b: OrientationState) => a.assign(b),\n isValid: () => true,\n difference: (a: OrientationState, b: OrientationState) => {\n const temp = quat.create();\n return quat.multiply(\n temp,\n quat.invert(temp, b.orientation),\n a.orientation,\n );\n },\n add: (target: OrientationState, source: OrientationState, amount: quat) => {\n quat.multiply(target.orientation, source.orientation, amount);\n target.changed.dispatch();\n },\n subtract: (\n target: OrientationState,\n source: OrientationState,\n amount: quat,\n ) => {\n quat.multiply(\n target.orientation,\n source.orientation,\n quat.invert(tempQuat, amount),\n );\n target.changed.dispatch();\n },\n });\n}\n\nexport interface RelativeDisplayScales {\n /**\n * Array of length `coordinateSpace.rank` specifying scale factors on top of (will be multiply by)\n * `coordinateSpace.scales` to use for display purposes. This allows non-uniform zooming.\n */\n factors: Float64Array;\n}\n\nexport class TrackableRelativeDisplayScales\n extends RefCounted\n implements Trackable, WatchableValueInterface\n{\n changed = new NullarySignal();\n private curCoordinateSpace = emptyInvalidCoordinateSpace;\n private value_: RelativeDisplayScales = { factors: new Float64Array(0) };\n constructor(\n public coordinateSpace: WatchableValueInterface,\n ) {\n super();\n this.registerDisposer(coordinateSpace.changed.add(() => this.update()));\n this.update();\n }\n\n get value() {\n return this.update();\n }\n\n reset() {\n this.value_ = { factors: new Float64Array(0) };\n this.curCoordinateSpace = emptyInvalidCoordinateSpace;\n this.changed.dispatch();\n }\n\n toJSON() {\n const json: any = {};\n let nonEmpty = false;\n const { value } = this;\n const { factors } = value;\n const { names, rank } = this.curCoordinateSpace;\n for (let i = 0; i < rank; ++i) {\n const factor = factors[i];\n if (factor === 1) continue;\n json[names[i]] = factor;\n nonEmpty = true;\n }\n if (nonEmpty) return json;\n return undefined;\n }\n\n restoreState(json: unknown) {\n const {\n coordinateSpace: { value: coordinateSpace },\n } = this;\n const { names, rank } = coordinateSpace;\n const factors = new Float64Array(rank);\n factors.fill(-1);\n if (json !== undefined) {\n const obj = verifyObject(json);\n for (let i = 0; i < rank; ++i) {\n factors[i] = verifyObjectProperty(obj, names[i], (x) =>\n x === undefined ? 1 : verifyFinitePositiveFloat(x),\n );\n }\n }\n this.value_ = { factors };\n this.curCoordinateSpace = coordinateSpace;\n this.changed.dispatch();\n }\n\n setFactors(factors: Float64Array) {\n const {\n coordinateSpace: { value: coordinateSpace },\n } = this;\n if (factors.length !== coordinateSpace.rank) return;\n this.value_ = { factors };\n this.curCoordinateSpace = coordinateSpace;\n this.changed.dispatch();\n }\n\n private update() {\n const {\n coordinateSpace: { value: coordinateSpace },\n } = this;\n let value = this.value_;\n const { curCoordinateSpace } = this;\n if (curCoordinateSpace === coordinateSpace) return value;\n const { ids: oldDimensionIds } = curCoordinateSpace;\n const { ids: newDimensionIds, rank } = coordinateSpace;\n const oldFactors = value.factors;\n const newFactors = new Float64Array(rank);\n newFactors.fill(1);\n for (let i = 0; i < rank; ++i) {\n const id = newDimensionIds[i];\n const oldIndex = oldDimensionIds.indexOf(id);\n if (oldIndex === -1) continue;\n newFactors[i] = oldFactors[oldIndex];\n }\n if (arraysEqual(newFactors, oldFactors)) return value;\n value = this.value_ = { factors: newFactors };\n this.curCoordinateSpace = coordinateSpace;\n this.changed.dispatch();\n return value;\n }\n\n assign(other: TrackableRelativeDisplayScales) {\n this.setFactors(other.value.factors);\n }\n}\n\nfunction mapPerDimensionValues<\n T,\n A extends { length: number; [index: number]: T },\n C extends { new (n: number): A },\n>(\n arrayConstructor: C,\n input: A,\n oldCoordinateSpace: CoordinateSpace,\n newCoordinateSpace: CoordinateSpace,\n defaultValue: (index: number) => T,\n): A {\n if (oldCoordinateSpace === newCoordinateSpace) return input;\n const { ids: oldDimensionIds } = oldCoordinateSpace;\n const { rank: newRank, ids: newDimensionIds } = newCoordinateSpace;\n const output = new arrayConstructor(newRank);\n for (let newDim = 0; newDim < newRank; ++newDim) {\n const id = newDimensionIds[newDim];\n const oldDim = oldDimensionIds.indexOf(id);\n output[newDim] = oldDim === -1 ? defaultValue(newDim) : input[oldDim];\n }\n return output;\n}\n\nexport class LinkedRelativeDisplayScales extends LinkedBase {\n value = makeLinked(\n new TrackableRelativeDisplayScales(this.peer.coordinateSpace),\n this.peer,\n this.link,\n {\n assign: (target, source) => target.assign(source),\n difference: (a, b) => {\n const { factors: fa } = a.value;\n const coordinateSpace = a.coordinateSpace.value;\n const fb = b.value.factors;\n return {\n coordinateSpace,\n offsets: vector.subtract(new Float64Array(fa.length), fa, fb),\n };\n },\n add: (\n target,\n source,\n delta: { offsets: Float64Array; coordinateSpace: CoordinateSpace },\n ) => {\n const newOffsets = mapPerDimensionValues(\n Float64Array,\n delta.offsets,\n delta.coordinateSpace,\n target.coordinateSpace.value,\n () => 0,\n );\n target.setFactors(\n vector.add(\n new Float64Array(newOffsets.length),\n newOffsets,\n source.value.factors,\n ),\n );\n },\n subtract: (\n target,\n source,\n delta: { offsets: Float64Array; coordinateSpace: CoordinateSpace },\n ) => {\n const newOffsets = mapPerDimensionValues(\n Float64Array,\n delta.offsets,\n delta.coordinateSpace,\n target.coordinateSpace.value,\n () => 0,\n );\n target.setFactors(\n vector.subtract(\n new Float64Array(newOffsets.length),\n source.value.factors,\n newOffsets,\n ),\n );\n },\n isValid: () => true,\n },\n );\n}\n\nexport interface DisplayDimensionRenderInfo {\n /**\n * Number of global dimensions.\n */\n globalRank: number;\n\n /**\n * Array of length `globalRank` specifying global dimension names.\n */\n globalDimensionNames: readonly string[];\n\n /**\n * Number of displayed dimensions. Must be <= 3.\n */\n displayRank: number;\n\n /**\n * Array of length 3. The first `displayRank` elements specify the indices of the the global\n * dimensions that are displayed. The remaining elements are `-1`.\n */\n displayDimensionIndices: Int32Array;\n\n /**\n * Array of length 3. `voxelPhysicalScales[i]` equals\n * `relativeDisplayScales[d] * coordinateSpace.scales[d]`,\n * where `d = displayDimensionIndices[i]`, or `1` for `i >= rank`.\n */\n voxelPhysicalScales: Float64Array;\n\n /**\n * Unit corresponding to each dimension in `displayDimensionIndices`. `displayDimensionUnits[i]`\n * is equal to `coordinateSpace.units[displayDimensionIndices[i]]`, or `''` if\n * `displayDimensionIndices[i] == -1`.\n */\n displayDimensionUnits: readonly string[];\n\n /**\n * Scale corresponding to each dimension in `displayDimensionIndices`.\n * `displayDimensionScales[i]` is equal to `coordinateSpace.scales[displayDimensionIndices[i]]`,\n * or `1` if `displayDimensionIndices[i] == -1`.\n */\n displayDimensionScales: Float64Array;\n\n /**\n * Physical scale corresponding to the canonical voxel. Equal to minimum of\n * `voxelPhysicalScales.slice(0, rank)`, or `1` if `rank == 0`.\n */\n canonicalVoxelPhysicalSize: number;\n\n /**\n * Array of length 3. Amount by which the voxel coordinates of each display dimensions must be\n * multiplied to convert to canonical voxels. canonicalVoxelFactors[i] = voxelPhysicalScales[d] /\n * canonicalVoxelPhysicalSize, where d = dimensionIndices[i], or `1` for `i >= rank`.\n */\n canonicalVoxelFactors: Float64Array;\n}\n\nfunction getDisplayDimensionRenderInfo(\n coordinateSpace: CoordinateSpace,\n displayDimensions: DisplayDimensions,\n relativeDisplayScales: RelativeDisplayScales,\n): DisplayDimensionRenderInfo {\n const {\n rank: globalRank,\n names: globalDimensionNames,\n units,\n } = coordinateSpace;\n const { displayRank, displayDimensionIndices } = displayDimensions;\n const canonicalVoxelFactors = new Float64Array(3);\n const voxelPhysicalScales = new Float64Array(3);\n let canonicalVoxelPhysicalSize: number;\n const { factors } = relativeDisplayScales;\n const displayDimensionUnits = new Array(3);\n const displayDimensionScales = new Float64Array(3);\n canonicalVoxelFactors.fill(1);\n voxelPhysicalScales.fill(1);\n displayDimensionScales.fill(1);\n displayDimensionUnits.fill(\"\");\n if (displayRank === 0) {\n canonicalVoxelPhysicalSize = 1;\n } else {\n canonicalVoxelPhysicalSize = Number.POSITIVE_INFINITY;\n const { scales } = coordinateSpace;\n for (let i = 0; i < displayRank; ++i) {\n const dim = displayDimensionIndices[i];\n const s = (voxelPhysicalScales[i] = factors[dim] * scales[dim]);\n canonicalVoxelPhysicalSize = Math.min(canonicalVoxelPhysicalSize, s);\n displayDimensionUnits[i] = units[dim];\n displayDimensionScales[i] = scales[dim];\n }\n for (let i = 0; i < displayRank; ++i) {\n canonicalVoxelFactors[i] =\n voxelPhysicalScales[i] / canonicalVoxelPhysicalSize;\n }\n }\n return {\n globalRank,\n globalDimensionNames,\n displayRank,\n displayDimensionIndices,\n displayDimensionUnits,\n displayDimensionScales,\n canonicalVoxelFactors,\n voxelPhysicalScales,\n canonicalVoxelPhysicalSize,\n };\n}\n\nexport function displayDimensionRenderInfosEqual(\n a: DisplayDimensionRenderInfo,\n b: DisplayDimensionRenderInfo,\n) {\n return (\n arraysEqual(a.globalDimensionNames, b.globalDimensionNames) &&\n arraysEqual(a.displayDimensionIndices, b.displayDimensionIndices) &&\n arraysEqual(a.canonicalVoxelFactors, b.canonicalVoxelFactors) &&\n arraysEqual(a.voxelPhysicalScales, b.voxelPhysicalScales) &&\n a.canonicalVoxelPhysicalSize === b.canonicalVoxelPhysicalSize &&\n arraysEqual(a.displayDimensionUnits, b.displayDimensionUnits) &&\n arraysEqual(a.displayDimensionScales, b.displayDimensionScales)\n );\n}\n\nexport function validateDisplayDimensionRenderInfoProperty(\n obj: { displayDimensionRenderInfo: DisplayDimensionRenderInfo },\n expected: DisplayDimensionRenderInfo,\n): boolean {\n const actual = obj.displayDimensionRenderInfo;\n if (actual === expected) return true;\n if (displayDimensionRenderInfosEqual(actual, expected)) {\n obj.displayDimensionRenderInfo = expected;\n return true;\n }\n return false;\n}\n\nexport class WatchableDisplayDimensionRenderInfo extends RefCounted {\n changed = new NullarySignal();\n private curRelativeDisplayScales: RelativeDisplayScales =\n this.relativeDisplayScales.value;\n private curDisplayDimensions: DisplayDimensions =\n this.displayDimensions.value;\n private curCoordinateSpace: CoordinateSpace =\n this.relativeDisplayScales.coordinateSpace.value;\n private value_: DisplayDimensionRenderInfo = getDisplayDimensionRenderInfo(\n this.curCoordinateSpace,\n this.curDisplayDimensions,\n this.curRelativeDisplayScales,\n );\n get value() {\n const {\n relativeDisplayScales: {\n value: relativeDisplayScales,\n coordinateSpace: { value: coordinateSpace },\n },\n displayDimensions: { value: displayDimensions },\n curRelativeDisplayScales,\n curDisplayDimensions,\n curCoordinateSpace,\n } = this;\n let value = this.value_;\n if (\n curRelativeDisplayScales !== relativeDisplayScales ||\n curDisplayDimensions !== displayDimensions ||\n curCoordinateSpace !== coordinateSpace\n ) {\n this.curRelativeDisplayScales = relativeDisplayScales;\n this.curDisplayDimensions = displayDimensions;\n this.curCoordinateSpace = coordinateSpace;\n const newValue = getDisplayDimensionRenderInfo(\n coordinateSpace,\n displayDimensions,\n relativeDisplayScales,\n );\n if (!displayDimensionRenderInfosEqual(value, newValue)) {\n this.value_ = value = newValue;\n this.changed.dispatch();\n }\n }\n return value;\n }\n constructor(\n public relativeDisplayScales: Owned,\n public displayDimensions: Owned,\n ) {\n super();\n this.registerDisposer(relativeDisplayScales);\n this.registerDisposer(displayDimensions);\n const maybeUpdateValue = () => {\n this.value;\n };\n this.registerDisposer(relativeDisplayScales.changed.add(maybeUpdateValue));\n this.registerDisposer(displayDimensions.changed.add(maybeUpdateValue));\n }\n}\n\nexport interface DisplayDimensions {\n coordinateSpace: CoordinateSpace;\n displayRank: number;\n displayDimensionIndices: Int32Array;\n}\n\nexport class TrackableDisplayDimensions\n extends RefCounted\n implements Trackable\n{\n changed = new NullarySignal();\n private default_ = true;\n private value_: DisplayDimensions | undefined = undefined;\n\n constructor(\n public coordinateSpace: WatchableValueInterface,\n ) {\n super();\n this.registerDisposer(\n this.coordinateSpace.changed.add(this.changed.dispatch),\n );\n this.update();\n }\n\n get value() {\n this.update();\n return this.value_!;\n }\n\n private update() {\n const {\n coordinateSpace: { value: coordinateSpace },\n } = this;\n const value = this.value_;\n if (value !== undefined && value.coordinateSpace === coordinateSpace) {\n return;\n }\n if (value === undefined || this.default_) {\n this.setToDefault(coordinateSpace);\n return;\n }\n const newDimensionIndices = new Int32Array(3);\n const { ids: oldDimensionIds } = value.coordinateSpace;\n const { ids: newDimensionIds } = coordinateSpace;\n const oldDimensionIndices = value.displayDimensionIndices;\n const oldRank = value.displayRank;\n let newRank = 0;\n for (let i = 0; i < oldRank; ++i) {\n const newDim = newDimensionIds.indexOf(\n oldDimensionIds[oldDimensionIndices[i]],\n );\n if (newDim === -1) continue;\n newDimensionIndices[newRank] = newDim;\n ++newRank;\n }\n newDimensionIndices.fill(-1, newRank);\n if (newRank === 0) {\n this.default_ = true;\n this.setToDefault(coordinateSpace);\n return;\n }\n this.assignValue(coordinateSpace, newRank, newDimensionIndices);\n this.changed.dispatch();\n }\n\n private setToDefault(coordinateSpace: CoordinateSpace) {\n const displayRank = Math.min(coordinateSpace.rank, 3);\n const displayDimensionIndices = new Int32Array(3);\n displayDimensionIndices.fill(-1);\n for (let i = 0; i < displayRank; ++i) {\n displayDimensionIndices[i] = i;\n }\n this.assignValue(coordinateSpace, displayRank, displayDimensionIndices);\n }\n\n private assignValue(\n coordinateSpace: CoordinateSpace,\n displayRank: number,\n displayDimensionIndices: Int32Array,\n ) {\n this.value_ = {\n coordinateSpace,\n displayRank,\n displayDimensionIndices,\n };\n this.changed.dispatch();\n }\n\n reset() {\n this.default_ = true;\n this.value_ = undefined;\n this.changed.dispatch();\n }\n\n restoreState(obj: any) {\n if (obj === undefined) {\n this.reset();\n return;\n }\n const displayDimensionNames = dimensionNamesFromJson(obj);\n if (displayDimensionNames.length > 3) {\n throw new Error(\"Number of spatial dimensions must be <= 3\");\n }\n const {\n coordinateSpace: { value: coordinateSpace },\n } = this;\n const displayDimensionIndices = new Int32Array(3);\n displayDimensionIndices.fill(-1);\n const { names } = coordinateSpace;\n let displayRank = 0;\n for (const name of displayDimensionNames) {\n const index = names.indexOf(name);\n if (index === -1) continue;\n displayDimensionIndices[displayRank++] = index;\n }\n if (displayRank === 0) {\n this.reset();\n return;\n }\n this.default_ = false;\n this.assignValue(coordinateSpace, displayRank, displayDimensionIndices);\n }\n\n get default() {\n this.update();\n return this.default_;\n }\n\n set default(value: boolean) {\n if (this.default_ === value) return;\n if (value) {\n this.default_ = true;\n this.setToDefault(this.coordinateSpace.value);\n } else {\n this.default_ = false;\n this.changed.dispatch();\n }\n }\n\n setDimensionIndices(rank: number, dimensionIndices: Int32Array) {\n this.default_ = false;\n this.assignValue(this.coordinateSpace.value, rank, dimensionIndices);\n }\n\n toJSON() {\n if (this.default_) return undefined;\n const { value } = this;\n const displayDimensionNames: string[] = [];\n const {\n displayRank,\n displayDimensionIndices,\n coordinateSpace: { names },\n } = value;\n if (displayRank === 0) return undefined;\n for (let i = 0; i < displayRank; ++i) {\n displayDimensionNames[i] = names[displayDimensionIndices[i]];\n }\n return displayDimensionNames;\n }\n\n assign(other: TrackableDisplayDimensions) {\n if (other.default) {\n this.default = true;\n } else {\n const { displayRank, displayDimensionIndices } = other.value;\n this.setDimensionIndices(displayRank, displayDimensionIndices);\n }\n }\n}\n\nexport class LinkedDisplayDimensions extends SimpleLinkedBase {\n value = makeSimpleLinked(\n new TrackableDisplayDimensions(this.peer.coordinateSpace),\n this.peer,\n this.link,\n {\n assign: (target, source) => target.assign(source),\n isValid: () => true,\n },\n );\n}\n\nexport class DisplayPose extends RefCounted {\n changed = new NullarySignal();\n\n get displayDimensions(): Borrowed {\n return this.displayDimensionRenderInfo.displayDimensions;\n }\n\n get relativeDisplayScales(): Borrowed {\n return this.displayDimensionRenderInfo.relativeDisplayScales;\n }\n\n constructor(\n public position: Owned,\n public displayDimensionRenderInfo: WatchableDisplayDimensionRenderInfo,\n public orientation: Owned,\n ) {\n super();\n this.registerDisposer(position);\n this.registerDisposer(orientation);\n this.registerDisposer(displayDimensionRenderInfo);\n this.registerDisposer(position.changed.add(this.changed.dispatch));\n this.registerDisposer(orientation.changed.add(this.changed.dispatch));\n this.registerDisposer(\n displayDimensionRenderInfo.changed.add(this.changed.dispatch),\n );\n }\n\n get valid() {\n return this.position.valid;\n }\n\n /**\n * Resets everything.\n */\n reset() {\n this.position.reset();\n this.orientation.reset();\n this.displayDimensions.reset();\n }\n\n updateDisplayPosition(\n fun: (pos: vec3) => boolean | void,\n temp: vec3 = tempVec3,\n ): boolean {\n const {\n coordinateSpace: { value: coordinateSpace },\n value: voxelCoordinates,\n } = this.position;\n const { displayDimensionIndices, displayRank } =\n this.displayDimensions.value;\n if (coordinateSpace === undefined) return false;\n temp.fill(0);\n for (let i = 0; i < displayRank; ++i) {\n const dim = displayDimensionIndices[i];\n temp[i] = voxelCoordinates[dim];\n }\n if (fun(temp) !== false) {\n for (let i = 0; i < displayRank; ++i) {\n const dim = displayDimensionIndices[i];\n voxelCoordinates[dim] = temp[i];\n }\n this.position.changed.dispatch();\n return true;\n }\n return false;\n }\n\n // Transform from view coordinates to global spatial coordinates.\n toMat4(mat: mat4, zoom: number) {\n mat4.fromQuat(mat, this.orientation.orientation);\n const { value: voxelCoordinates } = this.position;\n const { canonicalVoxelFactors, displayDimensionIndices } =\n this.displayDimensionRenderInfo.value;\n for (let i = 0; i < 3; ++i) {\n const dim = displayDimensionIndices[i];\n const scale = zoom / canonicalVoxelFactors[i];\n mat[i] *= scale;\n mat[4 + i] *= scale;\n mat[8 + i] *= scale;\n mat[12 + i] = voxelCoordinates[dim] || 0;\n }\n }\n\n toMat3(mat: mat3, zoom: number) {\n mat3.fromQuat(mat, this.orientation.orientation);\n const { canonicalVoxelFactors, displayRank } =\n this.displayDimensionRenderInfo.value;\n for (let i = 0; i < displayRank; ++i) {\n const scale = zoom / canonicalVoxelFactors[i];\n mat[i] *= scale;\n mat[3 + i] *= scale;\n mat[6 + i] *= scale;\n }\n }\n\n /**\n * Snaps the orientation to the nearest axis-aligned orientation, and\n * snaps the position to the nearest voxel.\n */\n snap() {\n this.orientation.snap();\n this.position.snapToVoxel();\n this.changed.dispatch();\n }\n\n translateDimensionRelative(dimensionIndex: number, adjustment: number) {\n if (!this.valid) {\n return;\n }\n const { position } = this;\n const { value: voxelCoordinates } = position;\n const { bounds } = position.coordinateSpace.value;\n voxelCoordinates[dimensionIndex] = clampAndRoundCoordinateToVoxelCenter(\n bounds,\n dimensionIndex,\n voxelCoordinates[dimensionIndex] + adjustment,\n );\n position.changed.dispatch();\n }\n\n translateVoxelsRelative(translation: vec3) {\n if (!this.valid) {\n return;\n }\n const temp = vec3.transformQuat(\n tempVec3,\n translation,\n this.orientation.orientation,\n );\n const { position } = this;\n const { value: voxelCoordinates } = position;\n const { displayDimensionIndices, displayRank } =\n this.displayDimensions.value;\n const { bounds } = position.coordinateSpace.value;\n for (let i = 0; i < displayRank; ++i) {\n const dim = displayDimensionIndices[i];\n const adjustment = temp[i];\n if (adjustment === 0) continue;\n voxelCoordinates[dim] = clampAndRoundCoordinateToVoxelCenter(\n bounds,\n dim,\n voxelCoordinates[dim] + adjustment,\n );\n }\n this.position.changed.dispatch();\n }\n\n rotateRelative(axis: vec3, angle: number) {\n const temp = quat.create();\n quat.setAxisAngle(temp, axis, angle);\n const orientation = this.orientation.orientation;\n quat.multiply(orientation, orientation, temp);\n this.orientation.changed.dispatch();\n }\n\n rotateAbsolute(axis: vec3, angle: number, fixedPoint: Float32Array) {\n const {\n coordinateSpace: { value: coordinateSpace },\n value: voxelCoordinates,\n } = this.position;\n if (coordinateSpace === undefined) return;\n const {\n relativeDisplayScales: {\n value: { factors: relativeDisplayScales },\n },\n displayDimensions: {\n value: { displayDimensionIndices, displayRank },\n },\n } = this;\n const { scales } = coordinateSpace;\n const temp = quat.create();\n quat.setAxisAngle(temp, axis, angle);\n const orientation = this.orientation.orientation;\n\n // We want the coordinates in the transformed coordinate frame of the fixed point to remain\n // the same after the rotation.\n\n // We have the invariants:\n // oldOrienation * fixedPointLocal + oldPosition == fixedPoint.\n // newOrientation * fixedPointLocal + newPosition == fixedPoint.\n\n // Therefore, we compute fixedPointLocal by:\n // fixedPointLocal == inverse(oldOrientation) * (fixedPoint - oldPosition).\n const fixedPointLocal = tempVec3;\n tempVec3.fill(0);\n for (let i = 0; i < displayRank; ++i) {\n const dim = displayDimensionIndices[i];\n const diff = fixedPoint[dim] - voxelCoordinates[dim];\n fixedPointLocal[i] = diff * scales[dim] * relativeDisplayScales[dim];\n }\n const invOrientation = quat.invert(tempQuat, orientation);\n vec3.transformQuat(fixedPointLocal, fixedPointLocal, invOrientation);\n\n // We then compute the newPosition by:\n // newPosition := fixedPoint - newOrientation * fixedPointLocal.\n quat.multiply(orientation, temp, orientation);\n vec3.transformQuat(fixedPointLocal, fixedPointLocal, orientation);\n\n for (let i = 0; i < displayRank; ++i) {\n const dim = displayDimensionIndices[i];\n voxelCoordinates[dim] =\n fixedPoint[dim] -\n fixedPointLocal[i] / (scales[dim] * relativeDisplayScales[dim]);\n }\n this.position.changed.dispatch();\n this.orientation.changed.dispatch();\n }\n\n translateNonDisplayDimension(\n nonSpatialDimensionIndex: number,\n adjustment: number,\n ) {\n if (!this.valid) return;\n const { displayDimensionIndices } = this.displayDimensions.value;\n const { position } = this;\n const rank = position.coordinateSpace.value.rank;\n for (let i = 0; i < rank; ++i) {\n if (displayDimensionIndices.indexOf(i) !== -1) continue;\n if (nonSpatialDimensionIndex-- === 0) {\n this.translateDimensionRelative(i, adjustment);\n return;\n }\n }\n }\n}\n\nexport type TrackableZoomInterface =\n | TrackableProjectionZoom\n | TrackableCrossSectionZoom;\n\nexport class LinkedZoomState<\n T extends TrackableProjectionZoom | TrackableCrossSectionZoom,\n> extends LinkedBase {\n constructor(\n peer: Owned,\n displayDimensionRenderInfo: Owned,\n ) {\n super(peer);\n this.value = (() => {\n const self: T = new (peer.constructor as any)(displayDimensionRenderInfo);\n const assign = (target: T, source: T) => {\n target.assign(source);\n };\n const difference = (a: T, b: T) => {\n return (\n (a.value / b.value) *\n (a.canonicalVoxelPhysicalSize / b.canonicalVoxelPhysicalSize)\n );\n };\n const add = (target: T, source: T, amount: number) => {\n target.setPhysicalScale(\n source.value * amount,\n source.canonicalVoxelPhysicalSize,\n );\n };\n const subtract = (target: T, source: T, amount: number) => {\n target.setPhysicalScale(\n source.value / amount,\n source.canonicalVoxelPhysicalSize,\n );\n };\n const isValid = (x: T) =>\n x.coordinateSpaceValue.valid && x.canonicalVoxelPhysicalSize !== 0;\n makeLinked(\n self as RefCounted & { changed: NullarySignal },\n this.peer,\n this.link,\n {\n assign,\n isValid,\n difference,\n add,\n subtract,\n },\n );\n return self;\n })();\n }\n}\n\nexport function linkedStateLegacyJsonView<\n T extends LinkableState & { readonly legacyJsonView: Trackable },\n>(linked: LinkedBase) {\n return {\n changed: linked.changed,\n toJSON() {\n return linked.toJSON();\n },\n restoreState(obj: unknown) {\n restoreLinkedFromJson(linked.link, linked.value.legacyJsonView, obj);\n },\n reset() {\n linked.reset();\n },\n };\n}\n\nabstract class TrackableZoom\n extends RefCounted\n implements Trackable, WatchableValueInterface\n{\n readonly changed = new NullarySignal();\n private curCanonicalVoxelPhysicalSize = 0;\n private value_: number = Number.NaN;\n protected legacyValue_: number = Number.NaN;\n\n /**\n * Zoom factor. For cross section views, in canonical voxels per viewport pixel. For projection\n * views, in canonical voxels per viewport height (for orthographic projection).\n */\n get value() {\n this.handleCoordinateSpaceChanged();\n return this.value_;\n }\n\n set value(value: number) {\n const { canonicalVoxelPhysicalSize } = this;\n if (\n Object.is(value, this.value_) &&\n canonicalVoxelPhysicalSize === this.curCanonicalVoxelPhysicalSize\n ) {\n return;\n }\n this.curCanonicalVoxelPhysicalSize = canonicalVoxelPhysicalSize;\n this.legacyValue_ = Number.NaN;\n this.value_ = value;\n this.changed.dispatch();\n }\n\n get canonicalVoxelPhysicalSize() {\n return this.displayDimensionRenderInfo.value.canonicalVoxelPhysicalSize;\n }\n\n get coordinateSpaceValue() {\n return this.displayDimensionRenderInfo.relativeDisplayScales.coordinateSpace\n .value;\n }\n\n /**\n * Sets the zoom factor in the legacy units. For cross section views, `1e-9` spatial units per\n * viewport pixel. For projection views, `2 * 100 * Math.tan(Math.PI / 8) * 1e-9` spatial units\n * per viewport height (for orthographic projection).\n */\n set legacyValue(value: number) {\n if (Object.is(value, this.legacyValue_)) return;\n this.value_ = Number.NaN;\n this.legacyValue_ = value;\n this.curCanonicalVoxelPhysicalSize = 0;\n this.changed.dispatch();\n }\n\n get legacyValue() {\n return this.legacyValue_;\n }\n\n constructor(\n public displayDimensionRenderInfo: Owned,\n ) {\n super();\n this.registerDisposer(displayDimensionRenderInfo);\n this.registerDisposer(\n displayDimensionRenderInfo.changed.add(() =>\n this.handleCoordinateSpaceChanged(),\n ),\n );\n this.registerDisposer(\n displayDimensionRenderInfo.relativeDisplayScales.coordinateSpace.changed.add(\n () => this.handleCoordinateSpaceChanged(),\n ),\n );\n this.handleCoordinateSpaceChanged();\n }\n\n handleCoordinateSpaceChanged() {\n const { value_ } = this;\n const {\n displayDimensionRenderInfo: {\n value: { canonicalVoxelPhysicalSize },\n relativeDisplayScales: {\n coordinateSpace: { value: coordinateSpace },\n },\n },\n } = this;\n const { curCanonicalVoxelPhysicalSize } = this;\n if (\n !Number.isNaN(value_) &&\n canonicalVoxelPhysicalSize === curCanonicalVoxelPhysicalSize\n ) {\n return;\n }\n if (!Number.isNaN(value_)) {\n if (curCanonicalVoxelPhysicalSize !== 0) {\n this.value_ =\n value_ * (curCanonicalVoxelPhysicalSize / canonicalVoxelPhysicalSize);\n this.curCanonicalVoxelPhysicalSize = canonicalVoxelPhysicalSize;\n this.changed.dispatch();\n }\n return;\n }\n if (!coordinateSpace.valid || canonicalVoxelPhysicalSize === 0) {\n return;\n }\n this.curCanonicalVoxelPhysicalSize = canonicalVoxelPhysicalSize;\n this.value_ = this.getDefaultValue();\n this.changed.dispatch();\n }\n\n protected abstract getDefaultValue(): number;\n\n toJSON() {\n const { value } = this;\n return Number.isNaN(value) ? undefined : value;\n }\n\n restoreState(obj: any) {\n this.curCanonicalVoxelPhysicalSize = 0;\n this.legacyValue_ = Number.NaN;\n if (obj === undefined) {\n this.value_ = Number.NaN;\n } else {\n this.value_ = verifyFinitePositiveFloat(obj);\n }\n this.changed.dispatch();\n }\n\n reset() {\n this.curCanonicalVoxelPhysicalSize = 0;\n this.value_ = Number.NaN;\n this.legacyValue_ = Number.NaN;\n this.changed.dispatch();\n }\n\n get legacyJsonView() {\n const self = this;\n return {\n changed: self.changed,\n toJSON() {\n return self.toJSON();\n },\n reset() {\n return self.reset();\n },\n restoreState(obj: any) {\n self.legacyValue = verifyFinitePositiveFloat(obj);\n },\n };\n }\n\n setPhysicalScale(\n scaleInCanonicalVoxels: number,\n canonicalVoxelPhysicalSize: number,\n ) {\n const curCanonicalVoxelPhysicalSize = (this.curCanonicalVoxelPhysicalSize =\n this.canonicalVoxelPhysicalSize);\n this.value =\n scaleInCanonicalVoxels *\n (canonicalVoxelPhysicalSize / curCanonicalVoxelPhysicalSize);\n }\n\n assign(source: TrackableZoomInterface) {\n const { legacyValue } = source;\n if (!Number.isNaN(legacyValue)) {\n this.legacyValue = legacyValue;\n } else {\n this.setPhysicalScale(source.value, source.canonicalVoxelPhysicalSize);\n }\n }\n}\n\nexport class TrackableCrossSectionZoom extends TrackableZoom {\n protected getDefaultValue() {\n const { legacyValue_ } = this;\n if (Number.isNaN(legacyValue_)) {\n // Default is 1 voxel per viewport pixel.\n return 1;\n }\n const { canonicalVoxelPhysicalSize } = this;\n return (this.legacyValue_ * 1e-9) / canonicalVoxelPhysicalSize;\n }\n}\n\nexport class TrackableProjectionZoom extends TrackableZoom {\n protected getDefaultValue() {\n const { legacyValue_ } = this;\n if (!Number.isNaN(legacyValue_)) {\n this.legacyValue_ = Number.NaN;\n const { canonicalVoxelPhysicalSize } = this;\n return (\n (2 * 100 * Math.tan(Math.PI / 8) * 1e-9 * legacyValue_) /\n canonicalVoxelPhysicalSize\n );\n }\n const {\n coordinateSpaceValue: {\n bounds: { lowerBounds, upperBounds },\n },\n } = this;\n const { canonicalVoxelFactors, displayDimensionIndices } =\n this.displayDimensionRenderInfo.value;\n let value = canonicalVoxelFactors.reduce((x, factor, i) => {\n const dim = displayDimensionIndices[i];\n const extent = (upperBounds[dim] - lowerBounds[dim]) * factor;\n return Math.max(x, extent);\n }, 0);\n if (!Number.isFinite(value)) {\n // Default to showing 1024 voxels if there is no bounds information.\n value = 1024;\n } else {\n value = 2 ** Math.ceil(Math.log2(value));\n }\n return value;\n }\n}\n\nexport class TrackableDepthRange\n extends RefCounted\n implements WatchableValueInterface\n{\n changed = new NullarySignal();\n\n constructor(\n public readonly defaultValue: number,\n public displayDimensionRenderInfo: WatchableValueInterface,\n ) {\n super();\n this.value_ = defaultValue;\n this.canonicalVoxelPhysicalSize =\n displayDimensionRenderInfo.value.canonicalVoxelPhysicalSize;\n this.registerDisposer(\n displayDimensionRenderInfo.changed.add(() => {\n this.value;\n }),\n );\n }\n\n private value_: number;\n canonicalVoxelPhysicalSize: number;\n\n get value() {\n let { value_ } = this;\n if (value_ > 0) {\n const { canonicalVoxelPhysicalSize } =\n this.displayDimensionRenderInfo.value;\n const prevCanonicalVoxelPhysicalSize = this.canonicalVoxelPhysicalSize;\n if (canonicalVoxelPhysicalSize !== prevCanonicalVoxelPhysicalSize) {\n this.canonicalVoxelPhysicalSize = canonicalVoxelPhysicalSize;\n value_ =\n this.value_ =\n value_ =\n prevCanonicalVoxelPhysicalSize / canonicalVoxelPhysicalSize;\n this.changed.dispatch();\n }\n }\n return value_;\n }\n\n set value(value: number) {\n if (value === this.value) return;\n this.value_ = value;\n const { canonicalVoxelPhysicalSize } =\n this.displayDimensionRenderInfo.value;\n this.canonicalVoxelPhysicalSize = canonicalVoxelPhysicalSize;\n this.changed.dispatch();\n }\n\n toJSON() {\n const { value } = this;\n if (value === this.defaultValue) return undefined;\n return value;\n }\n\n reset() {\n this.value = this.defaultValue;\n }\n\n restoreState(obj: unknown) {\n if (typeof obj !== \"number\" || !Number.isFinite(obj) || obj === 0) {\n this.value = this.defaultValue;\n } else {\n this.value = obj;\n }\n }\n\n setValueAbsolute(value: number, sourceCanonicalVoxelPhysicalSize: number) {\n if (value > 0) {\n const { canonicalVoxelPhysicalSize } =\n this.displayDimensionRenderInfo.value;\n value =\n value * (sourceCanonicalVoxelPhysicalSize / canonicalVoxelPhysicalSize);\n }\n this.value = value;\n }\n\n assign(other: TrackableDepthRange) {\n this.setValueAbsolute(other.value, other.canonicalVoxelPhysicalSize);\n }\n}\n\nexport class LinkedDepthRange extends SimpleLinkedBase {\n constructor(\n peer: Owned,\n displayDimensionRenderInfo: WatchableValueInterface,\n ) {\n super(peer);\n this.value = makeSimpleLinked(\n new TrackableDepthRange(peer.defaultValue, displayDimensionRenderInfo),\n this.peer,\n this.link,\n {\n assign: (target, source) => target.assign(source),\n isValid: () => true,\n },\n );\n }\n}\n\nexport class NavigationState<\n Zoom extends TrackableZoomInterface = TrackableZoomInterface,\n> extends RefCounted {\n changed = new NullarySignal();\n\n constructor(\n public pose: Owned,\n public zoomFactor: Owned,\n public depthRange: Owned,\n ) {\n super();\n this.registerDisposer(pose);\n this.registerDisposer(zoomFactor);\n this.registerDisposer(depthRange);\n this.registerDisposer(this.pose.changed.add(this.changed.dispatch));\n this.registerDisposer(this.zoomFactor.changed.add(this.changed.dispatch));\n this.registerDisposer(this.depthRange.changed.add(this.changed.dispatch));\n }\n get coordinateSpace() {\n return this.pose.position.coordinateSpace;\n }\n\n /**\n * Resets everything.\n */\n reset() {\n this.pose.reset();\n this.zoomFactor.reset();\n }\n\n get position() {\n return this.pose.position;\n }\n get displayDimensions() {\n return this.pose.displayDimensions;\n }\n get relativeDisplayScales() {\n return this.pose.relativeDisplayScales;\n }\n get displayDimensionRenderInfo() {\n return this.pose.displayDimensionRenderInfo;\n }\n toMat4(mat: mat4) {\n this.pose.toMat4(mat, this.zoomFactor.value);\n }\n toMat3(mat: mat3) {\n this.pose.toMat3(mat, this.zoomFactor.value);\n }\n\n get relativeDepthRange() {\n let depthRange = this.depthRange.value;\n if (depthRange > 0) {\n depthRange /= this.zoomFactor.value;\n } else {\n depthRange *= -1;\n }\n return depthRange;\n }\n\n get valid() {\n return this.pose.valid && !Number.isNaN(this.zoomFactor.value);\n }\n\n zoomBy(factor: number) {\n this.zoomFactor.value *= factor;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @file Hierarchical mapping from keys to values.\n */\n\nexport interface HierarchicalMapInterface {\n get(key: Key): Value | undefined;\n entries(): IterableIterator<[Key, Value]>;\n}\n\n/**\n * Maps string event identifiers to string action identifiers.\n *\n * When an event identifier is looked up in a given HierarchicalMap, it is resolved to a\n * corresponding action identifier in one of two ways:\n *\n * 1. via mappings defined directly on the HierarchicalMap.\n *\n * 2. via a recursive lookup on a \"parent\" HierarchicalMap that has been specified for the root\n * HierarchicalMap on which the lookup was initiated.\n *\n * HierarchicalMap objects may be specified as \"parents\" of another HierarchicalMap along with a\n * specified numerical priority value, such that there is a directed graph of HierarchicalMap\n * objects. Cycles in this graph may lead to infinite looping.\n *\n * Recursive lookups in parent HierarchicalMap objects are performed in order of decreasing\n * priority. The lookup stops as soon as a mapping is found. Direct bindings have a priority of 0.\n * Therefore, parent maps with a priority higher than 0 take precedence over direct bindings.\n */\nexport class HierarchicalMap<\n Key,\n Value,\n Parent extends HierarchicalMapInterface<\n Key,\n Value\n > = HierarchicalMapInterface,\n> implements HierarchicalMapInterface\n{\n parents = new Array();\n private parentPriorities = new Array();\n bindings = new Map();\n\n /**\n * If an existing HierarchicalMap is specified, a shallow copy is made.\n *\n * @param existing Existing map to make a shallow copy of.\n */\n constructor(existing?: HierarchicalMap) {\n if (existing !== undefined) {\n this.parents.push(...existing.parents);\n this.parentPriorities.push(...existing.parentPriorities);\n for (const [k, v] of existing.bindings) {\n this.bindings.set(k, v);\n }\n }\n }\n\n /**\n * Register `parent` as a parent map. If `priority > 0`, this map will take precedence over\n * direct bindings.\n *\n * @returns A nullary function that unregisters the parent (and may be called at most once).\n */\n addParent(parent: Parent, priority: number) {\n const { parents, parentPriorities } = this;\n let index = 0;\n const { length } = parents;\n while (index < length && priority < parentPriorities[index]) {\n ++index;\n }\n parents.splice(index, 0, parent);\n parentPriorities.splice(index, 0, priority);\n\n return () => {\n this.removeParent(parent);\n };\n }\n\n /**\n * Unregisters `parent` as a parent.\n */\n removeParent(parent: Parent) {\n const index = this.parents.indexOf(parent);\n if (index === -1) {\n throw new Error(\"Attempt to remove non-existent parent map.\");\n }\n this.parents.splice(index, 1);\n this.parentPriorities.splice(index, 1);\n }\n\n /**\n * Register a direct binding.\n */\n set(key: Key, value: Value) {\n this.bindings.set(key, value);\n }\n\n /**\n * Unregister a direct binding.\n */\n delete(key: Key) {\n this.bindings.delete(key);\n }\n\n /**\n * Deletes all bindings, including parents.\n */\n clear() {\n this.bindings.clear();\n this.parents.length = 0;\n this.parentPriorities.length = 0;\n }\n\n /**\n * Lookup the highest priority value to which the specified key is mapped.\n */\n get(key: Key): Value | undefined {\n const { parents, parentPriorities } = this;\n const numParents = parentPriorities.length;\n let parentIndex = 0;\n let value;\n for (\n ;\n parentIndex < numParents && parentPriorities[parentIndex] > 0;\n ++parentIndex\n ) {\n value = parents[parentIndex].get(key);\n if (value !== undefined) {\n return value;\n }\n }\n value = this.bindings.get(key);\n if (value !== undefined) {\n return value;\n }\n for (; parentIndex < numParents; ++parentIndex) {\n value = parents[parentIndex].get(key);\n if (value !== undefined) {\n return value;\n }\n }\n return undefined;\n }\n\n /**\n * Find all values to which the specified key is mapped.\n */\n *getAll(key: Key): IterableIterator {\n const { parents, parentPriorities } = this;\n const numParents = parentPriorities.length;\n const parentIndex = 0;\n let value;\n while (parentIndex < numParents && parentPriorities[parentIndex] > 0) {\n value = parents[parentIndex].get(key);\n if (value !== undefined) {\n yield value;\n }\n }\n value = this.bindings.get(key);\n if (value !== undefined) {\n yield value;\n }\n while (parentIndex < numParents) {\n value = parents[parentIndex].get(key);\n if (value !== undefined) {\n yield value;\n }\n }\n }\n\n *entries(): IterableIterator<[Key, Value]> {\n const { parents, parentPriorities } = this;\n const numParents = parentPriorities.length;\n let parentIndex = 0;\n for (\n ;\n parentIndex < numParents && parentPriorities[parentIndex] > 0;\n ++parentIndex\n ) {\n yield* parents[parentIndex].entries();\n }\n yield* this.bindings.entries();\n for (; parentIndex < numParents; ++parentIndex) {\n yield* parents[parentIndex].entries();\n }\n }\n}\n","/**\n * @license\n * Copyright 2017 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { registerEventListener } from \"#src/util/disposable.js\";\nimport type { HierarchicalMapInterface } from \"#src/util/hierarchical_map.js\";\nimport { HierarchicalMap } from \"#src/util/hierarchical_map.js\";\n\n/**\n * @file Facilities for dispatching user-defined actions in response to input events.\n */\n\n/**\n * Specifies a unique string representation of an input event, used for matching an input event to a\n * corresponding action with which it has been associated.\n *\n * The EventIdentifier combines several pieces of information using the following syntax:\n *\n * NormalizedEventIdentifier ::= phase ':' ( modifier '+' )* base-event-identifier\n *\n * - The event `phase` name, corresponding to the phase of DOM event processing at which the event was\n * received, which may be 'at', 'bubble', or 'capture'. (Currently, 'capture' is not supported.)\n *\n * - The set of `modifier` keys ('control', 'alt', 'meta', and/or 'shift') active when the event occurred.\n *\n * - The `base-event-identifier`, which in the case of keyboard events is the lowercase KeyboardEvent\n * `code`, and in the case of mouse events is one of:\n *\n * - 'mousedown' + n\n * - 'mouseup' + n\n * - 'click' + n\n * - 'dblclick' + n\n * - 'wheel'\n *\n * where `n` is the index of the mouse button, starting from 0.\n *\n * In the normalized form used for matching events, the set of modifiers must be specified in\n * exactly the order: 'control', 'alt', 'meta', 'shift'. Consequently, there is exactly one\n * NormalizedEventIdentifier representation for a given input event.\n */\nexport type NormalizedEventIdentifier = string;\n\n/**\n * An EventIdentifier specifies a criteria for matching input events using a relaxed form of the\n * NormalizedEventIdentifier syntax. Each EventIdentifier corresponds to one or more\n * NormalizedEventIdentifier values.\n *\n * EventIdentifier ::= [ phase ':' ] ( modifier '+' )* base-event-identifier\n *\n * In addition to the phase being optional, the modifiers may be specified in any order. If the\n * phase is not specified, then the EventIdentifier matches both the 'at' and 'bubble' phases.\n */\nexport type EventIdentifier = string;\n\n/**\n * Identifies a user-defined action name. Actions are dispatched as DOM events, using 'action:'\n * prepended to the ActionIdentifier as the event type.\n */\nexport type ActionIdentifier = string;\n\n/**\n * Specifies how to handle an event.\n */\nexport interface EventAction {\n /**\n * Identifier of action to dispatch.\n */\n action: ActionIdentifier;\n\n /**\n * Whether to call `stopPropagation()` on the triggering event. Defaults to true.\n */\n stopPropagation?: boolean;\n\n /**\n * Whether to call `preventDefault()` on the triggering event. Defaults to true. Additionally,\n * if `preventDefault()` is called on the dispatched ActionEvent, `preventDefault()` will also be\n * called on the triggering event regardless of the value of `preventDefault`.\n */\n preventDefault?: boolean;\n\n originalEventIdentifier?: string;\n}\n\nexport type EventActionMapInterface = HierarchicalMapInterface<\n NormalizedEventIdentifier,\n EventAction\n>;\n\nexport enum Modifiers {\n CONTROL = 1,\n ALT = 2,\n META = 4,\n SHIFT = 8,\n}\n\nexport type ModifierMask = number;\n\nexport interface EventModifierKeyState {\n ctrlKey: boolean;\n altKey: boolean;\n metaKey: boolean;\n shiftKey: boolean;\n}\n\nexport function getEventModifierMask(\n event: EventModifierKeyState,\n): ModifierMask {\n return (\n (event.ctrlKey ? Modifiers.CONTROL : 0) |\n (event.altKey ? Modifiers.ALT : 0) |\n (event.metaKey ? Modifiers.META : 0) |\n (event.shiftKey ? Modifiers.SHIFT : 0)\n );\n}\n\nexport function getStrokeIdentifier(keyName: string, modifiers: ModifierMask) {\n let identifier = \"\";\n if (modifiers & Modifiers.CONTROL) {\n identifier += \"control+\";\n }\n if (modifiers & Modifiers.ALT) {\n identifier += \"alt+\";\n }\n if (modifiers & Modifiers.META) {\n identifier += \"meta+\";\n }\n if (modifiers & Modifiers.SHIFT) {\n identifier += \"shift+\";\n }\n identifier += keyName;\n return identifier;\n}\n\nfunction getStrokeIdentifierWithOptionalModifiers(\n keyName: string,\n modifiers: ModifierMask,\n optionalModifiers: ModifierMask,\n) {\n let identifier = \"\";\n if (modifiers & Modifiers.CONTROL) {\n identifier += \"control+\";\n }\n if (optionalModifiers & Modifiers.CONTROL) {\n identifier += \"control?+\";\n }\n if (modifiers & Modifiers.ALT) {\n identifier += \"alt+\";\n }\n if (optionalModifiers & Modifiers.ALT) {\n identifier += \"alt?+\";\n }\n if (modifiers & Modifiers.META) {\n identifier += \"meta+\";\n }\n if (optionalModifiers & Modifiers.META) {\n identifier += \"meta?+\";\n }\n if (modifiers & Modifiers.SHIFT) {\n identifier += \"shift+\";\n }\n if (optionalModifiers & Modifiers.SHIFT) {\n identifier += \"shift?+\";\n }\n identifier += keyName;\n return identifier;\n}\n\ninterface ParsedEventIdentifier {\n phase: undefined | \"at\" | \"bubble\";\n keyName: string;\n modifiers: ModifierMask;\n optionalModifiers: ModifierMask;\n}\n\nfunction parseEventIdentifier(identifier: string): ParsedEventIdentifier {\n const firstColonOffset = identifier.indexOf(\":\");\n let phase: string | undefined;\n if (firstColonOffset !== -1) {\n phase = identifier.substring(0, firstColonOffset);\n // TODO(jbms): Support capture phase.\n if (phase !== \"at\" && phase !== \"bubble\") {\n throw new Error(`Invalid event phase: ${JSON.stringify(phase)}`);\n }\n }\n const parts = identifier.substring(firstColonOffset + 1).split(\"+\");\n let keyName: string | undefined;\n let modifiers = 0;\n let optionalModifiers = 0;\n loop: for (const part of parts) {\n switch (part) {\n case \"control\":\n modifiers |= Modifiers.CONTROL;\n break;\n case \"control?\":\n optionalModifiers |= Modifiers.CONTROL;\n break;\n case \"alt\":\n modifiers |= Modifiers.ALT;\n break;\n case \"alt?\":\n optionalModifiers |= Modifiers.ALT;\n break;\n case \"meta\":\n modifiers |= Modifiers.META;\n break;\n case \"meta?\":\n optionalModifiers |= Modifiers.META;\n break;\n case \"shift\":\n modifiers |= Modifiers.SHIFT;\n break;\n case \"shift?\":\n optionalModifiers |= Modifiers.SHIFT;\n break;\n default:\n if (keyName === undefined) {\n keyName = part;\n } else {\n keyName = undefined;\n break loop;\n }\n }\n }\n if (keyName === undefined || modifiers & optionalModifiers) {\n throw new Error(`Invalid event identifier: ${JSON.stringify(identifier)}`);\n }\n return {\n phase: phase as ParsedEventIdentifier[\"phase\"],\n keyName,\n modifiers,\n optionalModifiers,\n };\n}\n\nfunction* getNormalizedStrokeIdentifiers(\n keyName: string,\n modifiers: ModifierMask,\n optionalModifiers: ModifierMask,\n): Iterable {\n if (optionalModifiers === 0) {\n yield getStrokeIdentifier(keyName, modifiers);\n }\n for (let m = 0; m < 16; ++m) {\n if ((m & (modifiers | optionalModifiers)) !== m) continue;\n if ((m & modifiers) !== modifiers) continue;\n yield getStrokeIdentifier(keyName, m);\n }\n}\n\n/**\n * Normalizes a user-specified EventIdentifier into a list of one or more corresponding\n * NormalizedEventIdentifier strings.\n */\nfunction* getNormalizedEventIdentifiers(\n parsed: ParsedEventIdentifier,\n): Iterable {\n const { phase } = parsed;\n const strokeIdentifiers = getNormalizedStrokeIdentifiers(\n parsed.keyName,\n parsed.modifiers,\n parsed.optionalModifiers,\n );\n if (phase === undefined) {\n for (const suffix of strokeIdentifiers) {\n yield `at:${suffix}`;\n yield `bubble:${suffix}`;\n }\n } else {\n for (const suffix of strokeIdentifiers) {\n yield `${phase}:${suffix}`;\n }\n }\n}\n\n/**\n * Specifies either an EventAction or a bare ActionIdentifier.\n */\ntype ActionOrEventAction = EventAction | ActionIdentifier;\n\n/**\n * Normalizes an ActionOrEventAction into an EventAction.\n */\nexport function normalizeEventAction(\n parsed: ParsedEventIdentifier,\n action: ActionOrEventAction,\n): EventAction {\n const identifier = getStrokeIdentifierWithOptionalModifiers(\n parsed.keyName,\n parsed.modifiers,\n parsed.optionalModifiers,\n );\n if (typeof action === \"string\") {\n return { action: action, originalEventIdentifier: identifier };\n }\n return { ...action, originalEventIdentifier: identifier };\n}\n\n// Strips the phase and optional modifiers.\nfunction friendlyEventIdentifier(identifier: string): string {\n identifier = identifier.replace(\n /^(?:at|bubble|capture)|(?:(?:shift|control|alt|meta)\\?\\+)/g,\n \"\",\n );\n return identifier;\n}\n\n/**\n * Hierarchical map of `EventIdentifier` specifications to `EventAction` specifications. These maps\n * are used by KeyboardEventBinder and MouseEventBinder to dispatch an ActionEvent in response to an\n * input event.\n */\nexport class EventActionMap\n extends HierarchicalMap<\n NormalizedEventIdentifier,\n EventAction,\n EventActionMap\n >\n implements EventActionMapInterface\n{\n label: string | undefined;\n\n /**\n * Returns a new EventActionMap with the specified bindings.\n *\n * The keys of the `bindings` object specify unnormalized event identifiers to be mapped to their\n * corresponding `ActionOrEventAction` values.\n */\n static fromObject(\n bindings: { [key: string]: ActionOrEventAction },\n options: {\n label?: string;\n parents?: Iterable<[EventActionMap, number]>;\n } = {},\n ) {\n const map = new EventActionMap();\n map.label = options.label;\n if (options.parents !== undefined) {\n for (const [parent, priority] of options.parents) {\n map.addParent(parent, priority);\n }\n }\n for (const key of Object.keys(bindings)) {\n map.set(key, bindings[key]);\n }\n return map;\n }\n\n setFromObject(bindings: { [key: string]: ActionOrEventAction }) {\n for (const key of Object.keys(bindings)) {\n this.set(key, bindings[key]);\n }\n }\n\n /**\n * Maps the specified event `identifier` to the specified `action`.\n *\n * The `identifier` may be unnormalized; the actual mapping is created for each corresponding\n * normalized identifier.\n */\n set(identifier: EventIdentifier, action: ActionOrEventAction) {\n const parsedIdentifier = parseEventIdentifier(identifier);\n const normalizedAction = normalizeEventAction(parsedIdentifier, action);\n for (const normalizedIdentifier of getNormalizedEventIdentifiers(\n parsedIdentifier,\n )) {\n super.set(normalizedIdentifier, normalizedAction);\n }\n }\n\n /**\n * Deletes the mapping for the specified `identifier`.\n *\n * The `identifier` may be unnormalized; the mapping is deleted for each corresponding normalized\n * identifier.\n */\n delete(identifier: EventIdentifier) {\n for (const normalizedIdentifier of getNormalizedEventIdentifiers(\n parseEventIdentifier(identifier),\n )) {\n super.delete(normalizedIdentifier);\n }\n }\n\n describe(): string {\n const bindings = [];\n const uniqueBindings = new Map();\n for (const [, value] of this.entries()) {\n uniqueBindings.set(value.originalEventIdentifier!, value.action);\n }\n const actionBindings = new Map();\n for (const [eventIdentifier, action] of uniqueBindings) {\n let events = actionBindings.get(action);\n if (events === undefined) {\n events = [];\n actionBindings.set(action, events);\n }\n events.push(friendlyEventIdentifier(eventIdentifier));\n }\n for (const [action, events] of actionBindings) {\n const eventStr =\n events.length === 1 ? events[0] : `{${events.join(\",\")}}`;\n bindings.push(`${eventStr}→${action}`);\n }\n return bindings.join(\", \");\n }\n}\n\nexport function dispatchEventAction(\n originalEvent: Event,\n detail: any,\n eventAction: EventAction | undefined,\n) {\n if (eventAction === undefined) {\n return;\n }\n if (eventAction.stopPropagation !== false) {\n originalEvent.stopPropagation();\n }\n const actionEvent = new CustomEvent(\"action:\" + eventAction.action, {\n bubbles: true,\n detail: detail,\n cancelable: true,\n });\n const cancelled = !originalEvent.target!.dispatchEvent(actionEvent);\n if (eventAction.preventDefault !== false || cancelled) {\n originalEvent.preventDefault();\n }\n}\n\nexport const eventPhaseNames: string[] = [];\neventPhaseNames[Event.AT_TARGET] = \"at\";\neventPhaseNames[Event.CAPTURING_PHASE] = \"capture\";\neventPhaseNames[Event.BUBBLING_PHASE] = \"bubble\";\n\nexport function dispatchEvent(\n baseIdentifier: EventIdentifier,\n originalEvent: Event,\n eventPhase: number,\n detail: any,\n eventMap: EventActionMapInterface,\n) {\n const eventIdentifier = eventPhaseNames[eventPhase] + \":\" + baseIdentifier;\n const eventAction = eventMap.get(eventIdentifier);\n dispatchEventAction(originalEvent, detail, eventAction);\n}\n\nexport function dispatchEventWithModifiers(\n baseIdentifier: EventIdentifier,\n originalEvent: Event & EventModifierKeyState,\n detail: any,\n eventMap: EventActionMapInterface,\n) {\n dispatchEvent(\n getStrokeIdentifier(baseIdentifier, getEventModifierMask(originalEvent)),\n originalEvent,\n originalEvent.eventPhase,\n detail,\n eventMap,\n );\n}\n\n/**\n * DOM Event type used for dispatching actions.\n *\n * Additional information relevant to the acction is specified as the `detail` property.\n */\nexport interface ActionEvent extends CustomEvent {\n detail: Info;\n}\n\n/**\n * Register an event listener for the specified `action`.\n *\n * There is no checking that the `TriggerEvent` type is suitable for use with the specified\n * `action`.\n *\n * @returns A nullary disposer function that unregisters the listener when called.\n */\nexport function registerActionListener(\n target: EventTarget,\n action: ActionIdentifier,\n listener: (event: ActionEvent) => void,\n options?: boolean | AddEventListenerOptions,\n) {\n return registerEventListener(target, `action:${action}`, listener, options);\n}\n","/**\n * @license\n * Copyright 2017 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @file Facility for triggering named actions in response to mouse events.\n */\n\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport type {\n ActionEvent,\n EventActionMapInterface,\n} from \"#src/util/event_action_map.js\";\nimport {\n dispatchEventWithModifiers,\n EventActionMap,\n registerActionListener,\n} from \"#src/util/event_action_map.js\";\n\nexport class MouseEventBinder<\n EventMap extends EventActionMapInterface,\n> extends RefCounted {\n private dispatch(baseIdentifier: string, event: MouseEvent) {\n if (this.shouldIgnore?.(event)) return;\n dispatchEventWithModifiers(baseIdentifier, event, event, this.eventMap);\n }\n shouldIgnore: ((event: MouseEvent) => boolean) | undefined = undefined;\n constructor(\n public target: EventTarget,\n public eventMap: EventMap,\n commonHandler?: (event: MouseEvent) => void,\n ) {\n super();\n this.registerEventListener(target, \"wheel\", (event: WheelEvent) => {\n if (commonHandler !== undefined) commonHandler(event);\n this.dispatch(\"wheel\", event);\n });\n this.registerEventListener(target, \"click\", (event: MouseEvent) => {\n if (commonHandler !== undefined) commonHandler(event);\n this.dispatch(`click${event.button}`, event);\n });\n this.registerEventListener(target, \"dblclick\", (event: MouseEvent) => {\n if (commonHandler !== undefined) commonHandler(event);\n this.dispatch(`dblclick${event.button}`, event);\n });\n this.registerEventListener(target, \"mousedown\", (event: MouseEvent) => {\n if (commonHandler !== undefined) commonHandler(event);\n let button = event.button;\n // Under Firefox on macOS, pressing the left mouse button while holding\n // control results in a mouse event with `button` set to 2 (incorrectly\n // indicating the right mouse button) but `buttons` set to 1 (correctly\n // indicating that only the left mouse button is down). This attempts to\n // reverse that translation.\n //\n // https://github.com/google/neuroglancer/issues/365\n //\n // Notes:\n //\n // - If both the left and right mouse buttons are both pressed at the same\n // time, this method of disambiguation does not work.\n //\n // - Firefox seems to \"remember\" that this translation of the button\n // number was done, and also sends the `mouseup` event with a button\n // number of 2, even if the control key was released before releasing\n // the mouse button. That means `mouse_drag.ts` works unmodified with\n // this translation (since it waits for a mouseup event with the same\n // button number).\n //\n // - This method of disambiguation does not work for `mouseup` events,\n // since the button has already been released and therefore is not\n // included in `buttons` anyway. Fortunately `mouseup` events are not\n // commonly used in Neuroglancer.\n if (button === 2 && (event.buttons & 3) === 1) {\n // `button` is 2 (right button), but only the left button is currently pressed.\n button = 0;\n }\n this.dispatch(`mousedown${button}`, event);\n });\n this.registerEventListener(target, \"mouseup\", (event: MouseEvent) => {\n if (commonHandler !== undefined) commonHandler(event);\n this.dispatch(`mouseup${event.button}`, event);\n });\n }\n}\n\nexport { EventActionMap, registerActionListener };\nexport type { EventActionMapInterface, ActionEvent };\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type RelativeDragHandler = (\n event: MouseEvent,\n deltaX: number,\n deltaY: number,\n) => void;\nexport function startRelativeMouseDrag(\n initialEvent: MouseEvent,\n handler: RelativeDragHandler,\n finishDragHandler?: RelativeDragHandler,\n) {\n const { document } = initialEvent.view!;\n let prevClientX = initialEvent.clientX;\n let prevClientY = initialEvent.clientY;\n const mouseMoveHandler = (e: PointerEvent) => {\n const deltaX = e.clientX - prevClientX;\n const deltaY = e.clientY - prevClientY;\n prevClientX = e.clientX;\n prevClientY = e.clientY;\n handler(e, deltaX, deltaY);\n };\n const button = initialEvent.button;\n const cancel = (e: PointerEvent) => {\n document.removeEventListener(\"pointermove\", mouseMoveHandler, true);\n document.removeEventListener(\"pointerup\", mouseUpHandler, false);\n\n if (finishDragHandler !== undefined) {\n finishDragHandler(e, e.clientX - prevClientX, e.clientY - prevClientY);\n }\n };\n const mouseUpHandler = (e: PointerEvent) => {\n if (e.button === button) {\n cancel(e);\n }\n };\n document.addEventListener(\"pointermove\", mouseMoveHandler, true);\n document.addEventListener(\"pointerup\", mouseUpHandler, false);\n document.addEventListener(\"pointercancel\", cancel, false);\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst DOM_DELTA_PIXEL = 0;\nconst DOM_DELTA_LINE = 1;\nconst DOM_DELTA_PAGE = 2;\n\nexport function getWheelZoomAmount(event: WheelEvent) {\n let multiplier = 0;\n const { deltaMode } = event;\n switch (deltaMode) {\n case DOM_DELTA_PIXEL:\n multiplier = 1 / 200.0;\n break;\n case DOM_DELTA_LINE:\n multiplier = 1 / 10.0;\n break;\n case DOM_DELTA_PAGE:\n multiplier = 2;\n break;\n }\n return Math.exp(event.deltaY * multiplier);\n}\n","/**\n * @license\n * Copyright 2018 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @file Facilities for drawing quads in WebGL as two triangles.\n */\n\nexport const VERTICES_PER_QUAD = 6;\nexport const TRIANGLES_PER_QUAD = 2;\n\n// Use a lookup table rather than a switch to avoid miscompilation on Apple M1.\nexport const glsl_getQuadVertexPosition = `\nvec2 getQuadVertexPosition(vec2 lower, vec2 upper) {\n const vec2 coeffs[] = vec2[](\n vec2(0.0, 0.0),\n vec2(0.0, 1.0),\n vec2(1.0, 1.0),\n vec2(1.0, 1.0),\n vec2(1.0, 0.0),\n vec2(0.0, 0.0)\n );\n int v = gl_VertexID % 6;\n return mix(lower, upper, coeffs[v]);\n}\n`;\n\nexport function drawQuads(\n gl: WebGL2RenderingContext,\n quadsPerInstance: number,\n numInstances: number,\n) {\n gl.drawArraysInstanced(\n WebGL2RenderingContext.TRIANGLES,\n 0,\n VERTICES_PER_QUAD * quadsPerInstance,\n numInstances,\n );\n}\n","/**\n * @license\n * Copyright 2017 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @file Facilities for drawing anti-aliased lines in WebGL as quads.\n */\n\nimport {\n drawQuads,\n glsl_getQuadVertexPosition,\n VERTICES_PER_QUAD,\n} from \"#src/webgl/quad.js\";\nimport type { ShaderBuilder, ShaderProgram } from \"#src/webgl/shader.js\";\nimport { glsl_clipLineToDepthRange } from \"#src/webgl/shader_lib.js\";\n\nexport const VERTICES_PER_LINE = VERTICES_PER_QUAD;\n\nexport function defineLineShader(builder: ShaderBuilder, rounded = false) {\n builder.addVertexCode(glsl_getQuadVertexPosition);\n // x: 1 / viewportWidth\n // y: 1 / viewportHeight\n // z: featherWidth: Line feather width in pixels\n builder.addUniform(\"highp vec3\", \"uLineParams\");\n builder.addVarying(\"highp float\", \"vLineCoord\");\n // max(1e-6, featherWidth) / (lineWidth + featherWidth)\n builder.addVarying(\"highp float\", \"vLineFeatherFraction\");\n if (rounded) {\n // Fraction of total line length used by each endpoint.\n builder.addVarying(\"highp float\", \"vEndpointFraction\");\n builder.addVarying(\"highp float\", \"vLineCoordT\");\n // Starting point of border from [0, 1].\n builder.addVarying(\"highp float\", \"vLineBorderStartFraction\");\n }\n builder.addVertexCode(glsl_clipLineToDepthRange);\n builder.addVertexCode(`\nvec2 getLineOffset() { return getQuadVertexPosition(vec2(0.0, -1.0), vec2(1.0, 1.0)); }\nfloat getLineEndpointCoefficient() { return getLineOffset().x; }\nuint getLineEndpointIndex() { return uint(getLineEndpointCoefficient()); }\nvoid emitLine(vec4 vertexAClip, vec4 vertexBClip, float lineWidthInPixels\n ${rounded ? \", float borderWidth\" : \"\"}) {\n if (!clipLineToDepthRange(vertexAClip, vertexBClip)) {\n gl_Position = vec4(2.0, 2.0, 2.0, 1.0);\n return;\n }\n vec3 vertexADevice = vertexAClip.xyz / vertexAClip.w;\n vec3 vertexBDevice = vertexBClip.xyz / vertexBClip.w;\n\n vec2 lineDirectionUnnormalized = vertexBDevice.xy - vertexADevice.xy;\n vec2 lineDirection;\n float linePixelLength = length(lineDirectionUnnormalized / uLineParams.xy * 0.5);\n\n if (linePixelLength < 1e-3) {\n lineDirection = vec2(1.0, 0.0);\n vertexADevice.z = vertexBDevice.z = 0.0;\n } else {\n lineDirection = normalize(lineDirectionUnnormalized);\n }\n vec2 lineNormal = normalize(vec2(lineDirection.y, -lineDirection.x) / uLineParams.yx * uLineParams.xy);\n\n vec2 lineOffset = getLineOffset();\n gl_Position = vec4(mix(vertexADevice, vertexBDevice, lineOffset.x), 1.0);\n float totalLineWidth = lineWidthInPixels + 2.0 * uLineParams.z ${\n rounded ? \" + 2.0 * borderWidth\" : \"\"\n };\n if (lineWidthInPixels == 0.0) totalLineWidth = 0.0;\n vLineFeatherFraction = max(1e-6, uLineParams.z) / totalLineWidth;\n gl_Position.xy += (lineOffset.y * lineNormal\n ${\n rounded\n ? \"+ lineDirection * (2.0 * lineOffset.x - 1.0)\"\n : \"\"\n })\n * totalLineWidth * uLineParams.xy;\n vLineCoord = lineOffset.y;\n ${\n rounded\n ? \"vEndpointFraction = totalLineWidth / (linePixelLength + totalLineWidth * 2.0);\"\n : \"\"\n }\n ${\n rounded\n ? \"vLineCoordT = lineOffset.x; vLineBorderStartFraction = lineWidthInPixels / totalLineWidth;\"\n : \"\"\n }\n}\nvoid emitLine(mat4 projection, vec3 vertexA, vec3 vertexB, float lineWidthInPixels\n ${rounded ? \", float borderWidth\" : \"\"}) {\n emitLine(projection * vec4(vertexA, 1.0), projection * vec4(vertexB, 1.0),\n lineWidthInPixels\n ${rounded ? \", borderWidth\" : \"\"});\n}\n`);\n if (rounded) {\n builder.addFragmentCode(`\nvec4 getRoundedLineColor(vec4 interiorColor, vec4 borderColor) {\n float radius;\n if (vLineCoordT < vEndpointFraction || vLineCoordT > 1.0 - vEndpointFraction) {\n radius = length(vec2(1.0 - min(vLineCoordT, 1.0 - vLineCoordT) / vEndpointFraction,\n vLineCoord));\n if (radius > 1.0) {\n discard;\n }\n } else {\n radius = abs(vLineCoord);\n }\n float borderColorFraction = clamp((radius - vLineBorderStartFraction) / vLineFeatherFraction, 0.0, 1.0);\n float feather = clamp((1.0 - radius) / vLineFeatherFraction, 0.0, 1.0);\n vec4 color = mix(interiorColor, borderColor, borderColorFraction);\n return vec4(color.rgb, color.a * feather);\n}\n`);\n }\n\n builder.addFragmentCode(`\nfloat getLineAlpha() {\n return clamp((1.0 - abs(vLineCoord)) / vLineFeatherFraction, 0.0, 1.0);\n}\n`);\n}\n\nexport function drawLines(\n gl: WebGL2RenderingContext,\n linesPerInstance: number,\n numInstances: number,\n) {\n drawQuads(gl, linesPerInstance, numInstances);\n}\n\nexport function initializeLineShader(\n shader: ShaderProgram,\n projectionParameters: { width: number; height: number },\n featherWidthInPixels: number,\n) {\n const { gl } = shader;\n gl.uniform3f(\n shader.uniform(\"uLineParams\"),\n 1 / projectionParameters.width,\n 1 / projectionParameters.height,\n featherWidthInPixels,\n );\n}\n","/**\n * @license\n * Copyright 2024 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getMemoizedBuffer } from \"#src/webgl/buffer.js\";\nimport type { GL } from \"#src/webgl/context.js\";\nimport { VERTICES_PER_QUAD } from \"#src/webgl/quad.js\";\n\n/**\n * Create a Float32Array of vertices gridded in a rectangle\n * Only grids along the x-axis are created, the y-axis is assumed to be the same for all grids\n */\nexport function createGriddedRectangleArray(\n numGrids: number,\n startX = -1,\n endX = 1,\n startY = 1,\n endY = -1,\n): Float32Array {\n const result = new Float32Array(numGrids * VERTICES_PER_QUAD * 2);\n const step = (endX - startX) / numGrids;\n let currentx = startX;\n for (let i = 0; i < numGrids; ++i) {\n const index = i * VERTICES_PER_QUAD * 2;\n\n // Triangle 1 - top-left, top-right, bottom-right\n result[index] = currentx; // top-left x\n result[index + 1] = startY; // top-left y\n result[index + 2] = currentx + step; // top-right x\n result[index + 3] = startY; // top-right y\n result[index + 4] = currentx + step; // bottom-right x\n result[index + 5] = endY; // bottom-right y\n\n // Triangle 2 - top-left, bottom-right, bottom-left\n result[index + 6] = currentx; // top-left x\n result[index + 7] = startY; // top-left y\n result[index + 8] = currentx + step; // bottom-right x\n result[index + 9] = endY; // bottom-right y\n result[index + 10] = currentx; // bottom-left x\n result[index + 11] = endY; // bottom-left y\n currentx += step;\n }\n return result;\n}\n\n/**\n * Get a buffer of vertices representing a rectangle that is gridded\n * along the x dimension, useful for drawing grids, such as a lookup table / heatmap\n */\nexport function getGriddedRectangleBuffer(\n gl: GL,\n numGrids: number,\n startX = -1,\n endX = 1,\n startY = 1,\n endY = -1,\n) {\n return getMemoizedBuffer(\n gl,\n WebGL2RenderingContext.ARRAY_BUFFER,\n createGriddedRectangleArray,\n numGrids,\n startX,\n endX,\n startY,\n endY,\n ).value;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Converts an HSV color (with h, s, v in [0,1]) to RGB (in range [0,1]).\n *\n * Based on goog/color/color.js in the Google Closure library.\n */\nexport function hsvToRgb(\n out: Float32Array,\n h: number,\n s: number,\n v: number,\n): Float32Array {\n h *= 6;\n const hueIndex = Math.floor(h);\n const remainder = h - hueIndex;\n const val1 = v * (1 - s);\n const val2 = v * (1 - s * remainder);\n const val3 = v * (1 - s * (1 - remainder));\n switch (hueIndex % 6) {\n case 0:\n out[0] = v;\n out[1] = val3;\n out[2] = val1;\n break;\n case 1:\n out[0] = val2;\n out[1] = v;\n out[2] = val1;\n break;\n case 2:\n out[0] = val1;\n out[1] = v;\n out[2] = val3;\n break;\n case 3:\n out[0] = val1;\n out[1] = val2;\n out[2] = v;\n break;\n case 4:\n out[0] = val3;\n out[1] = val1;\n out[2] = v;\n break;\n case 5:\n out[0] = v;\n out[1] = val1;\n out[2] = val2;\n break;\n }\n return out;\n}\n\n/**\n * Converts from RGB values (with r,g,b in range [0,1]) to an array of HSV values (in range [0, 1])\n *\n * Based on goog/color/color.js in the Google Closure library.\n */\nexport function rgbToHsv(\n out: Float32Array,\n r: number,\n g: number,\n b: number,\n): Float32Array {\n const max = Math.max(Math.max(r, g), b);\n const min = Math.min(Math.min(r, g), b);\n out[2] = max;\n if (min === max) {\n out[0] = 0;\n out[1] = 0;\n } else {\n const delta = max - min;\n out[1] = delta / max;\n\n if (r === max) {\n out[0] = (g - b) / delta;\n } else if (g === max) {\n out[0] = 2 + (b - r) / delta;\n } else {\n out[0] = 4 + (r - g) / delta;\n }\n out[0] /= 6.0;\n if (out[0] < 0.0) {\n out[0] += 1.0;\n }\n if (out[0] > 1.0) {\n out[0] -= 1.0;\n }\n }\n return out;\n}\n","/**\n * @license\n * Copyright 2018 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { WatchableValueInterface } from \"#src/trackable_value.js\";\nimport { parseRGBColorSpecification, serializeColor } from \"#src/util/color.js\";\nimport { hsvToRgb, rgbToHsv } from \"#src/util/colorspace.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport { vec3 } from \"#src/util/geom.js\";\n\nexport class ColorWidget<\n Color extends vec3 | undefined = vec3,\n> extends RefCounted {\n static template() {\n const element = document.createElement(\"input\");\n element.classList.add(\"neuroglancer-color-widget\");\n element.type = \"color\";\n return element;\n }\n\n constructor(\n public model: WatchableValueInterface,\n public getDefaultColor: () => vec3 = () => vec3.fromValues(1, 0, 0),\n public element = ColorWidget.template(),\n public unsetHandler = () => {},\n enableWheel = true,\n ) {\n super();\n element.addEventListener(\"change\", () => this.updateModel());\n element.addEventListener(\"input\", () => this.updateModel());\n if (enableWheel) {\n element.addEventListener(\"wheel\", (event) => {\n event.stopPropagation();\n event.preventDefault();\n this.adjustHueViaWheel(event);\n });\n }\n element.addEventListener(\"mousedown\", (evt) => {\n if (evt.button === 2) {\n evt.stopPropagation();\n unsetHandler();\n }\n });\n this.registerDisposer(model.changed.add(() => this.updateView()));\n this.updateView();\n }\n private getRGB() {\n return this.model.value ?? this.getDefaultColor();\n }\n private updateView() {\n this.element.value = serializeColor(this.getRGB());\n }\n private updateModel() {\n this.model.value = parseRGBColorSpecification(this.element.value) as Color;\n }\n\n adjustHueViaWheel(event: WheelEvent) {\n const rgb = this.getRGB();\n const temp = vec3.create();\n rgbToHsv(temp, rgb[0], rgb[1], rgb[2]);\n const { deltaY } = event;\n let hue = Math.round(temp[0] * 256);\n hue += deltaY > 0 ? 1 : deltaY < 0 ? -1 : 0;\n hue = (hue + 256) % 256;\n temp[0] = hue / 256;\n hsvToRgb(temp, temp[0], temp[1], temp[2]);\n this.model.value = temp as Color;\n }\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function removeChildren(element: HTMLElement) {\n while (true) {\n const child = element.firstChild;\n if (!child) {\n break;\n }\n element.removeChild(child);\n }\n}\n\nexport function removeFromParent(element: HTMLElement) {\n const { parentElement } = element;\n if (parentElement) {\n parentElement.removeChild(element);\n return true;\n }\n return false;\n}\n\nexport function updateInputFieldWidth(\n element: HTMLInputElement,\n length = Math.max(1, element.value.length),\n) {\n const newWidth = `${length}ch`;\n if (element.style.width !== newWidth) {\n // Force additional reflow to work around Chrome bug.\n element.style.width = \"0px\";\n element.offsetWidth;\n element.style.width = newWidth;\n }\n}\n\nexport function updateChildren(\n element: HTMLElement,\n children: Iterable,\n) {\n let nextChild = element.firstElementChild;\n for (const child of children) {\n if (child !== nextChild) {\n element.insertBefore(child, nextChild);\n }\n nextChild = child.nextElementSibling;\n }\n while (nextChild !== null) {\n const next = nextChild.nextElementSibling;\n element.removeChild(nextChild);\n nextChild = next;\n }\n}\n\nexport function isInputTextTarget(target: EventTarget | null) {\n if (!(target instanceof HTMLElement)) return false;\n if (\n target instanceof HTMLInputElement ||\n target instanceof HTMLTextAreaElement ||\n target.isContentEditable\n ) {\n return true;\n }\n return false;\n}\n\nexport function measureElementClone(element: HTMLElement) {\n const clone = element.cloneNode(/*deep=*/ true) as HTMLElement;\n clone.style.position = \"absolute\";\n document.body.appendChild(clone);\n return clone.getBoundingClientRect();\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport \"#src/widget/icon.css\";\n\nexport interface MakeIconOptions {\n text?: string;\n svg?: string;\n title?: string;\n onClick?: (this: HTMLElement, event: MouseEvent) => void;\n href?: string;\n}\n\nexport interface MakeHoverIconOptions extends MakeIconOptions {\n svgHover?: string;\n}\n\nexport function makeHoverIcon(options: MakeHoverIconOptions): HTMLElement {\n const element = makeIcon(options);\n if (options.svgHover) {\n element.classList.add(\"neuroglancer-icon-hover\");\n element.innerHTML += options.svgHover;\n }\n return element;\n}\n\nexport function makeIcon(options: MakeIconOptions): HTMLElement {\n const { title, onClick, href } = options;\n let element: HTMLDivElement | HTMLAnchorElement;\n if (href !== undefined) {\n element = document.createElement(\"a\");\n element.href = href;\n element.target = \"_blank\";\n } else {\n element = document.createElement(\"div\");\n }\n\n if (title !== undefined) {\n element.title = title;\n }\n if (onClick !== undefined) {\n element.addEventListener(\"click\", onClick);\n }\n const { svg } = options;\n element.className = \"neuroglancer-icon\";\n if (svg !== undefined) {\n element.innerHTML = svg;\n }\n if (options.text !== undefined) {\n element.appendChild(document.createTextNode(options.text));\n }\n return element;\n}\n","/**\n * @license\n * Copyright 2018 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @file Tabbed view widget.\n */\n\nimport \"#src/widget/tab_view.css\";\n\nimport type {\n WatchableValueChangeInterface,\n WatchableValueInterface,\n} from \"#src/trackable_value.js\";\nimport { animationFrameDebounce } from \"#src/util/animation_frame_debounce.js\";\nimport type { Owned } from \"#src/util/disposable.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport { removeChildren, removeFromParent } from \"#src/util/dom.js\";\nimport { NullarySignal, Signal } from \"#src/util/signal.js\";\nimport type { Trackable } from \"#src/util/trackable.js\";\nimport { WatchableVisibilityPriority } from \"#src/visibility_priority/frontend.js\";\n\nexport class Tab extends RefCounted {\n element = document.createElement(\"div\");\n\n get visible() {\n return this.visibility.visible;\n }\n\n constructor(\n public visibility = new WatchableVisibilityPriority(\n WatchableVisibilityPriority.VISIBLE,\n ),\n ) {\n super();\n const { element } = this;\n element.classList.add(\"neuroglancer-tab-content\");\n }\n\n disposed() {\n removeFromParent(this.element);\n super.disposed();\n }\n}\n\nexport class OptionSpecification extends RefCounted implements Trackable {\n changed = new NullarySignal();\n options = new Map();\n optionsChanged = new NullarySignal();\n\n private selectedValue: string | undefined = undefined;\n private defaultValue: string | undefined = undefined;\n\n get value() {\n const { selectedValue } = this;\n if (selectedValue !== undefined) {\n return selectedValue;\n }\n return this.defaultValue;\n }\n\n set default(value: string | undefined) {\n if (this.defaultValue !== value) {\n this.defaultValue = value;\n this.changed.dispatch();\n }\n }\n\n get default() {\n return this.defaultValue;\n }\n\n set value(value: string | undefined) {\n if (value !== undefined && this.ready_ && !this.options.has(value)) {\n value = undefined;\n }\n const { selectedValue } = this;\n if (selectedValue !== value) {\n this.selectedValue = value;\n this.changed.dispatch();\n }\n }\n\n get validValue() {\n const value = this.selectedValue;\n if (value === undefined || !this.options.has(value)) {\n return this.defaultValue;\n }\n return value;\n }\n\n add(id: string, value: T) {\n const { options } = this;\n if (options.has(id)) {\n throw new Error(`Option already defined: ${JSON.stringify(id)}.`);\n }\n options.set(id, value);\n this.optionsChanged.dispatch();\n if (this.defaultValue === undefined) {\n this.default = id;\n }\n }\n\n remove(id: string) {\n const { options } = this;\n if (!options.has(id)) {\n throw new Error(`Option is not defined: ${JSON.stringify(id)}.`);\n }\n options.delete(id);\n this.optionsChanged.dispatch();\n }\n\n toJSON() {\n const { value, defaultValue } = this;\n if (value === defaultValue) {\n return undefined;\n }\n return value;\n }\n\n reset() {\n this.value = undefined;\n }\n\n ready_ = true;\n\n /**\n * When `ready` is `false`, the selected `value` may be set to an unknown option.\n */\n get ready() {\n return this.ready_;\n }\n\n set ready(value: boolean) {\n if (value !== this.ready_) {\n this.ready_ = value;\n if (value) {\n // eslint-disable-next-line no-self-assign\n this.value = this.value;\n }\n this.changed.dispatch();\n }\n }\n\n restoreState(obj: any) {\n if (typeof obj !== \"string\") {\n obj = undefined;\n }\n this.value = obj;\n }\n}\n\nexport class StackView extends RefCounted {\n element = document.createElement(\"div\");\n tabs = new Map>();\n tabVisibilityChanged = new Signal<(id: TabId, visible: boolean) => void>();\n\n private displayedTab: TabId | undefined;\n\n get visible() {\n return this.visibility.visible;\n }\n\n private debouncedUpdateSelectedTab = this.registerCancellable(\n animationFrameDebounce(() => this.updateSelectedTab()),\n );\n\n flush() {\n this.debouncedUpdateSelectedTab.flush();\n }\n\n constructor(\n public getter: (id: TabId) => Owned,\n public selected: WatchableValueInterface,\n public visibility = new WatchableVisibilityPriority(\n WatchableVisibilityPriority.VISIBLE,\n ),\n public invalidateByDefault = false,\n ) {\n super();\n\n const { element } = this;\n element.className = \"neuroglancer-stack-view\";\n this.registerDisposer(\n visibility.changed.add(this.debouncedUpdateSelectedTab),\n );\n this.registerDisposer(\n selected.changed.add(this.debouncedUpdateSelectedTab),\n );\n this.updateSelectedTab();\n }\n\n invalidate(id: TabId) {\n const { tabs } = this;\n const tab = tabs.get(id);\n if (tab === undefined) {\n return;\n }\n tab.dispose();\n tabs.delete(id);\n if (id === this.displayedTab) {\n this.displayedTab = undefined;\n this.debouncedUpdateSelectedTab();\n }\n }\n\n private hideTab(id: TabId) {\n const tab = this.tabs.get(id);\n if (tab !== undefined) {\n tab.visibility.value = WatchableVisibilityPriority.IGNORED;\n tab.element.style.display = \"none\";\n }\n this.tabVisibilityChanged.dispatch(id, false);\n }\n\n private showTab(id: TabId) {\n const { tabs } = this;\n let tab = tabs.get(id);\n if (tab === undefined) {\n tab = this.getter(id);\n this.element.appendChild(tab.element);\n tabs.set(id, tab);\n }\n tab.element.style.display = \"\";\n tab.visibility.value = WatchableVisibilityPriority.VISIBLE;\n this.tabVisibilityChanged.dispatch(id, true);\n }\n\n private updateSelectedTab() {\n const { displayedTab } = this;\n const newTab = this.visible ? this.selected.value : undefined;\n if (\n newTab === displayedTab &&\n (newTab === undefined || this.tabs.has(newTab))\n ) {\n return;\n }\n if (displayedTab !== undefined) {\n this.hideTab(displayedTab);\n }\n if (this.invalidateByDefault) {\n this.invalidateAll();\n }\n this.displayedTab = newTab;\n if (newTab === undefined) {\n return;\n }\n this.showTab(newTab);\n }\n\n invalidateAll(predicate: ((id: TabId) => boolean) | undefined = undefined) {\n const { tabs } = this;\n for (const [id, tab] of tabs) {\n if (predicate?.(id)) continue;\n tabs.delete(id);\n tab.dispose();\n }\n this.debouncedUpdateSelectedTab();\n }\n\n disposed() {\n this.invalidateAll();\n removeFromParent(this.element);\n super.disposed();\n }\n}\n\nexport class TabSpecification extends OptionSpecification<{\n label: string;\n order?: number;\n getter: () => Owned;\n hidden?: WatchableValueInterface;\n}> {}\n\nfunction updateTabLabelVisibilityStyle(\n labelElement: HTMLElement,\n visible: boolean,\n) {\n const className = \"neuroglancer-selected-tab-label\";\n if (visible) {\n labelElement.classList.add(className);\n } else {\n labelElement.classList.remove(className);\n }\n}\n\nexport interface TabViewOptions {\n makeTab: (id: string) => Tab;\n selectedTab: WatchableValueInterface;\n tabs: WatchableValueChangeInterface<\n { id: string; label: string; hidden: boolean }[]\n >;\n handleTabElement?: (id: string, element: HTMLElement) => void;\n}\n\nexport class TabView extends RefCounted {\n element = document.createElement(\"div\");\n tabBar = document.createElement(\"div\");\n\n tabs: WatchableValueChangeInterface<\n { id: string; label: string; hidden: boolean }[]\n >;\n selectedTab: WatchableValueInterface;\n private handleTabElement:\n | ((id: string, element: HTMLElement) => void)\n | undefined;\n\n private stack: StackView;\n private tabLabels = new Map();\n private tabsGeneration = -1;\n\n get visible() {\n return this.visibility.visible;\n }\n\n private debouncedUpdateView = this.registerCancellable(\n animationFrameDebounce(() => this.updateTabs()),\n );\n\n constructor(\n options: TabViewOptions,\n public visibility = new WatchableVisibilityPriority(\n WatchableVisibilityPriority.VISIBLE,\n ),\n ) {\n super();\n this.tabs = options.tabs;\n this.selectedTab = options.selectedTab;\n this.handleTabElement = options.handleTabElement;\n const { element, tabBar } = this;\n element.className = \"neuroglancer-tab-view\";\n tabBar.className = \"neuroglancer-tab-view-bar\";\n element.appendChild(tabBar);\n this.registerDisposer(visibility.changed.add(this.debouncedUpdateView));\n const stack = (this.stack = this.registerDisposer(\n new StackView(\n options.makeTab,\n options.selectedTab,\n this.visibility,\n ),\n ));\n element.appendChild(stack.element);\n this.registerDisposer(options.tabs.changed.add(this.debouncedUpdateView));\n let prevSelectedId = this.selectedTab.value;\n this.registerDisposer(\n options.selectedTab.changed.add(() => {\n const tabs = this.tabs.value;\n const prevSelectedTab = tabs.find(({ id }) => id === prevSelectedId);\n if (prevSelectedTab?.hidden) {\n // hide hidden tab label when it is deselected\n this.tabs.changed.count++;\n this.debouncedUpdateView();\n } else {\n this.updateTabLabelStyles();\n }\n prevSelectedId = this.selectedTab.value;\n }),\n );\n this.updateTabs();\n }\n\n private updateTabLabelStyles() {\n const selectedId = this.selectedTab.value;\n for (const [id, element] of this.tabLabels) {\n updateTabLabelVisibilityStyle(element, id === selectedId);\n }\n }\n\n private updateTabs() {\n if (this.tabsGeneration !== this.tabs.changed.count) {\n this.destroyTabs();\n if (this.visible) {\n this.makeTabs();\n }\n }\n }\n\n private destroyTabs() {\n if (this.tabsGeneration === -1) {\n return;\n }\n this.tabLabels.clear();\n if (!this.visible) {\n this.stack.invalidateAll();\n } else {\n const tabs = this.tabs.value;\n this.stack.invalidateAll(\n (existingId) => tabs.find(({ id }) => id === existingId) !== undefined,\n );\n }\n removeChildren(this.tabBar);\n this.tabsGeneration = -1;\n }\n\n private makeTabs() {\n const { tabBar, tabLabels, handleTabElement } = this;\n for (const { id, label, hidden } of this.tabs.value) {\n if (hidden && id !== this.selectedTab.value) continue;\n const labelElement = document.createElement(\"div\");\n labelElement.classList.add(\"neuroglancer-tab-label\");\n labelElement.textContent = label;\n labelElement.addEventListener(\"click\", () => {\n this.selectedTab.value = id;\n });\n if (handleTabElement !== undefined) {\n handleTabElement(id, labelElement);\n }\n tabLabels.set(id, labelElement);\n tabBar.appendChild(labelElement);\n }\n this.updateTabLabelStyles();\n this.tabsGeneration = this.tabs.changed.count;\n }\n\n disposed() {\n removeChildren(this.tabBar);\n this.tabLabels.clear();\n removeFromParent(this.element);\n super.disposed();\n }\n}\n","/**\n * @license\n * Copyright 2020 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport \"#src/widget/invlerp.css\";\n\nimport svg_arrowLeft from \"ikonate/icons/arrow-left.svg?raw\";\nimport svg_arrowRight from \"ikonate/icons/arrow-right.svg?raw\";\nimport type { DisplayContext } from \"#src/display_context.js\";\nimport { IndirectRenderedPanel } from \"#src/display_context.js\";\nimport type { WatchableValueInterface } from \"#src/trackable_value.js\";\nimport type { ToolActivation } from \"#src/ui/tool.js\";\nimport { animationFrameDebounce } from \"#src/util/animation_frame_debounce.js\";\nimport type { DataType } from \"#src/util/data_type.js\";\nimport type { Owned } from \"#src/util/disposable.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport { removeChildren, updateInputFieldWidth } from \"#src/util/dom.js\";\nimport {\n EventActionMap,\n registerActionListener,\n} from \"#src/util/event_action_map.js\";\nimport type { DataTypeInterval } from \"#src/util/lerp.js\";\nimport {\n computeInvlerp,\n computeLerp,\n dataTypeCompare,\n dataTypeIntervalEqual,\n getClampedInterval,\n getClosestEndpoint,\n getIntervalBoundsEffectiveFraction,\n getIntervalBoundsEffectiveOffset,\n parseDataTypeValue,\n} from \"#src/util/lerp.js\";\nimport { MouseEventBinder } from \"#src/util/mouse_bindings.js\";\nimport { startRelativeMouseDrag } from \"#src/util/mouse_drag.js\";\nimport { Uint64 } from \"#src/util/uint64.js\";\nimport { getWheelZoomAmount } from \"#src/util/wheel_zoom.js\";\nimport type { WatchableVisibilityPriority } from \"#src/visibility_priority/frontend.js\";\nimport { getMemoizedBuffer } from \"#src/webgl/buffer.js\";\nimport type { GL } from \"#src/webgl/context.js\";\nimport type { ParameterizedEmitterDependentShaderGetter } from \"#src/webgl/dynamic_shader.js\";\nimport { parameterizedEmitterDependentShaderGetter } from \"#src/webgl/dynamic_shader.js\";\nimport type { HistogramSpecifications } from \"#src/webgl/empirical_cdf.js\";\nimport {\n defineLerpShaderFunction,\n enableLerpShaderFunction,\n} from \"#src/webgl/lerp.js\";\nimport {\n defineLineShader,\n drawLines,\n initializeLineShader,\n VERTICES_PER_LINE,\n} from \"#src/webgl/lines.js\";\nimport { ShaderBuilder } from \"#src/webgl/shader.js\";\nimport { getShaderType } from \"#src/webgl/shader_lib.js\";\nimport type { InvlerpParameters } from \"#src/webgl/shader_ui_controls.js\";\nimport { getSquareCornersBuffer } from \"#src/webgl/square_corners_buffer.js\";\nimport { setRawTextureParameters } from \"#src/webgl/texture.js\";\nimport { makeIcon } from \"#src/widget/icon.js\";\nimport type { LayerControlTool } from \"#src/widget/layer_control.js\";\nimport type { LegendShaderOptions } from \"#src/widget/shader_controls.js\";\nimport { Tab } from \"#src/widget/tab_view.js\";\n\nconst inputEventMap = EventActionMap.fromObject({\n \"shift?+mousedown0\": { action: \"set\" },\n \"shift?+alt+mousedown0\": { action: \"adjust-window-via-drag\" },\n \"shift?+wheel\": { action: \"zoom-via-wheel\" },\n});\n\nexport function createCDFLineShader(gl: GL, textureUnit: symbol) {\n const builder = new ShaderBuilder(gl);\n defineLineShader(builder);\n builder.addTextureSampler(\"sampler2D\", \"uHistogramSampler\", textureUnit);\n builder.addOutputBuffer(\"vec4\", \"out_color\", 0);\n builder.addAttribute(\"uint\", \"aDataValue\");\n builder.addUniform(\"float\", \"uBoundsFraction\");\n builder.addVertexCode(`\nfloat getCount(int i) {\n return texelFetch(uHistogramSampler, ivec2(i, 0), 0).x;\n}\nvec4 getVertex(float cdf, int i) {\n float x;\n if (i == 0) {\n x = -1.0;\n } else if (i == 255) {\n x = 1.0;\n } else {\n x = float(i) / 254.0 * uBoundsFraction * 2.0 - 1.0;\n }\n return vec4(x, cdf * (2.0 - uLineParams.y) - 1.0 + uLineParams.y * 0.5, 0.0, 1.0);\n}\n`);\n builder.setVertexMain(`\nint lineNumber = int(aDataValue);\nint dataValue = lineNumber;\nfloat cumSum = 0.0;\nfor (int i = 0; i <= dataValue; ++i) {\n cumSum += getCount(i);\n}\nfloat total = cumSum + getCount(dataValue + 1);\nfloat cumSumEnd = dataValue == ${NUM_CDF_LINES - 1} ? cumSum : total;\nif (dataValue == ${NUM_CDF_LINES - 1}) {\n cumSum + getCount(dataValue + 1);\n}\nfor (int i = dataValue + 2; i < 256; ++i) {\n total += getCount(i);\n}\ntotal = max(total, 1.0);\nfloat cdf1 = cumSum / total;\nfloat cdf2 = cumSumEnd / total;\nemitLine(getVertex(cdf1, lineNumber), getVertex(cdf2, lineNumber + 1), 1.0);\n`);\n builder.setFragmentMain(`\nout_color = vec4(0.0, 1.0, 1.0, getLineAlpha());\n`);\n return builder.build();\n}\n\nexport class CdfController<\n T extends RangeAndWindowIntervals,\n> extends RefCounted {\n constructor(\n public element: HTMLElement,\n public dataType: DataType,\n public getModel: () => T,\n public setModel: (value: T) => void,\n ) {\n super();\n element.title = inputEventMap.describe();\n this.registerDisposer(new MouseEventBinder(element, inputEventMap));\n registerActionListener(element, \"set\", (actionEvent) => {\n const mouseEvent = actionEvent.detail;\n const bounds = this.getModel();\n const value = this.getTargetValue(mouseEvent);\n if (value === undefined) return;\n const clampedRange = getClampedInterval(bounds.window, bounds.range);\n const endpointIndex = getClosestEndpoint(clampedRange, value);\n const setEndpoint = (value: number | Uint64) => {\n const bounds = this.getModel();\n this.setModel(\n getUpdatedRangeAndWindowParameters(\n bounds,\n \"range\",\n endpointIndex,\n value,\n ),\n );\n };\n setEndpoint(value);\n startRelativeMouseDrag(mouseEvent, (newEvent: MouseEvent) => {\n const value = this.getTargetValue(newEvent);\n if (value === undefined) return;\n setEndpoint(value);\n });\n });\n\n registerActionListener(\n element,\n \"adjust-window-via-drag\",\n (actionEvent) => {\n // If user starts drag on left half, then right bound is fixed, and left bound is adjusted to\n // keep the value under the mouse fixed. If user starts drag on right half, the left bound is\n // fixed and right bound is adjusted.\n const mouseEvent = actionEvent.detail;\n const initialRelativeX = this.getTargetFraction(mouseEvent);\n const initialValue = this.getWindowLerp(initialRelativeX);\n // Index for bound being adjusted\n const endpointIndex = initialRelativeX < 0.5 ? 0 : 1;\n const setEndpoint = (value: number | Uint64) => {\n const bounds = this.getModel();\n this.setModel(\n getUpdatedRangeAndWindowParameters(\n bounds,\n \"window\",\n endpointIndex,\n value,\n ),\n );\n };\n startRelativeMouseDrag(mouseEvent, (newEvent: MouseEvent) => {\n const window = this.getModel().window;\n const relativeX = this.getTargetFraction(newEvent);\n if (endpointIndex === 0) {\n // Need to find x such that: lerp([x, window[1]], relativeX) == initialValue\n // Equivalently: lerp([initialValue, window[1]], -relativeX / ( 1 - relativeX))\n setEndpoint(\n computeLerp(\n [initialValue, window[1]] as DataTypeInterval,\n this.dataType,\n -relativeX / (1 - relativeX),\n ),\n );\n } else {\n // Need to find x such that: lerp([window[0], x], relativeX) == initialValue\n // Equivalently: lerp([window[0], initialValue], 1 / relativeX)\n setEndpoint(\n computeLerp(\n [window[0], initialValue] as DataTypeInterval,\n this.dataType,\n 1 / relativeX,\n ),\n );\n }\n });\n },\n );\n\n registerActionListener(\n element,\n \"zoom-via-wheel\",\n (actionEvent) => {\n const wheelEvent = actionEvent.detail;\n const zoomAmount = getWheelZoomAmount(wheelEvent);\n const relativeX = this.getTargetFraction(wheelEvent);\n const { dataType } = this;\n const bounds = this.getModel();\n const newLower = computeLerp(\n bounds.window,\n dataType,\n relativeX * (1 - zoomAmount),\n );\n const newUpper = computeLerp(\n bounds.window,\n dataType,\n (1 - relativeX) * zoomAmount + relativeX,\n );\n this.setModel({\n ...bounds,\n window: [newLower, newUpper] as DataTypeInterval,\n range: bounds.range,\n });\n },\n );\n }\n\n /**\n * Get fraction of distance in x along bounding rect for a MouseEvent.\n */\n getTargetFraction(event: MouseEvent) {\n const clientRect = this.element.getBoundingClientRect();\n return (event.clientX - clientRect.left) / clientRect.width;\n }\n\n /**\n * Interpolate a value along the model interval.\n * @param relativeX Relative x coordinate within the interval.\n * @returns Interpolated value.\n */\n getWindowLerp(relativeX: number) {\n return computeLerp(this.getModel().window, this.dataType, relativeX);\n }\n\n getTargetValue(event: MouseEvent): number | Uint64 | undefined {\n const targetFraction = this.getTargetFraction(event);\n if (!Number.isFinite(targetFraction)) return undefined;\n return this.getWindowLerp(targetFraction);\n }\n}\n\nconst histogramSamplerTextureUnit = Symbol(\"histogramSamplerTexture\");\n\n/**\n * An interval with coordinates `range` and endpoint values `window`.\n * Can be thought of representing associated intervals in x (range) and y (window).\n */\nexport interface RangeAndWindowIntervals {\n range: DataTypeInterval;\n window: DataTypeInterval;\n}\n\n/**\n * Update the value of one endpoint, and return new interval.\n * @param existingBounds Initial bounds.\n * @param boundType 'range' to update endpoint coordinates, 'window' to update endpoint values.\n * @param endpointIndex Index of bound to update.\n * @param newEndpoint New value of bound being updated.\n * @param fitRangeInWindow\n * @returns New bounds.\n */\nexport function getUpdatedRangeAndWindowParameters<\n T extends RangeAndWindowIntervals,\n>(\n existingBounds: T,\n boundType: \"range\" | \"window\",\n endpointIndex: number,\n newEndpoint: number | Uint64,\n fitRangeInWindow = false,\n): T {\n const newBounds = { ...existingBounds };\n const existingInterval = existingBounds[boundType];\n newBounds[boundType] = [\n existingInterval[0],\n existingInterval[1],\n ] as DataTypeInterval;\n // Update bound\n newBounds[boundType][endpointIndex] = newEndpoint;\n if (\n boundType === \"window\" &&\n dataTypeCompare(newEndpoint, existingInterval[1 - endpointIndex]) *\n (2 * endpointIndex - 1) <\n 0\n ) {\n // If new endpoint has gone past other bound, adjust other bound to match\n newBounds[boundType][1 - endpointIndex] = newEndpoint;\n }\n if (boundType === \"range\" && fitRangeInWindow) {\n // Also adjust `window` endpoint to contain the new endpoint.\n const newWindowInterval = [\n existingBounds.window[0],\n existingBounds.window[1],\n ] as DataTypeInterval;\n for (let i = 0; i < 2; ++i) {\n if (\n dataTypeCompare(newEndpoint, newWindowInterval[i]) * (2 * i - 1) >\n 0\n ) {\n newWindowInterval[i] = newEndpoint;\n }\n }\n newBounds.window = newWindowInterval;\n }\n return newBounds;\n}\n\n// 256 bins in total. The first and last bin are for values below the lower bound/above the upper\n// bound.\nconst NUM_HISTOGRAM_BINS_IN_RANGE = 254;\nexport const NUM_CDF_LINES = NUM_HISTOGRAM_BINS_IN_RANGE + 1;\n\n/**\n * Panel that shows Cumulative Distribution Function (CDF) of visible data.\n */\nclass CdfPanel extends IndirectRenderedPanel {\n get drawOrder() {\n return 100;\n }\n controller = this.registerDisposer(\n new CdfController(\n this.element,\n this.parent.dataType,\n () => this.parent.trackable.value,\n (value: InvlerpParameters) => {\n this.parent.trackable.value = value;\n },\n ),\n );\n constructor(public parent: InvlerpWidget) {\n super(parent.display, document.createElement(\"div\"), parent.visibility);\n const { element } = this;\n element.classList.add(\"neuroglancer-invlerp-cdfpanel\");\n }\n\n private dataValuesBuffer = this.registerDisposer(\n getMemoizedBuffer(this.gl, WebGL2RenderingContext.ARRAY_BUFFER, () => {\n const array = new Uint8Array(NUM_CDF_LINES * VERTICES_PER_LINE);\n for (let i = 0; i < NUM_CDF_LINES; ++i) {\n for (let j = 0; j < VERTICES_PER_LINE; ++j) {\n array[i * VERTICES_PER_LINE + j] = i;\n }\n }\n return array;\n }),\n ).value;\n\n private lineShader = this.registerDisposer(\n (() => createCDFLineShader(this.gl, histogramSamplerTextureUnit))(),\n );\n\n private regionCornersBuffer = getSquareCornersBuffer(this.gl, 0, -1, 1, 1);\n\n private regionShader = this.registerDisposer(\n (() => {\n const builder = new ShaderBuilder(this.gl);\n builder.addAttribute(\"vec2\", \"aVertexPosition\");\n builder.addUniform(\"vec2\", \"uBounds\");\n builder.addUniform(\"vec4\", \"uColor\");\n builder.addOutputBuffer(\"vec4\", \"out_color\", 0);\n builder.setVertexMain(`\ngl_Position = vec4(mix(uBounds[0], uBounds[1], aVertexPosition.x) * 2.0 - 1.0, aVertexPosition.y, 0.0, 1.0);\n`);\n builder.setFragmentMain(`\nout_color = uColor;\n`);\n return builder.build();\n })(),\n );\n\n drawIndirect() {\n const {\n lineShader,\n gl,\n regionShader,\n parent: {\n dataType,\n trackable: { value: bounds },\n },\n } = this;\n this.setGLLogicalViewport();\n gl.clearColor(0.0, 0.0, 0.0, 0.0);\n gl.clear(WebGL2RenderingContext.COLOR_BUFFER_BIT);\n gl.enable(WebGL2RenderingContext.BLEND);\n gl.blendFunc(\n WebGL2RenderingContext.SRC_ALPHA,\n WebGL2RenderingContext.ONE_MINUS_SRC_ALPHA,\n );\n gl.disable(WebGL2RenderingContext.DEPTH_TEST);\n gl.disable(WebGL2RenderingContext.STENCIL_TEST);\n {\n regionShader.bind();\n gl.uniform4f(regionShader.uniform(\"uColor\"), 0.2, 0.2, 0.2, 1.0);\n const fraction0 = computeInvlerp(bounds.window, bounds.range[0]);\n const fraction1 = computeInvlerp(bounds.window, bounds.range[1]);\n const effectiveFraction = getIntervalBoundsEffectiveFraction(\n dataType,\n bounds.window,\n );\n gl.uniform2f(\n regionShader.uniform(\"uBounds\"),\n Math.min(fraction0, fraction1) * effectiveFraction,\n Math.max(fraction0, fraction1) * effectiveFraction +\n (1 - effectiveFraction),\n );\n const aVertexPosition = regionShader.attribute(\"aVertexPosition\");\n this.regionCornersBuffer.bindToVertexAttrib(\n aVertexPosition,\n /*componentsPerVertexAttribute=*/ 2,\n /*attributeType=*/ WebGL2RenderingContext.FLOAT,\n );\n gl.drawArrays(WebGL2RenderingContext.TRIANGLE_FAN, 0, 4);\n gl.disableVertexAttribArray(aVertexPosition);\n }\n if (this.parent.histogramSpecifications.producerVisibility.visible) {\n const { renderViewport } = this;\n lineShader.bind();\n initializeLineShader(\n lineShader,\n {\n width: renderViewport.logicalWidth,\n height: renderViewport.logicalHeight,\n },\n /*featherWidthInPixels=*/ 1.0,\n );\n const histogramTextureUnit = lineShader.textureUnit(\n histogramSamplerTextureUnit,\n );\n gl.uniform1f(\n lineShader.uniform(\"uBoundsFraction\"),\n getIntervalBoundsEffectiveFraction(dataType, bounds.window),\n );\n gl.activeTexture(WebGL2RenderingContext.TEXTURE0 + histogramTextureUnit);\n gl.bindTexture(WebGL2RenderingContext.TEXTURE_2D, this.parent.texture);\n setRawTextureParameters(gl);\n const aDataValue = lineShader.attribute(\"aDataValue\");\n this.dataValuesBuffer.bindToVertexAttribI(\n aDataValue,\n /*componentsPerVertexAttribute=*/ 1,\n /*attributeType=*/ WebGL2RenderingContext.UNSIGNED_BYTE,\n );\n drawLines(gl, /*linesPerInstance=*/ NUM_CDF_LINES, /*numInstances=*/ 1);\n gl.disableVertexAttribArray(aDataValue);\n gl.bindTexture(WebGL2RenderingContext.TEXTURE_2D, null);\n }\n gl.disable(WebGL2RenderingContext.BLEND);\n }\n\n isReady() {\n return true;\n }\n}\n\nfunction dummyColorLegendShaderModule() {}\n\nclass ColorLegendPanel extends IndirectRenderedPanel {\n private shaderOptions: LegendShaderOptions;\n constructor(public parent: InvlerpWidget) {\n super(parent.display, document.createElement(\"div\"), parent.visibility);\n const { element } = this;\n element.classList.add(\"neuroglancer-invlerp-legend-panel\");\n const shaderOptions = (this.shaderOptions = parent.legendShaderOptions!);\n this.shaderGetter = parameterizedEmitterDependentShaderGetter(\n this,\n this.gl,\n {\n ...shaderOptions,\n memoizeKey: { id: \"colorLegendShader\", base: shaderOptions.memoizeKey },\n defineShader: (builder, parameters, extraParameters) => {\n builder.addOutputBuffer(\"vec4\", \"v4f_fragData0\", 0);\n builder.addAttribute(\"vec2\", \"aVertexPosition\");\n builder.addUniform(\"float\", \"uLegendOffset\");\n builder.addVarying(\"float\", \"vLinearPosition\");\n builder.setVertexMain(`\ngl_Position = vec4(aVertexPosition, 0.0, 1.0);\nvLinearPosition = -uLegendOffset + ((aVertexPosition.x + 1.0) * 0.5) * (1.0 + 2.0 * uLegendOffset);\n`);\n const dataType = this.parent.dataType;\n const shaderDataType = getShaderType(dataType);\n builder.addFragmentCode(\n defineLerpShaderFunction(builder, \"ng_colorLegendLerp\", dataType),\n );\n builder.addFragmentCode(`\nvoid emit(vec4 v) {\n v4f_fragData0 = v;\n}\n${shaderDataType} getDataValue() {\n return ng_colorLegendLerp(vLinearPosition);\n}\n${shaderDataType} getDataValue(int dummyChannel) {\n return getDataValue();\n}\n${shaderDataType} getInterpolatedDataValue() {\n return getDataValue();\n}\n${shaderDataType} getInterpolatedDataValue(int dummyChannel) {\n return getDataValue();\n}\n`);\n shaderOptions.defineShader(builder, parameters, extraParameters);\n },\n },\n );\n }\n\n private shaderGetter: ParameterizedEmitterDependentShaderGetter;\n\n private cornersBuffer = getSquareCornersBuffer(this.gl, -1, -1, 1, 1);\n\n drawIndirect() {\n const shaderResult = this.shaderGetter(dummyColorLegendShaderModule);\n const { shader } = shaderResult;\n if (shader === null) return;\n this.setGLLogicalViewport();\n const { gl } = this;\n gl.clearColor(0.0, 0.0, 0.0, 0.0);\n gl.clear(WebGL2RenderingContext.COLOR_BUFFER_BIT);\n shader.bind();\n this.shaderOptions.initializeShader(shaderResult);\n gl.enable(WebGL2RenderingContext.BLEND);\n const {\n trackable: {\n value: { window },\n },\n dataType,\n } = this.parent;\n enableLerpShaderFunction(\n shader,\n \"ng_colorLegendLerp\",\n this.parent.dataType,\n window,\n );\n const legendOffset = getIntervalBoundsEffectiveOffset(dataType, window);\n gl.uniform1f(\n shader.uniform(\"uLegendOffset\"),\n Number.isFinite(legendOffset) ? legendOffset : 0,\n );\n gl.blendFunc(\n WebGL2RenderingContext.SRC_ALPHA,\n WebGL2RenderingContext.ONE_MINUS_SRC_ALPHA,\n );\n gl.disable(WebGL2RenderingContext.DEPTH_TEST);\n gl.disable(WebGL2RenderingContext.STENCIL_TEST);\n const aVertexPosition = shader.attribute(\"aVertexPosition\");\n this.cornersBuffer.bindToVertexAttrib(\n aVertexPosition,\n /*componentsPerVertexAttribute=*/ 2,\n /*attributeType=*/ WebGL2RenderingContext.FLOAT,\n );\n gl.drawArrays(WebGL2RenderingContext.TRIANGLE_FAN, 0, 4);\n gl.disableVertexAttribArray(aVertexPosition);\n }\n\n isReady() {\n return true;\n }\n}\n\nfunction createRangeBoundInput(\n boundType: \"range\" | \"window\",\n endpoint: number,\n) {\n const e = document.createElement(\"input\");\n e.addEventListener(\"focus\", () => {\n e.select();\n });\n e.classList.add(\"neuroglancer-invlerp-widget-bound\");\n e.classList.add(`neuroglancer-invlerp-widget-${boundType}-bound`);\n e.type = \"text\";\n e.spellcheck = false;\n e.autocomplete = \"off\";\n e.title =\n boundType === \"range\"\n ? `Data value that maps to ${endpoint}`\n : `${endpoint === 0 ? \"Lower\" : \"Upper\"} bound for distribution`;\n return e;\n}\n\nfunction createRangeBoundInputs(\n boundType: \"range\" | \"window\",\n dataType: DataType,\n model: WatchableValueInterface,\n) {\n const container = document.createElement(\"div\");\n container.classList.add(\"neuroglancer-invlerp-widget-bounds\");\n container.classList.add(`neuroglancer-invlerp-widget-${boundType}-bounds`);\n const inputs = [\n createRangeBoundInput(boundType, 0),\n createRangeBoundInput(boundType, 1),\n ] as [HTMLInputElement, HTMLInputElement];\n for (let endpointIndex = 0; endpointIndex < 2; ++endpointIndex) {\n const input = inputs[endpointIndex];\n input.addEventListener(\"input\", () => {\n updateInputBoundWidth(input);\n });\n input.addEventListener(\"change\", () => {\n const existingBounds = model.value;\n const existingInterval = existingBounds[boundType];\n try {\n const value = parseDataTypeValue(dataType, input.value);\n model.value = getUpdatedRangeAndWindowParameters(\n existingBounds,\n boundType,\n endpointIndex,\n value,\n /*fitRangeInWindow=*/ true,\n );\n } catch {\n updateInputBoundValue(input, existingInterval[endpointIndex]);\n }\n });\n }\n let spacers: [HTMLElement, HTMLElement, HTMLElement] | undefined;\n container.appendChild(inputs[0]);\n container.appendChild(inputs[1]);\n if (boundType === \"range\") {\n spacers = [\n document.createElement(\"div\"),\n document.createElement(\"div\"),\n document.createElement(\"div\"),\n ];\n spacers[1].classList.add(\"neuroglancer-invlerp-widget-range-spacer\");\n container.insertBefore(spacers[0], inputs[0]);\n container.insertBefore(spacers[1], inputs[1]);\n container.appendChild(spacers[2]);\n }\n return { container, inputs, spacers };\n}\n\nexport function updateInputBoundWidth(inputElement: HTMLInputElement) {\n updateInputFieldWidth(\n inputElement,\n Math.max(1, inputElement.value.length + 0.1),\n );\n}\n\nexport function updateInputBoundValue(\n inputElement: HTMLInputElement,\n bound: number | Uint64,\n) {\n let boundString: string;\n if (bound instanceof Uint64 || Number.isInteger(bound)) {\n boundString = bound.toString();\n } else {\n boundString = bound.toPrecision(6);\n }\n inputElement.value = boundString;\n updateInputBoundWidth(inputElement);\n}\n\nexport function invertInvlerpRange(\n trackable: WatchableValueInterface,\n) {\n const bounds = trackable.value;\n const { range } = bounds;\n trackable.value = {\n ...bounds,\n range: [range[1], range[0]] as DataTypeInterval,\n };\n}\n\nexport function adjustInvlerpContrast(\n dataType: DataType,\n trackable: WatchableValueInterface,\n scaleFactor: number,\n) {\n const bounds = trackable.value;\n const newLower = computeLerp(bounds.range, dataType, 0.5 - scaleFactor / 2);\n const newUpper = computeLerp(bounds.range, dataType, 0.5 + scaleFactor / 2);\n trackable.value = {\n ...bounds,\n range: [newLower, newUpper] as DataTypeInterval,\n };\n}\n\nexport function adjustInvlerpBrightnessContrast(\n dataType: DataType,\n trackable: WatchableValueInterface,\n baseRange: DataTypeInterval,\n brightnessAmount: number,\n contrastAmount: number,\n) {\n const scaleFactor = Math.exp(contrastAmount);\n const bounds = trackable.value;\n const newLower = computeLerp(\n baseRange,\n dataType,\n 0.5 - scaleFactor / 2 + brightnessAmount,\n );\n const newUpper = computeLerp(\n baseRange,\n dataType,\n 0.5 + scaleFactor / 2 + brightnessAmount,\n );\n trackable.value = {\n ...bounds,\n range: [newLower, newUpper] as DataTypeInterval,\n };\n}\n\nexport class InvlerpWidget extends Tab {\n cdfPanel = this.registerDisposer(new CdfPanel(this));\n boundElements = {\n range: createRangeBoundInputs(\"range\", this.dataType, this.trackable),\n window: createRangeBoundInputs(\"window\", this.dataType, this.trackable),\n };\n invertArrows: HTMLElement[];\n get texture() {\n return this.histogramSpecifications.getFramebuffers(this.display.gl)[\n this.histogramIndex\n ].colorBuffers[0].texture;\n }\n private invertRange() {\n invertInvlerpRange(this.trackable);\n }\n constructor(\n visibility: WatchableVisibilityPriority,\n public display: DisplayContext,\n public dataType: DataType,\n public trackable: WatchableValueInterface,\n public histogramSpecifications: HistogramSpecifications,\n public histogramIndex: number,\n public legendShaderOptions: LegendShaderOptions | undefined,\n ) {\n super(visibility);\n this.registerDisposer(\n histogramSpecifications.visibility.add(this.visibility),\n );\n const { element, boundElements } = this;\n if (legendShaderOptions !== undefined) {\n const legendPanel = this.registerDisposer(new ColorLegendPanel(this));\n element.appendChild(legendPanel.element);\n }\n const makeArrow = (svg: string) => {\n const icon = makeIcon({\n svg,\n title: \"Invert range\",\n onClick: () => {\n this.invertRange();\n },\n });\n boundElements.range.spacers![1].appendChild(icon);\n return icon;\n };\n this.invertArrows = [makeArrow(svg_arrowRight), makeArrow(svg_arrowLeft)];\n element.appendChild(boundElements.range.container);\n element.appendChild(this.cdfPanel.element);\n element.classList.add(\"neuroglancer-invlerp-widget\");\n element.appendChild(boundElements.window.container);\n this.updateView();\n this.registerDisposer(\n trackable.changed.add(\n this.registerCancellable(\n animationFrameDebounce(() => this.updateView()),\n ),\n ),\n );\n }\n\n updateView() {\n const { boundElements } = this;\n const {\n trackable: { value: bounds },\n dataType,\n } = this;\n for (let i = 0; i < 2; ++i) {\n updateInputBoundValue(boundElements.range.inputs[i], bounds.range[i]);\n updateInputBoundValue(boundElements.window.inputs[i], bounds.window[i]);\n }\n const reversed = dataTypeCompare(bounds.range[0], bounds.range[1]) > 0;\n boundElements.range.container.style.flexDirection = !reversed\n ? \"row\"\n : \"row-reverse\";\n const clampedRange = getClampedInterval(bounds.window, bounds.range);\n const spacers = boundElements.range.spacers!;\n const effectiveFraction = getIntervalBoundsEffectiveFraction(\n dataType,\n bounds.window,\n );\n const leftOffset =\n computeInvlerp(bounds.window, clampedRange[reversed ? 1 : 0]) *\n effectiveFraction;\n const rightOffset =\n computeInvlerp(bounds.window, clampedRange[reversed ? 0 : 1]) *\n effectiveFraction +\n (1 - effectiveFraction);\n spacers[reversed ? 2 : 0].style.width = `${leftOffset * 100}%`;\n spacers[reversed ? 0 : 2].style.width = `${(1 - rightOffset) * 100}%`;\n const { invertArrows } = this;\n invertArrows[reversed ? 1 : 0].style.display = \"\";\n invertArrows[reversed ? 0 : 1].style.display = \"none\";\n }\n}\n\nexport class VariableDataTypeInvlerpWidget extends Tab {\n invlerpWidget: Owned;\n constructor(\n visibility: WatchableVisibilityPriority,\n public display: DisplayContext,\n public watchableDataType: WatchableValueInterface,\n public trackable: WatchableValueInterface,\n public histogramSpecifications: HistogramSpecifications,\n public histogramIndex: number,\n public legendShaderOptions: LegendShaderOptions | undefined,\n ) {\n super(visibility);\n this.invlerpWidget = this.makeInvlerpWidget();\n this.registerDisposer(\n watchableDataType.changed.add(() => {\n removeChildren(this.element);\n this.invlerpWidget.dispose();\n this.invlerpWidget = this.makeInvlerpWidget();\n }),\n );\n }\n\n get dataType() {\n return this.watchableDataType.value;\n }\n\n disposed() {\n this.invlerpWidget.dispose();\n super.disposed();\n }\n\n private makeInvlerpWidget() {\n const { dataType } = this;\n const widget = new InvlerpWidget(\n this.visibility,\n this.display,\n dataType,\n this.trackable,\n this.histogramSpecifications,\n this.histogramIndex,\n this.legendShaderOptions,\n );\n this.element.appendChild(widget.element);\n return widget;\n }\n}\n\nconst TOOL_INPUT_EVENT_MAP = EventActionMap.fromObject({\n \"at:shift+wheel\": { action: \"adjust-contrast-via-wheel\" },\n \"at:shift+mousedown0\": { action: \"adjust-via-drag\" },\n \"at:shift+mousedown2\": { action: \"invert-range\" },\n});\n\nexport function activateInvlerpTool(\n activation: ToolActivation,\n control: InvlerpWidget | VariableDataTypeInvlerpWidget,\n) {\n activation.bindInputEventMap(TOOL_INPUT_EVENT_MAP);\n activation.bindAction(\"adjust-contrast-via-wheel\", (event) => {\n event.stopPropagation();\n const zoomAmount = getWheelZoomAmount(event.detail);\n adjustInvlerpContrast(control.dataType, control.trackable, zoomAmount);\n });\n activation.bindAction(\"adjust-via-drag\", (event) => {\n event.stopPropagation();\n let baseScreenX = event.detail.screenX;\n let baseScreenY = event.detail.screenY;\n let baseRange = control.trackable.value.range;\n let prevRange = baseRange;\n let prevScreenX = baseScreenX;\n let prevScreenY = baseScreenY;\n startRelativeMouseDrag(event.detail, (newEvent) => {\n const curRange = control.trackable.value.range;\n const curScreenX = newEvent.screenX;\n const curScreenY = newEvent.screenY;\n if (!dataTypeIntervalEqual(control.dataType, curRange, prevRange)) {\n baseRange = curRange;\n baseScreenX = prevScreenX;\n baseScreenY = prevScreenY;\n }\n adjustInvlerpBrightnessContrast(\n control.dataType,\n control.trackable,\n baseRange,\n ((curScreenY - baseScreenY) * 2) / screen.height,\n ((curScreenX - baseScreenX) * 4) / screen.width,\n );\n prevRange = control.trackable.value.range;\n prevScreenX = curScreenX;\n prevScreenY = curScreenY;\n });\n });\n activation.bindAction(\"invert-range\", (event) => {\n event.stopPropagation();\n invertInvlerpRange(control.trackable);\n });\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport svg_close from \"ikonate/icons/close.svg?raw\";\nimport type { MakeIconOptions } from \"#src/widget/icon.js\";\nimport { makeIcon } from \"#src/widget/icon.js\";\n\nexport function makeCloseButton(options: MakeIconOptions = {}) {\n return makeIcon({ svg: svg_close, ...options });\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport \"#src/status.css\";\n\nimport { makeCloseButton } from \"#src/widget/close_button.js\";\n\nlet statusContainer: HTMLElement | null = null;\nlet modalStatusContainer: HTMLElement | null = null;\n\nexport const DEFAULT_STATUS_DELAY = 200;\n\nexport type Delay = boolean | number;\n\nexport class StatusMessage {\n element: HTMLElement;\n modalElementWrapper: HTMLElement | undefined;\n private timer: number | null;\n constructor(delay: Delay = false, modal = false) {\n if (statusContainer === null) {\n statusContainer = document.createElement(\"ul\");\n statusContainer.id = \"statusContainer\";\n statusContainer.tabIndex = -1;\n const el: HTMLElement | null = document.getElementById(\n \"neuroglancer-container\",\n );\n if (el) {\n el.appendChild(statusContainer);\n } else {\n document.body.appendChild(statusContainer);\n }\n }\n if (modal && modalStatusContainer === null) {\n modalStatusContainer = document.createElement(\"ul\");\n modalStatusContainer.id = \"statusContainerModal\";\n const el: HTMLElement | null = document.getElementById(\n \"neuroglancer-container\",\n );\n if (el) {\n el.appendChild(modalStatusContainer);\n } else {\n document.body.appendChild(modalStatusContainer);\n }\n }\n const element = document.createElement(\"li\");\n this.element = element;\n if (delay === true) {\n delay = DEFAULT_STATUS_DELAY;\n }\n if (delay !== false) {\n this.setVisible(false);\n this.timer = window.setTimeout(this.setVisible.bind(this, true), delay);\n } else {\n this.timer = null;\n }\n if (modal) {\n const modalElementWrapper = document.createElement(\"div\");\n const dismissModalElement = makeCloseButton({\n title: \"Dismiss\",\n onClick: () => {\n this.dismissModal();\n },\n });\n dismissModalElement.classList.add(\"dismiss-modal\");\n dismissModalElement.addEventListener(\"click\", () => this.dismissModal());\n modalElementWrapper.appendChild(dismissModalElement);\n modalElementWrapper.appendChild(element);\n this.modalElementWrapper = modalElementWrapper;\n modalStatusContainer!.appendChild(modalElementWrapper);\n } else {\n statusContainer.appendChild(element);\n }\n }\n dispose() {\n if (this.modalElementWrapper) {\n modalStatusContainer!.removeChild(this.modalElementWrapper);\n } else {\n statusContainer!.removeChild(this.element);\n }\n this.element = undefined;\n if (this.timer !== null) {\n clearTimeout(this.timer);\n }\n }\n dismissModal() {\n if (this.modalElementWrapper) {\n modalStatusContainer!.removeChild(this.modalElementWrapper);\n this.modalElementWrapper = undefined;\n statusContainer!.appendChild(this.element);\n }\n }\n setText(text: string, makeVisible?: boolean) {\n this.element.textContent = text;\n if (makeVisible) {\n this.setVisible(true);\n }\n }\n setHTML(text: string, makeVisible?: boolean) {\n this.element.innerHTML = text;\n if (makeVisible) {\n this.setVisible(true);\n }\n }\n setVisible(value: boolean) {\n if (this.timer !== null) {\n clearTimeout(this.timer);\n this.timer = null;\n }\n this.element.style.display = value ? \"block\" : \"none\";\n }\n\n static forPromise(\n promise: Promise,\n options: { initialMessage: string; delay?: Delay; errorPrefix: string },\n ): Promise {\n const status = new StatusMessage(options.delay);\n status.setText(options.initialMessage);\n const dispose = status.dispose.bind(status);\n promise.then(dispose, (reason) => {\n let msg: string;\n if (reason instanceof Error) {\n msg = reason.message;\n } else {\n msg = \"\" + reason;\n }\n const { errorPrefix = \"\" } = options;\n status.setErrorMessage(errorPrefix + msg);\n status.setVisible(true);\n });\n return promise;\n }\n\n setErrorMessage(message: string) {\n this.element.textContent = message + \" \";\n const button = document.createElement(\"button\");\n button.textContent = \"Dismiss\";\n button.addEventListener(\"click\", () => {\n this.dispose();\n });\n this.element.appendChild(button);\n }\n\n static showMessage(message: string): StatusMessage {\n const msg = new StatusMessage();\n msg.element.textContent = message;\n msg.setVisible(true);\n return msg;\n }\n\n static showTemporaryMessage(\n message: string,\n closeAfter = 2000,\n ): StatusMessage {\n const msg = StatusMessage.showMessage(message);\n window.setTimeout(() => msg.dispose(), closeAfter);\n return msg;\n }\n}\n","/**\n * @license\n * Copyright 2018 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @file Support for defining user-selectable tools.\n */\n\nimport \"#src/ui/tool.css\";\n\nimport { debounce } from \"lodash-es\";\nimport type { MouseSelectionState, UserLayer } from \"#src/layer/index.js\";\nimport { StatusMessage } from \"#src/status.js\";\nimport type { TrackableValueInterface } from \"#src/trackable_value.js\";\nimport { animationFrameDebounce } from \"#src/util/animation_frame_debounce.js\";\nimport type { Borrowed, Owned } from \"#src/util/disposable.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport type {\n ActionEvent,\n EventActionMap,\n} from \"#src/util/event_action_map.js\";\nimport { registerActionListener } from \"#src/util/event_action_map.js\";\nimport {\n verifyObject,\n verifyObjectProperty,\n verifyString,\n} from \"#src/util/json.js\";\nimport type { AnyConstructor } from \"#src/util/mixin.js\";\nimport { Signal } from \"#src/util/signal.js\";\n\nconst TOOL_KEY_PATTERN = /^[A-Z]$/;\n\nexport type InputEventMapBinder = (\n eventActionMap: EventActionMap,\n context: RefCounted,\n) => void;\n\nexport class ToolActivation extends RefCounted {\n constructor(\n public tool: ToolType,\n public inputEventMapBinder: InputEventMapBinder,\n ) {\n super();\n }\n bindAction(\n action: string,\n listener: (event: ActionEvent) => void,\n ) {\n this.registerDisposer(registerActionListener(window, action, listener));\n }\n bindInputEventMap(inputEventMap: EventActionMap) {\n this.inputEventMapBinder(inputEventMap, this);\n }\n cancel() {\n const { globalBinder } = this.tool;\n if (this === globalBinder.activeTool_) {\n globalBinder.deactivate_();\n }\n }\n}\n\nexport abstract class Tool extends RefCounted {\n changed = new Signal();\n keyBinding: string | undefined = undefined;\n\n get context() {\n return this.localBinder.context;\n }\n\n get globalBinder() {\n return this.localBinder.globalBinder;\n }\n\n constructor(\n public readonly localBinder: LocalToolBinder,\n public toggle = false,\n ) {\n super();\n }\n abstract activate(activation: ToolActivation): void;\n abstract toJSON(): any;\n abstract description: string;\n unbind() {\n const { keyBinding } = this;\n if (keyBinding !== undefined) {\n this.localBinder.set(keyBinding, undefined);\n }\n }\n}\n\nexport abstract class LayerTool<\n LayerType extends UserLayer = UserLayer,\n> extends Tool {\n constructor(\n public layer: LayerType,\n toggle = false,\n ) {\n super(layer.toolBinder, toggle);\n }\n get mouseState() {\n return this.layer.manager.root.layerSelectedValues.mouseState;\n }\n}\n\nexport abstract class LegacyTool<\n LayerType extends UserLayer = UserLayer,\n> extends RefCounted {\n changed = new Signal();\n constructor(public layer: LayerType) {\n super();\n }\n get context() {\n return this.layer;\n }\n get mouseState() {\n return this.layer.manager.root.layerSelectedValues.mouseState;\n }\n abstract trigger(mouseState: MouseSelectionState): void;\n abstract toJSON(): any;\n deactivate(): void {}\n abstract description: string;\n unbind() {\n const { layer } = this;\n if (layer.tool.value === this) {\n layer.tool.value = undefined;\n }\n }\n}\n\nexport function restoreTool(\n context: Context,\n obj: unknown,\n) {\n if (obj === undefined) {\n return undefined;\n }\n if (typeof obj === \"string\") {\n obj = { type: obj };\n }\n verifyObject(obj);\n const type = verifyObjectProperty(obj, \"type\", verifyString);\n\n let prototype = context;\n let getter: ToolGetter | undefined;\n while (true) {\n prototype = Object.getPrototypeOf(prototype);\n if (prototype === null) {\n throw new Error(`Invalid tool type: ${JSON.stringify(obj)}.`);\n }\n getter = toolsForPrototype.get(prototype)?.get(type);\n if (getter !== undefined) break;\n }\n return getter(context, obj);\n}\n\nexport function restoreLegacyTool(layer: UserLayer, obj: any) {\n if (obj === undefined) {\n return undefined;\n }\n if (typeof obj === \"string\") {\n obj = { type: obj };\n }\n verifyObject(obj);\n const type = verifyObjectProperty(obj, \"type\", verifyString);\n const getter = legacyTools.get(type);\n if (getter === undefined) {\n throw new Error(`Invalid tool type: ${JSON.stringify(obj)}.`);\n }\n return getter(layer, obj);\n}\n\nexport type ToolGetter = (\n context: Context,\n options: any,\n) => Owned | undefined;\n\nexport type LegacyToolGetter = (\n layer: LayerType,\n options: any,\n) => Owned | undefined;\n\nconst legacyTools = new Map();\nconst toolsForPrototype = new Map>();\n\nexport function registerLegacyTool(type: string, getter: LegacyToolGetter) {\n legacyTools.set(type, getter);\n}\n\nexport function registerTool(\n contextType: AnyConstructor,\n type: string,\n getter: ToolGetter,\n) {\n const { prototype } = contextType;\n let tools = toolsForPrototype.get(prototype);\n if (tools === undefined) {\n tools = new Map();\n toolsForPrototype.set(prototype, tools);\n }\n tools.set(type, getter);\n}\n\nexport function unregisterTool(\n contextType: AnyConstructor,\n type: string,\n) {\n const { prototype } = contextType;\n const tools = toolsForPrototype.get(prototype);\n if (tools) {\n tools.delete(type);\n }\n}\n\nexport class SelectedLegacyTool\n extends RefCounted\n implements TrackableValueInterface\n{\n changed = new Signal();\n private value_: Owned | undefined;\n\n get value() {\n return this.value_;\n }\n\n set value(newValue: Owned | undefined) {\n if (newValue === this.value_) return;\n this.unregister();\n if (newValue !== undefined) {\n newValue.changed.add(this.changed.dispatch);\n this.value_ = newValue;\n }\n this.changed.dispatch();\n }\n\n private unregister() {\n const existingValue = this.value_;\n if (existingValue !== undefined) {\n existingValue.changed.remove(this.changed.dispatch);\n existingValue.dispose();\n this.value_ = undefined;\n }\n }\n\n disposed() {\n this.unregister();\n super.disposed();\n }\n\n restoreState(obj: unknown) {\n this.value = restoreLegacyTool(this.layer, obj);\n }\n\n reset() {\n this.value = undefined;\n }\n\n toJSON() {\n const value = this.value_;\n if (value === undefined) return undefined;\n return value.toJSON();\n }\n constructor(public layer: UserLayer) {\n super();\n }\n}\n\nexport class GlobalToolBinder extends RefCounted {\n bindings = new Map>();\n changed = new Signal();\n activeTool_: Owned | undefined; // For internal use only- should only be called by ToolBinder and ToolActivation.cancel()\n private queuedTool: Tool | undefined;\n private debounceDeactivate = this.registerCancellable(\n debounce(() => {\n this.deactivate_();\n this.reactivateQueuedTool();\n }, 100),\n );\n\n constructor(private inputEventMapBinder: InputEventMapBinder) {\n super();\n }\n\n get(key: string): Borrowed | undefined {\n return this.bindings.get(key);\n }\n\n set(key: string, tool: Owned | undefined) {\n const { bindings } = this;\n const existingTool = bindings.get(key);\n if (existingTool !== undefined) {\n existingTool.keyBinding = undefined;\n bindings.delete(key);\n const localToolBinder = existingTool.localBinder;\n localToolBinder.bindings.delete(key);\n localToolBinder.jsonToKey.delete(JSON.stringify(existingTool.toJSON()));\n this.destroyTool(existingTool);\n localToolBinder.changed.dispatch();\n }\n if (tool !== undefined) {\n const localToolBinder = tool.localBinder;\n const json = JSON.stringify(tool.toJSON());\n const existingKey = localToolBinder.jsonToKey.get(json);\n if (existingKey !== undefined) {\n const existingTool = localToolBinder.bindings.get(existingKey)!;\n existingTool.keyBinding = undefined;\n bindings.delete(existingKey);\n localToolBinder.bindings.delete(existingKey);\n localToolBinder.jsonToKey.delete(json);\n this.destroyTool(existingTool);\n }\n localToolBinder.bindings.set(key, tool);\n tool.keyBinding = key;\n localToolBinder.jsonToKey.set(json, key);\n bindings.set(key, tool);\n localToolBinder.changed.dispatch();\n }\n this.changed.dispatch();\n }\n\n activate(key: string, tool?: Tool): Borrowed | undefined {\n tool = tool || this.get(key);\n if (tool === undefined) {\n this.deactivate_();\n return;\n }\n this.debounceDeactivate.cancel();\n const activeTool = this.activeTool_;\n if (tool.toJSON() === activeTool?.tool.toJSON()) {\n if (tool.toggle) {\n this.deactivate_();\n }\n return;\n }\n if (activeTool !== undefined) {\n if (activeTool.tool.toggle && !tool.toggle) {\n this.queuedTool = activeTool.tool;\n }\n this.deactivate_();\n }\n const activation = new ToolActivation(tool, this.inputEventMapBinder);\n this.activeTool_ = activation;\n if (!tool.toggle) {\n const expectedCode = `Key${key}`;\n activation.registerEventListener(\n window,\n \"keydown\",\n (event: KeyboardEvent) => {\n // Prevent other key input while tool is activated. This\n // prevents `shift+key` from being interpreted as text input\n // if an input element becomes focused.\n event.stopPropagation();\n event.preventDefault();\n },\n );\n activation.registerEventListener(\n window,\n \"keyup\",\n (event: KeyboardEvent) => {\n if (event.code === expectedCode) {\n this.debounceDeactivate();\n }\n },\n );\n activation.registerEventListener(window, \"blur\", () => {\n this.debounceDeactivate();\n });\n }\n tool.activate(activation);\n return tool;\n }\n\n private reactivateQueuedTool() {\n if (this.queuedTool) {\n const activation = new ToolActivation(\n this.queuedTool,\n this.inputEventMapBinder,\n );\n this.activeTool_ = activation;\n this.queuedTool.activate(activation);\n this.queuedTool = undefined;\n }\n }\n\n destroyTool(tool: Owned) {\n if (this.queuedTool === tool) {\n this.queuedTool = undefined;\n }\n if (this.activeTool_?.tool === tool) {\n this.deactivate_();\n }\n tool.dispose();\n }\n\n disposed() {\n this.deactivate_();\n super.disposed();\n }\n\n deactivate_() {\n // For internal use only- should only be called by ToolBinder and ToolActivation.cancel()\n this.debounceDeactivate.cancel();\n const activation = this.activeTool_;\n if (activation === undefined) return;\n this.activeTool_ = undefined;\n activation.dispose();\n }\n}\n\nexport class LocalToolBinder<\n Context extends object = object,\n> extends RefCounted {\n // Maps the the tool key (i.e. \"A\", \"B\", ...) to the bound tool.\n bindings = new Map>();\n // Maps the serialized json representation of the tool to the tool key.\n jsonToKey = new Map();\n changed = new Signal();\n\n constructor(\n public context: Context,\n public globalBinder: GlobalToolBinder,\n ) {\n super();\n }\n\n disposed() {\n this.clear();\n super.disposed();\n }\n\n get(key: string): Borrowed | undefined {\n return this.bindings.get(key);\n }\n\n set(key: string, tool: Owned | undefined) {\n this.globalBinder.set(key, tool);\n }\n\n setJson(key: string, toolJson: any) {\n const tool = restoreTool(this.context, toolJson);\n if (tool === undefined) return;\n this.set(key, tool);\n }\n\n removeJsonString(toolJsonString: string) {\n const key = this.jsonToKey.get(toolJsonString);\n if (key === undefined) return;\n this.set(key, undefined);\n }\n\n toJSON(): any {\n const { bindings } = this;\n if (bindings.size === 0) return undefined;\n const obj: any = {};\n for (const [key, value] of bindings) {\n obj[key] = value.toJSON();\n }\n return obj;\n }\n\n deleteTool(key: string) {\n const { globalBinder, bindings, jsonToKey } = this;\n const existingTool = bindings.get(key);\n if (existingTool) {\n bindings.delete(key);\n globalBinder.bindings.delete(key);\n jsonToKey.delete(JSON.stringify(existingTool.toJSON()));\n globalBinder.destroyTool(existingTool);\n globalBinder.changed.dispatch();\n this.changed.dispatch();\n }\n }\n\n clear() {\n const { globalBinder, bindings } = this;\n if (bindings.size !== 0) {\n for (const [key, tool] of bindings) {\n tool.keyBinding = undefined;\n globalBinder.bindings.delete(key);\n globalBinder.destroyTool(tool);\n }\n bindings.clear();\n this.jsonToKey.clear();\n globalBinder.changed.dispatch();\n this.changed.dispatch();\n }\n }\n\n reset() {\n this.clear();\n }\n\n restoreState(obj: any) {\n if (obj === undefined) return;\n verifyObject(obj);\n for (const [key, value] of Object.entries(obj)) {\n if (!key.match(TOOL_KEY_PATTERN)) {\n throw new Error(`Invalid tool key: ${JSON.stringify(key)}`);\n }\n const tool = restoreTool(this.context, value);\n if (tool === undefined) return;\n this.set(key, tool);\n }\n }\n}\n\nexport class ToolBindingWidget extends RefCounted {\n element = document.createElement(\"div\");\n private toolJsonString = JSON.stringify(this.toolJson);\n constructor(\n public localBinder: LocalToolBinder,\n public toolJson: any,\n ) {\n super();\n const { element } = this;\n element.classList.add(\"neuroglancer-tool-key-binding\");\n this.registerDisposer(\n localBinder.changed.add(\n this.registerCancellable(\n animationFrameDebounce(() => this.updateView()),\n ),\n ),\n );\n this.updateView();\n element.title = \"click → bind key, dbclick → unbind\";\n element.addEventListener(\"dblclick\", () => {\n this.localBinder.removeJsonString(this.toolJsonString);\n });\n addToolKeyBindHandlers(this, element, (key) =>\n this.localBinder.setJson(key, this.toolJson),\n );\n }\n\n private updateView() {\n const { localBinder } = this;\n const key = localBinder.jsonToKey.get(this.toolJsonString);\n this.element.textContent = key ?? \" \";\n }\n}\n\nexport function addToolKeyBindHandlers(\n context: RefCounted,\n element: HTMLElement,\n bindKey: (key: string) => void,\n) {\n let mousedownContext: RefCounted | undefined;\n element.addEventListener(\"mousedown\", (event) => {\n if (event.button !== 0 || mousedownContext !== undefined) return;\n event.preventDefault();\n event.stopPropagation();\n mousedownContext = new RefCounted();\n context.registerDisposer(mousedownContext);\n const message = mousedownContext.registerDisposer(new StatusMessage(false));\n message.setText(\"Press A-Z to bind key\");\n mousedownContext.registerEventListener(\n window,\n \"keydown\",\n (event: KeyboardEvent) => {\n const { code } = event;\n const m = code.match(/^Key([A-Z])$/);\n if (m === null) return;\n event.stopPropagation();\n event.preventDefault();\n const key = m[1];\n bindKey(key);\n },\n { capture: true },\n );\n mousedownContext.registerEventListener(\n window,\n \"mouseup\",\n (event: MouseEvent) => {\n if (event.button !== 0 || mousedownContext === undefined) return;\n event.preventDefault();\n event.stopPropagation();\n context.unregisterDisposer(mousedownContext);\n mousedownContext.dispose();\n mousedownContext = undefined;\n },\n );\n });\n element.addEventListener(\"click\", (event) => {\n event.preventDefault();\n event.stopPropagation();\n });\n}\n\nexport function makeToolButton(\n context: RefCounted,\n localBinder: LocalToolBinder,\n options: { toolJson: any; label?: string; title?: string },\n) {\n const element = document.createElement(\"div\");\n element.classList.add(\"neuroglancer-tool-button\");\n element.appendChild(\n context.registerDisposer(\n new ToolBindingWidget(localBinder, options.toolJson),\n ).element,\n );\n const labelElement = document.createElement(\"div\");\n labelElement.classList.add(\"neuroglancer-tool-button-label\");\n const labelText = options.label;\n if (labelText !== undefined) {\n labelElement.textContent = labelText;\n }\n if (options.title) {\n labelElement.title = options.title;\n }\n element.appendChild(labelElement);\n return element;\n}\n\nexport function makeToolActivationStatusMessage(activation: ToolActivation) {\n const message = activation.registerDisposer(new StatusMessage(false));\n message.element.classList.add(\"neuroglancer-tool-status\");\n const content = document.createElement(\"div\");\n content.classList.add(\"neuroglancer-tool-status-content\");\n message.element.appendChild(content);\n const { inputEventMapBinder } = activation;\n activation.inputEventMapBinder = (\n inputEventMap: EventActionMap,\n context: RefCounted,\n ) => {\n const bindingHelp = document.createElement(\"div\");\n bindingHelp.textContent = inputEventMap.describe();\n bindingHelp.classList.add(\"neuroglancer-tool-status-bindings\");\n message.element.appendChild(bindingHelp);\n inputEventMapBinder(inputEventMap, context);\n };\n return { message, content };\n}\n\nexport function makeToolActivationStatusMessageWithHeader(\n activation: ToolActivation,\n) {\n const { message, content } = makeToolActivationStatusMessage(activation);\n const header = document.createElement(\"div\");\n header.classList.add(\"neuroglancer-tool-status-header\");\n const headerContainer = document.createElement(\"div\");\n headerContainer.classList.add(\"neuroglancer-tool-status-header-container\");\n headerContainer.appendChild(header);\n content.appendChild(headerContainer);\n const body = document.createElement(\"div\");\n body.classList.add(\"neuroglancer-tool-status-body\");\n content.appendChild(body);\n return { message, body, header };\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { registerEventListener } from \"#src/util/disposable.js\";\n\nexport function setClipboard(data: string, format = \"text/plain\") {\n let success = false;\n const cleanup = registerEventListener(\n document,\n \"copy\",\n (event: ClipboardEvent) => {\n const { clipboardData } = event;\n if (clipboardData !== null) {\n clipboardData.setData(format, data);\n success = true;\n }\n event.stopPropagation();\n event.preventDefault();\n },\n true,\n );\n try {\n document.execCommand(\"copy\");\n } finally {\n cleanup();\n }\n return success;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @file Facility for triggering named actions in response to keyboard events.\n */\n\n// This is based on goog/ui/keyboardshortcuthandler.js in the Google Closure library.\n\nimport { WatchableValue } from \"#src/trackable_value.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport type {\n ActionEvent,\n EventActionMapInterface,\n} from \"#src/util/event_action_map.js\";\nimport {\n dispatchEventWithModifiers,\n EventActionMap,\n registerActionListener,\n getEventModifierMask,\n} from \"#src/util/event_action_map.js\";\n\nexport const globalModifiers = new WatchableValue(0);\nwindow.addEventListener(\"keydown\", (event) => {\n globalModifiers.value = getEventModifierMask(event);\n});\nwindow.addEventListener(\"keyup\", (event) => {\n globalModifiers.value = getEventModifierMask(event);\n});\n\nconst globalKeys = new Set([\n \"f1\",\n \"f2\",\n \"f3\",\n \"f4\",\n \"f5\",\n \"f6\",\n \"f7\",\n \"f8\",\n \"f9\",\n \"f10\",\n \"f11\",\n \"f12\",\n \"escape\",\n \"pause\",\n]);\nconst DEFAULT_TEXT_INPUTS = new Set([\n \"color\",\n \"date\",\n \"datetime\",\n \"datetime-local\",\n \"email\",\n \"month\",\n \"number\",\n \"password\",\n \"search\",\n \"tel\",\n \"text\",\n \"time\",\n \"url\",\n \"week\",\n]);\n\nexport class KeyboardEventBinder<\n EventMap extends EventActionMapInterface,\n> extends RefCounted {\n modifierShortcutsAreGlobal = true;\n allShortcutsAreGlobal = false;\n allowSpaceKeyOnButtons = false;\n shouldIgnore: ((event: KeyboardEvent) => boolean) | undefined = undefined;\n constructor(\n public target: EventTarget,\n public eventMap: EventMap,\n ) {\n super();\n this.registerEventListener(\n target,\n \"keydown\",\n this.handleKeyDown.bind(this),\n /*useCapture=*/ false,\n );\n }\n\n private shouldIgnoreEvent(key: string, event: KeyboardEvent) {\n if (this.shouldIgnore?.(event)) return true;\n const el = event.target;\n const { tagName } = el;\n if (el === this.target) {\n // If the event is directly on the target element, we never ignore it.\n return false;\n }\n const isFormElement =\n tagName === \"TEXTAREA\" ||\n tagName === \"INPUT\" ||\n tagName === \"BUTTON\" ||\n tagName === \"SELECT\";\n\n const isContentEditable =\n !isFormElement &&\n (el.isContentEditable ||\n (el.ownerDocument && el.ownerDocument.designMode === \"on\"));\n\n if (!isFormElement && !isContentEditable) {\n return false;\n }\n // Always allow keys registered as global to be used (typically Esc, the\n // F-keys and other keys that are not typically used to manipulate text).\n if (this.allShortcutsAreGlobal || globalKeys.has(key)) {\n return false;\n }\n if (isContentEditable) {\n // For events originating from an element in editing mode we only let\n // global key codes through.\n return true;\n }\n // Event target is one of (TEXTAREA, INPUT, BUTTON, SELECT).\n // Allow modifier shortcuts, unless we shouldn't.\n if (\n this.modifierShortcutsAreGlobal &&\n (event.altKey || event.ctrlKey || event.metaKey)\n ) {\n return true;\n }\n // Allow ENTER to be used as shortcut for text inputs.\n if (\n tagName === \"INPUT\" &&\n DEFAULT_TEXT_INPUTS.has((el).type)\n ) {\n return key !== \"enter\";\n }\n // Checkboxes, radiobuttons and buttons. Allow all but SPACE as shortcut.\n if (tagName === \"INPUT\" || tagName === \"BUTTON\") {\n // TODO(gboyer): If more flexibility is needed, create protected helper\n // methods for each case (e.g. button, input, etc).\n if (this.allowSpaceKeyOnButtons) {\n return false;\n }\n return key === \"space\";\n }\n // Don't allow any additional shortcut keys for textareas or selects.\n return true;\n }\n\n private handleKeyDown(event: KeyboardEvent) {\n const key = getEventKeyName(event);\n if (this.shouldIgnoreEvent(key, event)) {\n return;\n }\n dispatchEventWithModifiers(key, event, event, this.eventMap);\n }\n}\n\nexport function getEventKeyName(event: KeyboardEvent): string {\n return event.code.toLowerCase();\n}\n\nexport { EventActionMap, registerActionListener };\nexport type { EventActionMapInterface, ActionEvent };\n","/**\n * @license\n * Copyright 2020 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport \"#src/widget/checkbox_icon.css\";\n\nimport type { WatchableValueInterface } from \"#src/trackable_value.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport type { MakeIconOptions } from \"#src/widget/icon.js\";\nimport { makeIcon } from \"#src/widget/icon.js\";\n\nexport interface MakeCheckboxIconOptions\n extends Omit {\n enableTitle?: string;\n disableTitle?: string;\n backgroundScheme?: \"light\" | \"dark\";\n}\n\nexport class CheckboxIcon extends RefCounted {\n readonly element: HTMLElement;\n constructor(\n model: WatchableValueInterface,\n options: MakeCheckboxIconOptions,\n ) {\n super();\n this.element = makeIcon({\n ...options,\n onClick: () => {\n model.value = !model.value;\n },\n });\n this.element.classList.add(\"neuroglancer-checkbox-icon\");\n this.element.classList.add(\n options.backgroundScheme === \"dark\"\n ? \"dark-background\"\n : \"light-background\",\n );\n const updateView = () => {\n const value = model.value;\n this.element.dataset.checked = value ? \"true\" : \"false\";\n this.element.title =\n (value ? options.disableTitle : options.enableTitle) || \"\";\n };\n this.registerDisposer(model.changed.add(updateView));\n updateView();\n }\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport svg_copy from \"ikonate/icons/copy.svg?raw\";\nimport type { MakeIconOptions } from \"#src/widget/icon.js\";\nimport { makeIcon } from \"#src/widget/icon.js\";\n\nexport function makeCopyButton(options: MakeIconOptions = {}) {\n return makeIcon({ svg: svg_copy, ...options });\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { WatchableValueInterface } from \"#src/trackable_value.js\";\nimport { animationFrameDebounce } from \"#src/util/animation_frame_debounce.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport { removeChildren } from \"#src/util/dom.js\";\nimport { WatchableVisibilityPriority } from \"#src/visibility_priority/frontend.js\";\n\nexport class DependentViewContext extends RefCounted {\n constructor(public redraw: () => void) {\n super();\n }\n}\n\nexport class DependentViewWidget extends RefCounted {\n element = document.createElement(\"div\");\n\n private generation = -1;\n private currentViewDisposer: RefCounted | undefined = undefined;\n private debouncedUpdateView = this.registerCancellable(\n animationFrameDebounce(() => this.updateView()),\n );\n private debouncedForceUpdateView = () => {\n this.generation = -1;\n this.debouncedUpdateView();\n };\n\n constructor(\n public model: WatchableValueInterface,\n public render: (\n value: T,\n parent: HTMLElement,\n context: DependentViewContext,\n ) => void,\n public visibility = new WatchableVisibilityPriority(\n WatchableVisibilityPriority.VISIBLE,\n ),\n ) {\n super();\n this.element.style.display = \"contents\";\n this.registerDisposer(model.changed.add(this.debouncedUpdateView));\n this.registerDisposer(\n visibility.changed.add(() => {\n if (this.visible) this.debouncedUpdateView();\n }),\n );\n this.updateView();\n }\n\n get visible() {\n return this.visibility.visible;\n }\n\n private updateView() {\n if (!this.visible) return;\n const { model } = this;\n const generation = model.changed.count;\n if (generation === this.generation) return;\n this.disposeCurrentView();\n const currentViewDisposer = (this.currentViewDisposer =\n new DependentViewContext(this.debouncedForceUpdateView));\n this.render(model.value, this.element, currentViewDisposer);\n this.generation = generation;\n }\n\n private disposeCurrentView() {\n const { currentViewDisposer } = this;\n if (currentViewDisposer !== undefined) {\n currentViewDisposer.dispose();\n }\n removeChildren(this.element);\n }\n\n disposed() {\n this.disposeCurrentView();\n super.disposed();\n }\n}\n","/**\n * @license\n * Copyright 2017 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport type { TrackableEnum } from \"#src/util/trackable_enum.js\";\n\nexport class EnumSelectWidget extends RefCounted {\n element = document.createElement(\"select\");\n private valueIndexMap = new Map();\n constructor(public model: TrackableEnum) {\n super();\n const { element, valueIndexMap } = this;\n let index = 0;\n for (const key of Object.keys(model.enumType)) {\n if (Number.isNaN(Number(key))) {\n const option = document.createElement(\"option\");\n option.textContent = option.value = key.toLowerCase();\n element.appendChild(option);\n valueIndexMap.set(model.enumType[key], index);\n ++index;\n }\n }\n this.registerDisposer(model.changed.add(() => this.updateView()));\n this.registerEventListener(element, \"change\", () => this.updateModel());\n this.registerEventListener(element, \"wheel\", (event: WheelEvent) => {\n event.preventDefault();\n event.stopPropagation();\n this.adjustViaWheel(event);\n });\n this.updateView();\n }\n\n adjustViaWheel(event: WheelEvent) {\n const { element } = this;\n const { deltaY } = event;\n if (deltaY > 0) {\n element.selectedIndex =\n (element.options.length + element.selectedIndex - 1) %\n element.options.length;\n this.updateModel();\n } else if (deltaY < 0) {\n element.selectedIndex =\n (element.options.length + element.selectedIndex + 1) %\n element.options.length;\n this.updateModel();\n }\n }\n\n private updateView() {\n const { element } = this;\n element.selectedIndex = this.valueIndexMap.get(this.model.value)!;\n }\n\n private updateModel() {\n this.model.restoreState(this.element.value);\n }\n}\n","/**\n * @license\n * Copyright 2017 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { WatchableValue } from \"#src/trackable_value.js\";\nimport { TrackableValue } from \"#src/trackable_value.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport { removeFromParent } from \"#src/util/dom.js\";\n\nexport class NumberInputWidget extends RefCounted {\n element = document.createElement(\"label\");\n inputElement = document.createElement(\"input\");\n validator: (x: number) => number;\n constructor(\n public model: WatchableValue,\n options: {\n validator?: (x: number) => number;\n label?: string;\n } = {},\n ) {\n super();\n let { validator, label } = options;\n const { element, inputElement } = this;\n if (validator === undefined) {\n if (model instanceof TrackableValue) {\n validator = model.validator;\n } else {\n validator = (x) => x;\n }\n }\n this.validator = validator;\n if (label !== undefined) {\n element.textContent = label;\n }\n element.appendChild(inputElement);\n element.className = \"neuroglancer-number-input\";\n inputElement.type = \"text\";\n this.registerDisposer(this.model.changed.add(() => this.updateView()));\n this.registerEventListener(inputElement, \"change\", () =>\n this.updateModel(),\n );\n this.updateView();\n }\n\n private updateView() {\n this.inputElement.value = \"\" + this.model.value;\n }\n\n updateModel() {\n let value = parseFloat(this.inputElement.value.trim());\n if (Number.isNaN(value)) {\n this.updateView();\n return;\n }\n try {\n value = this.validator(value);\n this.model.value = value;\n } catch {\n this.updateView();\n }\n }\n\n disposed() {\n removeFromParent(this.element);\n super.disposed();\n }\n}\n","/**\n * @license\n * Copyright 2017-2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport \"#src/widget/position_plot.css\";\n\nimport type {\n CoordinateSpace,\n DimensionId,\n} from \"#src/coordinate_transform.js\";\nimport {\n computeCombinedLowerUpperBound,\n getDisplayLowerUpperBounds,\n} from \"#src/coordinate_transform.js\";\nimport type { Position } from \"#src/navigation_state.js\";\nimport { WatchableValue } from \"#src/trackable_value.js\";\nimport { animationFrameDebounce } from \"#src/util/animation_frame_debounce.js\";\nimport { filterArrayInplace } from \"#src/util/array.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport { startRelativeMouseDrag } from \"#src/util/mouse_drag.js\";\n\ninterface NormalizedDimensionBounds {\n lowerBound: number;\n upperBound: number;\n normalizedBounds: readonly { lower: number; upper: number }[];\n}\n\nfunction getCanvasYFromCoordinate(\n coordinate: number,\n lowerBound: number,\n upperBound: number,\n canvasHeight: number,\n) {\n return Math.floor(\n ((coordinate - lowerBound) * (canvasHeight - 1)) /\n (upperBound - lowerBound),\n );\n}\n\nfunction getNormalizedDimensionBounds(\n coordinateSpace: CoordinateSpace,\n dimensionIndex: number,\n height: number,\n): NormalizedDimensionBounds | undefined {\n const { boundingBoxes, bounds } = coordinateSpace;\n let [lowerBound, upperBound] = getDisplayLowerUpperBounds(\n bounds,\n dimensionIndex,\n );\n lowerBound = Math.floor(lowerBound);\n upperBound = Math.floor(upperBound - 1);\n if (!Number.isFinite(lowerBound) || !Number.isFinite(upperBound)) {\n return undefined;\n }\n const normalizedBounds: { lower: number; upper: number }[] = [];\n const normalize = (x: number) => {\n return getCanvasYFromCoordinate(x, lowerBound, upperBound, height);\n };\n const { rank } = coordinateSpace;\n for (const boundingBox of boundingBoxes) {\n const result = computeCombinedLowerUpperBound(\n boundingBox,\n dimensionIndex,\n rank,\n );\n if (result === undefined) continue;\n result.lower = Math.max(0, normalize(result.lower));\n result.upper = Math.min(height - 1, normalize(Math.ceil(result.upper - 1)));\n normalizedBounds.push(result);\n }\n normalizedBounds.sort((a, b) => {\n const lowerDiff = a.lower - b.lower;\n if (lowerDiff !== 0) return lowerDiff;\n return b.upper - b.upper;\n });\n filterArrayInplace(normalizedBounds, (x, i) => {\n if (i === 0) return true;\n const prev = normalizedBounds[i - 1];\n return prev.lower !== x.lower || prev.upper !== x.upper;\n });\n return { lowerBound, upperBound, normalizedBounds };\n}\n\nexport class PositionPlot extends RefCounted {\n element = document.createElement(\"div\");\n visible = true;\n dragging = new WatchableValue(false);\n\n tickWidth: number = this.orientation === \"column\" ? 10 : 5;\n barWidth: number = this.orientation === \"column\" ? 15 : 10;\n barRightMargin: number = this.orientation === \"column\" ? 10 : 2;\n canvasWidth: number;\n\n constructor(\n public position: Position,\n public dimensionId: DimensionId,\n public orientation: \"row\" | \"column\" = \"column\",\n ) {\n super();\n this.canvasWidth = this.tickWidth + this.barWidth + this.barRightMargin;\n const plotElement = this.element;\n plotElement.classList.add(\"neuroglancer-position-dimension-plot\");\n plotElement.dataset.orientation = orientation;\n const canvas = document.createElement(\"canvas\");\n const ctx = canvas.getContext(\"2d\")!;\n\n const lowerBoundElement = document.createElement(\"div\");\n const lowerBoundContainer = document.createElement(\"div\");\n lowerBoundContainer.appendChild(lowerBoundElement);\n const lowerBoundText = document.createTextNode(\"\");\n lowerBoundElement.appendChild(lowerBoundText);\n const upperBoundElement = document.createElement(\"div\");\n const hoverElement = document.createElement(\"div\");\n lowerBoundContainer.classList.add(\n \"neuroglancer-position-dimension-plot-lowerbound\",\n );\n upperBoundElement.classList.add(\n \"neuroglancer-position-dimension-plot-upperbound\",\n );\n hoverElement.classList.add(\n \"neuroglancer-position-dimension-plot-hoverposition\",\n );\n plotElement.appendChild(lowerBoundContainer);\n plotElement.appendChild(upperBoundElement);\n plotElement.appendChild(hoverElement);\n plotElement.appendChild(canvas);\n\n let prevLowerBound: number | undefined;\n let prevUpperBound: number | undefined;\n\n let hoverPosition: number | undefined = undefined;\n\n const updateView = () => {\n const coordinateSpace = this.position.coordinateSpace.value;\n const dimensionIndex = coordinateSpace.ids.indexOf(this.dimensionId);\n if (dimensionIndex === -1) return;\n\n let canvasHeight: number;\n if (orientation === \"column\") {\n canvasHeight = 100;\n canvas.width = this.canvasWidth;\n canvas.height = canvasHeight;\n upperBoundElement.style.marginTop = `${canvasHeight - 1}px`;\n } else {\n canvasHeight = canvas.clientWidth;\n canvas.width = canvasHeight;\n canvas.height = this.canvasWidth;\n }\n\n const normalizedDimensionBounds = getNormalizedDimensionBounds(\n coordinateSpace,\n dimensionIndex,\n canvasHeight,\n );\n if (\n normalizedDimensionBounds === undefined ||\n coordinateSpace.bounds.lowerBounds[dimensionIndex] + 1 ===\n coordinateSpace.bounds.upperBounds[dimensionIndex]\n ) {\n this.element.style.display = \"none\";\n this.visible = false;\n return;\n }\n this.visible = true;\n\n const { lowerBound, upperBound } = normalizedDimensionBounds;\n prevLowerBound = lowerBound;\n prevUpperBound = upperBound;\n lowerBoundText.textContent = lowerBound.toString();\n upperBoundElement.textContent = upperBound.toString();\n let canvasMargin: number;\n let lowerBoundWidth: number;\n let upperBoundWidth: number;\n if (orientation !== \"column\") {\n lowerBoundWidth = lowerBoundElement.clientWidth;\n upperBoundWidth = upperBoundElement.clientWidth;\n canvasMargin = Math.max(lowerBoundWidth, upperBoundWidth) / 2;\n canvas.style.marginLeft = `${canvasMargin}px`;\n canvas.style.marginRight = `${canvasMargin}px`;\n upperBoundElement.style.position = \"relative\";\n upperBoundElement.style.left = `${\n canvasHeight + canvasMargin - upperBoundWidth / 2\n }px`;\n lowerBoundElement.style.marginLeft = `${\n canvasMargin - lowerBoundWidth / 2\n }px`;\n }\n this.drawDimensionBounds(canvas, ctx, normalizedDimensionBounds);\n const curPosition = this.position.value[dimensionIndex];\n\n const drawPositionIndicator = (\n pos: number | undefined,\n fillStyle: string,\n ) => {\n if (\n pos !== undefined &&\n pos >= lowerBound &&\n Math.floor(pos) <= upperBound\n ) {\n ctx.fillStyle = fillStyle;\n const offset = getCanvasYFromCoordinate(\n pos,\n lowerBound,\n upperBound,\n canvasHeight,\n );\n if (orientation === \"column\") {\n ctx.fillRect(0, offset, this.canvasWidth, 1);\n } else {\n ctx.fillRect(offset, 0, 1, this.canvasWidth);\n }\n return offset;\n }\n return undefined;\n };\n const positionOffset = drawPositionIndicator(curPosition, \"#f66\");\n const isDragging = this.dragging.value;\n let hoverOffset = isDragging\n ? positionOffset\n : drawPositionIndicator(hoverPosition, \"#66f\");\n if (hoverOffset !== undefined) {\n hoverElement.textContent = (\n isDragging ? Math.floor(curPosition) : hoverPosition!\n ).toString();\n const lowerBoundOffset =\n orientation === \"column\"\n ? lowerBoundElement.clientHeight\n : lowerBoundElement.clientWidth;\n const upperBoundOffset =\n orientation === \"column\"\n ? upperBoundElement.clientHeight\n : upperBoundElement.clientWidth;\n let hoverWidth: number;\n let showLowerBound: boolean;\n let showUpperBound: boolean;\n if (orientation !== \"column\") {\n hoverWidth = hoverElement.clientWidth;\n hoverOffset += canvasMargin!;\n hoverOffset -= hoverWidth / 2;\n hoverOffset = Math.max(0, hoverOffset);\n const upperLimit =\n canvasHeight + canvasMargin! - upperBoundOffset / 2 - hoverWidth;\n showLowerBound = hoverOffset > canvasMargin! + lowerBoundOffset / 2;\n showUpperBound = hoverOffset < upperLimit;\n } else {\n showLowerBound = hoverOffset > lowerBoundOffset;\n showUpperBound = hoverOffset < canvasHeight - upperBoundOffset;\n }\n lowerBoundElement.style.visibility = showLowerBound ? \"\" : \"hidden\";\n upperBoundElement.style.visibility = showUpperBound ? \"\" : \"hidden\";\n hoverElement.style.display = \"\";\n hoverElement.style.visibility = \"visible\";\n if (orientation === \"column\") {\n hoverElement.style.marginTop = `${hoverOffset}px`;\n } else {\n hoverElement.style.marginLeft = `${hoverOffset}px`;\n }\n } else {\n lowerBoundElement.style.visibility = \"\";\n hoverElement.style.display = \"none\";\n upperBoundElement.style.visibility = \"\";\n }\n };\n const scheduleUpdateView = this.registerCancellable(\n animationFrameDebounce(updateView),\n );\n this.registerDisposer(this.position.changed.add(scheduleUpdateView));\n const getPositionFromMouseEvent = (\n event: MouseEvent,\n ): number | undefined => {\n if (prevLowerBound === undefined || prevUpperBound === undefined)\n return undefined;\n const canvasBounds = canvas.getBoundingClientRect();\n let relativeY: number;\n if (orientation === \"column\") {\n relativeY = (event.clientY - canvasBounds.top) / canvasBounds.height;\n } else {\n relativeY = (event.clientX - canvasBounds.left) / canvasBounds.width;\n }\n relativeY = Math.max(0, relativeY);\n relativeY = Math.min(1, relativeY);\n return (\n Math.round(relativeY * (prevUpperBound - prevLowerBound)) +\n prevLowerBound\n );\n };\n const setPositionFromMouse = (event: MouseEvent) => {\n const coordinateSpace = this.position.coordinateSpace.value;\n const dimensionIndex = coordinateSpace.ids.indexOf(this.dimensionId);\n if (dimensionIndex === -1) return;\n let x = getPositionFromMouseEvent(event);\n if (x === undefined) return;\n const { position } = this;\n const voxelCoordinates = position.value;\n if (\n !coordinateSpace.bounds.voxelCenterAtIntegerCoordinates[dimensionIndex]\n ) {\n x += 0.5;\n }\n voxelCoordinates[dimensionIndex] = x;\n position.value = voxelCoordinates;\n };\n\n canvas.addEventListener(\"pointermove\", (event: MouseEvent) => {\n const x = getPositionFromMouseEvent(event);\n hoverPosition = x;\n scheduleUpdateView();\n });\n canvas.addEventListener(\"pointerleave\", () => {\n hoverPosition = undefined;\n scheduleUpdateView();\n });\n\n canvas.addEventListener(\"pointerdown\", (event: MouseEvent) => {\n event.preventDefault();\n event.stopPropagation();\n if (event.ctrlKey || event.altKey || event.metaKey) {\n return;\n }\n startRelativeMouseDrag(\n event,\n (newEvent: MouseEvent) => {\n if (this.wasDisposed) return;\n hoverPosition = undefined;\n setPositionFromMouse(newEvent);\n scheduleUpdateView();\n this.dragging.value = true;\n },\n () => {\n this.dragging.value = false;\n scheduleUpdateView();\n },\n );\n setPositionFromMouse(event);\n });\n updateView();\n if (orientation === \"row\") {\n canvas.style.maxWidth = \"100%\";\n canvas.style.justifySelf = \"stretch\";\n const resizeObserver = new ResizeObserver(updateView);\n resizeObserver.observe(canvas);\n }\n }\n\n private drawDimensionBounds(\n canvas: HTMLCanvasElement,\n ctx: CanvasRenderingContext2D,\n bounds: NormalizedDimensionBounds,\n ) {\n const { orientation } = this;\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n const { normalizedBounds } = bounds;\n const drawTick =\n orientation === \"column\"\n ? (x: number) => {\n ctx.fillRect(0, x, this.tickWidth, 1);\n }\n : (x: number) => {\n ctx.fillRect(x, 0, 1, this.tickWidth);\n };\n ctx.fillStyle = \"#fff\";\n for (const { lower, upper } of normalizedBounds) {\n drawTick(lower);\n drawTick(upper);\n }\n const length = normalizedBounds.length;\n ctx.fillStyle = \"#ccc\";\n for (let i = 0; i < length; ++i) {\n const { lower, upper } = normalizedBounds[i];\n const startX = Math.floor((i * this.barWidth) / length);\n const width = Math.max(1, this.barWidth / length);\n if (orientation === \"column\") {\n ctx.fillRect(startX + this.tickWidth, lower, width, upper + 1 - lower);\n } else {\n ctx.fillRect(lower, startX + this.tickWidth, upper + 1 - lower, width);\n }\n }\n }\n}\n","/**\n * @license\n * Copyright 2017-2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport \"#src/widget/position_widget.css\";\n\nimport svg_pause from \"ikonate/icons/pause.svg?raw\";\nimport svg_play from \"ikonate/icons/play.svg?raw\";\nimport svg_video from \"ikonate/icons/video.svg?raw\";\nimport type {\n CoordinateArray,\n CoordinateSpace,\n CoordinateSpaceCombiner,\n DimensionId,\n} from \"#src/coordinate_transform.js\";\nimport {\n clampAndRoundCoordinateToVoxelCenter,\n emptyInvalidCoordinateSpace,\n insertDimensionAt,\n makeCoordinateSpace,\n} from \"#src/coordinate_transform.js\";\nimport type { MouseSelectionState, UserLayer } from \"#src/layer/index.js\";\nimport type { LayerGroupViewer } from \"#src/layer_group_viewer.js\";\nimport type {\n CoordinateSpacePlaybackVelocity,\n Position,\n} from \"#src/navigation_state.js\";\nimport { VelocityBoundaryBehavior } from \"#src/navigation_state.js\";\nimport { StatusMessage } from \"#src/status.js\";\nimport type { WatchableValueInterface } from \"#src/trackable_value.js\";\nimport {\n makeCachedDerivedWatchableValue,\n WatchableValue,\n} from \"#src/trackable_value.js\";\nimport type { LocalToolBinder, ToolActivation } from \"#src/ui/tool.js\";\nimport {\n makeToolActivationStatusMessage,\n makeToolButton,\n registerTool,\n Tool,\n} from \"#src/ui/tool.js\";\nimport { animationFrameDebounce } from \"#src/util/animation_frame_debounce.js\";\nimport { arraysEqual, binarySearch } from \"#src/util/array.js\";\nimport { setClipboard } from \"#src/util/clipboard.js\";\nimport type { Borrowed } from \"#src/util/disposable.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport {\n removeFromParent,\n updateChildren,\n updateInputFieldWidth,\n} from \"#src/util/dom.js\";\nimport { vec3 } from \"#src/util/geom.js\";\nimport { verifyObjectProperty, verifyString } from \"#src/util/json.js\";\nimport type { ActionEvent } from \"#src/util/keyboard_bindings.js\";\nimport {\n KeyboardEventBinder,\n registerActionListener,\n} from \"#src/util/keyboard_bindings.js\";\nimport { EventActionMap, MouseEventBinder } from \"#src/util/mouse_bindings.js\";\nimport { formatScaleWithUnit, parseScale } from \"#src/util/si_units.js\";\nimport { TrackableEnum } from \"#src/util/trackable_enum.js\";\nimport { getWheelZoomAmount } from \"#src/util/wheel_zoom.js\";\nimport type { Viewer } from \"#src/viewer.js\";\nimport { CheckboxIcon } from \"#src/widget/checkbox_icon.js\";\nimport { makeCopyButton } from \"#src/widget/copy_button.js\";\nimport { DependentViewWidget } from \"#src/widget/dependent_view_widget.js\";\nimport { EnumSelectWidget } from \"#src/widget/enum_widget.js\";\nimport { makeIcon } from \"#src/widget/icon.js\";\nimport { NumberInputWidget } from \"#src/widget/number_input_widget.js\";\nimport { PositionPlot } from \"#src/widget/position_plot.js\";\n\nexport const positionDragType = \"neuroglancer-position\";\n\nconst inputEventMap = EventActionMap.fromObject({\n arrowup: { action: \"adjust-up\" },\n arrowdown: { action: \"adjust-down\" },\n arrowleft: { action: \"maybe-tab-backward\", preventDefault: false },\n arrowright: { action: \"maybe-tab-forward\", preventDefault: false },\n tab: { action: \"tab-forward\" },\n \"shift+tab\": { action: \"tab-backward\" },\n wheel: { action: \"adjust-via-wheel\" },\n \"alt+wheel\": { action: \"adjust-velocity-via-wheel\" },\n backspace: { action: \"delete-backward\", preventDefault: false },\n enter: { action: \"commit\" },\n escape: { action: \"cancel\" },\n});\n\nconst widgetFieldGetters: ((widget: DimensionWidget) => HTMLInputElement)[] = [\n (w) => w.nameElement,\n (w) => w.coordinate,\n (w) => w.scaleElement,\n];\n\n// Returns the coordinate array for the specified dimension, if valid.\n//\n// If no coordinate array is specified, returns `undefined`.\n//\n// If a coordinate array is specified but there is a unit or scale specified, returns `null`.\n//\n// Otherwise, returns the coordinate array.\nfunction getCoordinateArray(\n coordinateSpace: CoordinateSpace,\n dimensionIndex: number,\n): CoordinateArray | undefined | null {\n const coordinateArray = coordinateSpace.coordinateArrays[dimensionIndex];\n if (coordinateArray === undefined) return coordinateArray;\n if (\n coordinateSpace.units[dimensionIndex] !== \"\" ||\n coordinateSpace.scales[dimensionIndex] !== 1\n ) {\n return null;\n }\n return coordinateArray;\n}\n\nclass DimensionWidget {\n container = document.createElement(\"div\");\n nameContainer = document.createElement(\"span\");\n nameElement = document.createElement(\"input\");\n scaleContainer = document.createElement(\"span\");\n scaleElement = document.createElement(\"input\");\n coordinate = document.createElement(\"input\");\n coordinateLabel = document.createElement(\"span\");\n playButton = document.createElement(\"div\");\n pauseButton = document.createElement(\"div\");\n coordinateLabelWidth = 0;\n\n // Maximum possible position width given the current coordinate space.\n maxPositionWidth = 0;\n\n // Maximum position width seen so far.\n //\n // If the bounds are known when this DimensionWidget is first created, this is initialized to\n // `maxPositionWidth`. Otherwise it is initialized to `0`.\n maxPositionWidthSeen = 0;\n\n dropdownOwner: RefCounted | undefined = undefined;\n modified = false;\n draggingPosition = false;\n hasFocus = false;\n\n constructor(\n public coordinateSpace: CoordinateSpace,\n public id: DimensionId,\n initialDimensionIndex: number,\n options: { allowFocus: boolean; showPlayback: boolean },\n ) {\n const {\n container,\n scaleElement,\n scaleContainer,\n coordinate,\n nameElement,\n nameContainer,\n coordinateLabel,\n playButton,\n pauseButton,\n } = this;\n container.title = \"\";\n container.classList.add(\"neuroglancer-position-dimension\");\n const { allowFocus, showPlayback } = options;\n if (allowFocus) {\n container.draggable = true;\n container.tabIndex = -1;\n }\n container.appendChild(nameContainer);\n container.appendChild(scaleElement);\n nameContainer.appendChild(nameElement);\n nameContainer.title = `Drag to reorder, double click to rename. Names ending in ' or ^ indicate dimensions local to the layer; names ending in ^ indicate channel dimensions (image layers only).`;\n scaleContainer.appendChild(scaleElement);\n nameElement.classList.add(\"neuroglancer-position-dimension-name\");\n nameElement.disabled = true;\n nameElement.spellcheck = false;\n nameElement.autocomplete = \"off\";\n nameElement.required = true;\n nameElement.placeholder = \" \";\n scaleContainer.classList.add(\n \"neuroglancer-position-dimension-scale-container\",\n );\n scaleElement.classList.add(\"neuroglancer-position-dimension-scale\");\n scaleElement.disabled = true;\n scaleElement.spellcheck = false;\n scaleElement.autocomplete = \"off\";\n container.appendChild(scaleContainer);\n\n if (showPlayback) {\n playButton.classList.add(\"neuroglancer-icon\");\n pauseButton.classList.add(\"neuroglancer-icon\");\n playButton.innerHTML = svg_play;\n pauseButton.innerHTML = svg_pause;\n container.appendChild(playButton);\n container.appendChild(pauseButton);\n }\n\n container.appendChild(coordinate);\n coordinate.type = \"text\";\n coordinate.classList.add(\"neuroglancer-position-dimension-coordinate\");\n coordinate.spellcheck = false;\n coordinate.autocomplete = \"off\";\n coordinate.pattern = String.raw`(-?\\d+(?:\\.(?:\\d+)?)?)`;\n const coordinateArray = getCoordinateArray(\n coordinateSpace,\n initialDimensionIndex,\n );\n if (coordinateArray != null) {\n let maxLabelWidth = 0;\n for (const label of coordinateArray.labels) {\n maxLabelWidth = Math.max(maxLabelWidth, label.length);\n }\n this.coordinateLabelWidth = maxLabelWidth;\n coordinateLabel.style.width = `${maxLabelWidth + 2}ch`;\n container.appendChild(coordinateLabel);\n }\n coordinate.required = true;\n coordinate.placeholder = \" \";\n coordinateLabel.classList.add(\n \"neuroglancer-position-dimension-coordinate-label\",\n );\n\n if (allowFocus) {\n nameContainer.addEventListener(\"dblclick\", () => {\n nameElement.disabled = false;\n nameElement.focus();\n nameElement.select();\n });\n scaleContainer.addEventListener(\"dblclick\", () => {\n scaleElement.disabled = false;\n scaleElement.focus();\n scaleElement.select();\n });\n coordinate.addEventListener(\"focus\", () => {\n coordinate.select();\n });\n container.addEventListener(\"click\", (event: PointerEvent) => {\n if (\n !(event.target instanceof HTMLInputElement) ||\n event.target.disabled\n ) {\n coordinate.focus();\n }\n });\n }\n }\n}\n\n// Updates the width of the coordinate field to the max of:\n//\n// - The current size.\n//\n// - Maximum size seen so far, bounded by maximum width for the current lower/upper\n// bounds.\n//\n// The purpose of this is to avoid repeatedly changing the layout when using velocity, and also\n// changing the layout as Neuroglancer first loads and the bounds are not yet known.\nfunction updateCoordinateFieldWidth(widget: DimensionWidget, value: string) {\n const curLength = value.length;\n if (curLength > widget.maxPositionWidthSeen) {\n widget.maxPositionWidthSeen = curLength;\n }\n updateInputFieldWidth(\n widget.coordinate,\n Math.max(\n Math.min(widget.maxPositionWidth, widget.maxPositionWidthSeen),\n curLength,\n ),\n );\n}\n\nfunction updateScaleElementStyle(scaleElement: HTMLInputElement) {\n const { value } = scaleElement;\n updateInputFieldWidth(scaleElement);\n scaleElement.parentElement!.dataset.isEmpty = value === \"\" ? \"true\" : \"false\";\n}\n\nexport class PositionWidget extends RefCounted {\n element = document.createElement(\"div\");\n private dimensionContainer = document.createElement(\"div\");\n private coordinateSpace: CoordinateSpace | undefined = undefined;\n private velocity: CoordinateSpacePlaybackVelocity | undefined;\n private singleDimensionId: DimensionId | undefined;\n private getToolBinder: (() => LocalToolBinder | undefined) | undefined;\n private allowFocus: boolean;\n private showPlayback: boolean;\n\n private dimensionWidgets = new Map();\n private dimensionWidgetList: DimensionWidget[] = [];\n\n getDimensionIndex(id: DimensionId): number {\n const coordinateSpace = this.position.coordinateSpace.value;\n return coordinateSpace.ids.indexOf(id);\n }\n\n private openRegularDropdown(\n widget: DimensionWidget,\n dropdown: HTMLDivElement,\n ) {\n dropdown.classList.add(\"neuroglancer-position-dimension-dropdown\");\n\n const dropdownOwner = widget.dropdownOwner!;\n const toolBinder = this.getToolBinder?.();\n if (toolBinder !== undefined) {\n const dimensionIndex = this.getDimensionIndex(widget.id);\n const toolButton = makeToolButton(dropdownOwner, toolBinder, {\n toolJson: {\n type: DIMENSION_TOOL_ID,\n dimension: widget.coordinateSpace.names[dimensionIndex],\n },\n });\n dropdown.appendChild(toolButton);\n }\n\n const plot = dropdownOwner.registerDisposer(\n new PositionPlot(this.position, widget.id),\n );\n dropdown.appendChild(plot.element);\n\n const watchableVelocity = this.velocity?.dimensionVelocity(\n dropdownOwner,\n widget.id,\n );\n if (watchableVelocity !== undefined) {\n const playbackElement = document.createElement(\"div\");\n playbackElement.classList.add(\"neuroglancer-position-dimension-playback\");\n const header = document.createElement(\"div\");\n header.classList.add(\"neuroglancer-position-dimension-playback-header\");\n playbackElement.appendChild(header);\n header.appendChild(\n dropdownOwner.registerDisposer(\n new CheckboxIcon(this.velocity!.playbackEnabled(widget.id), {\n svg: svg_video,\n enableTitle: \"Enable playback/velocity\",\n disableTitle: \"Disable playback/velocity\",\n backgroundScheme: \"dark\",\n }),\n ).element,\n );\n header.appendChild(document.createTextNode(\"Playback\"));\n dropdown.appendChild(playbackElement);\n const enabled = dropdownOwner.registerDisposer(\n makeCachedDerivedWatchableValue(\n (value) => value !== undefined,\n [watchableVelocity],\n ),\n );\n playbackElement.appendChild(\n dropdownOwner.registerDisposer(\n new DependentViewWidget(enabled, (enabledValue, parent, context) => {\n if (!enabledValue) return;\n const velocityModel = new WatchableValue(0);\n velocityModel.changed.add(() => {\n const newValue = velocityModel.value;\n const velocity = watchableVelocity.value;\n if (velocity === undefined) return;\n if (velocity.velocity === newValue) return;\n watchableVelocity.value = { ...velocity, velocity: newValue };\n });\n const negateButton = makeIcon({\n text: \"±\",\n title: \"Negate velocity\",\n onClick: () => {\n velocityModel.value = -velocityModel.value;\n },\n });\n const velocityInputWidget = context.registerDisposer(\n new NumberInputWidget(velocityModel),\n );\n velocityInputWidget.element.insertBefore(\n negateButton,\n velocityInputWidget.element.firstChild,\n );\n velocityInputWidget.element.title =\n \"Velocity in coordinates per second\";\n const rateSpan = document.createElement(\"span\");\n rateSpan.textContent = \"/s\";\n velocityInputWidget.element.appendChild(rateSpan);\n parent.appendChild(velocityInputWidget.element);\n const trackableEnum = new TrackableEnum(\n VelocityBoundaryBehavior,\n VelocityBoundaryBehavior.STOP,\n );\n const watchableVelocityChanged = () => {\n trackableEnum.value =\n watchableVelocity.value?.atBoundary ??\n VelocityBoundaryBehavior.STOP;\n velocityModel.value = watchableVelocity.value?.velocity ?? 0;\n };\n watchableVelocityChanged();\n context.registerDisposer(\n watchableVelocity.changed.add(watchableVelocityChanged),\n );\n trackableEnum.changed.add(() => {\n const atBoundary = trackableEnum.value;\n const velocity = watchableVelocity.value;\n if (velocity === undefined) return;\n if (velocity.atBoundary === atBoundary) return;\n watchableVelocity.value = { ...velocity, atBoundary };\n });\n const selectWidget = new EnumSelectWidget(trackableEnum).element;\n parent.appendChild(selectWidget);\n selectWidget.title = \"Behavior when lower/upper bound is reached\";\n }),\n ).element,\n );\n }\n plot.dragging.changed.add(() => {\n const newValue = (widget.draggingPosition = plot.dragging.value);\n if (newValue === false) {\n this.updateDropdownVisibility(widget);\n }\n });\n }\n\n private openCoordinateArrayDropdown(\n widget: DimensionWidget,\n dropdown: HTMLDivElement,\n coordinateArray: CoordinateArray,\n ) {\n dropdown.classList.add(\n \"neuroglancer-position-dimension-coordinate-dropdown\",\n );\n const { coordinates, labels } = coordinateArray;\n const entries: {\n entryElement: HTMLDivElement;\n coordinateElement: HTMLDivElement;\n labelElement: HTMLDivElement;\n }[] = [];\n const length = coordinates.length;\n dropdown.style.setProperty(\n \"--neuroglancer-coordinate-label-width\",\n `${widget.coordinateLabelWidth}ch`,\n );\n for (let i = 0; i < length; ++i) {\n const entryElement = document.createElement(\"div\");\n entryElement.classList.add(\n \"neuroglancer-dimension-dropdown-coordinate-entry\",\n );\n const coordinateElement = document.createElement(\"div\");\n coordinateElement.classList.add(\n \"neuroglancer-dimension-dropdown-coordinate\",\n );\n const labelElement = document.createElement(\"div\");\n labelElement.classList.add(\n \"neuroglancer-dimension-dropdown-coordinate-label\",\n );\n labelElement.textContent = labels[i];\n coordinateElement.textContent = coordinates[i].toString();\n entryElement.appendChild(coordinateElement);\n entryElement.appendChild(labelElement);\n entryElement.addEventListener(\"click\", () => {\n const dimensionIndex = this.getDimensionIndex(widget.id);\n if (dimensionIndex === -1) return;\n const { position } = this;\n const voxelCoordinates = position.value;\n voxelCoordinates[dimensionIndex] = coordinates[i] + 0.5;\n widget.modified = false;\n position.value = voxelCoordinates;\n });\n dropdown.appendChild(entryElement);\n entries.push({ entryElement, coordinateElement, labelElement });\n }\n // const dropdownOwner = widget.dropdownOwner!;\n }\n\n private openDropdown(widget: DimensionWidget) {\n if (widget.dropdownOwner !== undefined) return;\n const dimensionIndex = this.getDimensionIndex(widget.id);\n if (dimensionIndex === -1) return;\n this.closeDropdown();\n const dropdownOwner = (widget.dropdownOwner = new RefCounted());\n const dropdown = document.createElement(\"div\");\n dropdown.draggable = true;\n dropdown.addEventListener(\"dragstart\", (event) => {\n event.stopPropagation();\n event.preventDefault();\n });\n dropdown.addEventListener(\"pointerenter\", () => {\n widget.hasFocus = true;\n });\n dropdown.tabIndex = -1;\n widget.container.appendChild(dropdown);\n\n const coordinateArray = getCoordinateArray(\n widget.coordinateSpace,\n dimensionIndex,\n );\n if (coordinateArray == null) {\n this.openRegularDropdown(widget, dropdown);\n } else {\n this.openCoordinateArrayDropdown(widget, dropdown, coordinateArray);\n }\n\n this.widgetWithOpenDropdown = widget;\n\n dropdownOwner.registerDisposer(() => {\n removeFromParent(dropdown);\n widget.dropdownOwner = undefined;\n widget.container.dataset.dropdownVisible = undefined;\n this.widgetWithOpenDropdown = undefined;\n });\n\n dropdownOwner.registerEventListener(\n document,\n \"pointerdown\",\n (event: MouseEvent) => {\n const { target } = event;\n if (target instanceof Node && widget.container.contains(target)) {\n return;\n }\n this.closeDropdown(widget);\n },\n { capture: true },\n );\n }\n\n private widgetWithOpenDropdown: DimensionWidget | undefined;\n\n private closeDropdown(widget = this.widgetWithOpenDropdown) {\n if (widget === undefined) return;\n const { dropdownOwner } = widget;\n if (dropdownOwner === undefined) return;\n dropdownOwner.dispose();\n }\n\n private pasteString(widget: DimensionWidget, s: string) {\n while (true) {\n widget.coordinate.focus();\n const m = s.match(\n /^\\s*(-?\\d+(?:\\.(?:\\d+)?)?)((?:\\s+(?![\\s,]))|(?:\\s*,\\s*))?/,\n );\n if (m === null) break;\n if (m[1] !== undefined) {\n document.execCommand(\"insertText\", undefined, m[1]);\n }\n if (m[2] !== undefined) {\n const { dimensionWidgetList } = this;\n const dimensionIndex = dimensionWidgetList.indexOf(widget);\n if (\n dimensionIndex === -1 ||\n dimensionIndex + 1 === dimensionWidgetList.length\n ) {\n break;\n }\n const remaining = s.substring(m[0].length);\n const nextWidget = dimensionWidgetList[dimensionIndex + 1];\n widget = nextWidget;\n s = remaining;\n continue;\n }\n break;\n }\n }\n\n private dragSource: DimensionWidget | undefined = undefined;\n\n private reorderDimensionTo(targetIndex: number, sourceIndex: number) {\n if (targetIndex === sourceIndex) return;\n const { coordinateSpace } = this.position;\n coordinateSpace.value = insertDimensionAt(\n coordinateSpace.value,\n targetIndex,\n sourceIndex,\n );\n }\n\n private updateDropdownVisibility(widget: DimensionWidget) {\n if (widget.hasFocus || widget.draggingPosition) {\n this.openDropdown(widget);\n } else {\n this.closeDropdown(widget);\n }\n }\n\n private newDimension(\n coordinateSpace: CoordinateSpace,\n id: DimensionId,\n initialDimensionIndex: number,\n ) {\n const widget = new DimensionWidget(\n coordinateSpace,\n id,\n initialDimensionIndex,\n { allowFocus: this.allowFocus, showPlayback: this.showPlayback },\n );\n if (this.singleDimensionId === undefined) {\n widget.container.addEventListener(\"dragstart\", (event: DragEvent) => {\n this.dragSource = widget;\n event.stopPropagation();\n event.dataTransfer!.setData(\"neuroglancer-dimension\", \"\");\n });\n widget.container.addEventListener(\"dragenter\", (event: DragEvent) => {\n const { dragSource } = this;\n if (dragSource === undefined || dragSource === widget) return;\n const { dimensionWidgetList } = this;\n const sourceIndex = dimensionWidgetList.indexOf(dragSource);\n const targetIndex = dimensionWidgetList.indexOf(widget);\n if (sourceIndex === -1 || targetIndex === -1) return;\n event.preventDefault();\n this.reorderDimensionTo(targetIndex, sourceIndex);\n });\n widget.container.addEventListener(\"dragend\", (event: DragEvent) => {\n event;\n if (this.dragSource === widget) {\n this.dragSource = undefined;\n }\n });\n }\n if (this.allowFocus) {\n widget.container.addEventListener(\"focusin\", () => {\n widget.hasFocus = true;\n this.updateDropdownVisibility(widget);\n });\n widget.container.addEventListener(\"focusout\", (event: FocusEvent) => {\n const { relatedTarget } = event;\n if (\n relatedTarget instanceof Node &&\n widget.container.contains(relatedTarget)\n ) {\n return;\n }\n widget.hasFocus = false;\n this.updateDropdownVisibility(widget);\n });\n widget.coordinate.addEventListener(\"paste\", (event: ClipboardEvent) => {\n const input = widget.coordinate;\n const value = input.value;\n const { clipboardData } = event;\n if (clipboardData === null) return;\n let text = clipboardData.getData(\"text\");\n let { selectionEnd, selectionStart } = input;\n if (selectionStart !== 0 || selectionEnd !== value.length) {\n if (selectionStart == null) selectionStart = 0;\n if (selectionEnd == null) selectionEnd = 0;\n const invalidMatch = text.match(/[^\\-0-9.]/);\n if (invalidMatch !== null) {\n text = text.substring(0, invalidMatch.index);\n }\n if (text.length > 0) {\n document.execCommand(\"insertText\", undefined, text);\n }\n } else {\n this.pasteString(widget, text);\n }\n event.preventDefault();\n event.stopPropagation();\n });\n widget.coordinate.addEventListener(\"input\", () => {\n widget.modified = true;\n const input = widget.coordinate;\n const value = input.value;\n let { selectionDirection, selectionEnd, selectionStart } = input;\n if (selectionStart === null) selectionStart = 0;\n if (selectionEnd === null) selectionEnd = selectionStart;\n let newValue = \"\";\n const invalidPattern = /[^\\-0-9.]/g;\n newValue += value\n .substring(0, selectionStart)\n .replace(invalidPattern, \"\");\n const newSelectionStart = newValue.length;\n newValue += value\n .substring(selectionStart, selectionEnd)\n .replace(invalidPattern, \"\");\n const newSelectionEnd = newValue.length;\n newValue += value.substring(selectionEnd).replace(invalidPattern, \"\");\n input.value = newValue;\n input.selectionStart = newSelectionStart;\n input.selectionEnd = newSelectionEnd;\n input.selectionDirection = selectionDirection;\n updateCoordinateFieldWidth(widget, newValue);\n if (\n selectionEnd === selectionStart &&\n selectionEnd === value.length &&\n value.match(/^(-?\\d+(?:\\.(?:\\d+)?)?)((?:\\s+(?![\\s,]))|(?:\\s*,\\s*))$/)\n ) {\n this.selectAdjacentCoordinate(widget, 1);\n }\n });\n\n widget.nameElement.addEventListener(\"input\", () => {\n const { nameElement } = widget;\n updateInputFieldWidth(nameElement);\n this.updateNameValidity();\n });\n\n widget.scaleElement.addEventListener(\"input\", () => {\n const { scaleElement } = widget;\n updateScaleElementStyle(scaleElement);\n this.updateScaleValidity(widget);\n });\n\n widget.coordinate.addEventListener(\"blur\", (event) => {\n const { relatedTarget } = event;\n if (\n this.dimensionWidgetList.some(\n (widget) => widget.coordinate === relatedTarget,\n )\n ) {\n return;\n }\n if (widget.modified) {\n this.updatePosition();\n }\n });\n\n widget.nameElement.addEventListener(\"blur\", (event) => {\n widget.nameElement.disabled = true;\n const { relatedTarget } = event;\n if (\n this.dimensionWidgetList.some(\n (widget) => widget.nameElement === relatedTarget,\n )\n ) {\n return;\n }\n if (!this.updateNames()) {\n this.forceUpdateDimensions();\n }\n });\n\n widget.scaleElement.addEventListener(\"blur\", (event) => {\n widget.scaleElement.disabled = true;\n const { relatedTarget } = event;\n if (\n this.dimensionWidgetList.some(\n (widget) => widget.scaleElement === relatedTarget,\n )\n ) {\n return;\n }\n if (!this.updateScales()) {\n this.forceUpdateDimensions();\n }\n });\n } else {\n widget.coordinate.disabled = true;\n }\n\n registerActionListener(\n widget.container,\n \"adjust-via-wheel\",\n (actionEvent) => {\n const event = actionEvent.detail;\n const { deltaY } = event;\n if (deltaY === 0) {\n return;\n }\n this.adjustDimensionPosition(widget.id, Math.sign(deltaY));\n },\n );\n\n registerActionListener(\n widget.container,\n \"adjust-velocity-via-wheel\",\n (actionEvent) => {\n const event = actionEvent.detail;\n this.adjustDimensionVelocity(widget, getWheelZoomAmount(event));\n },\n );\n\n registerActionListener(widget.container, \"adjust-up\", () => {\n this.adjustDimensionPosition(widget.id, -1);\n });\n registerActionListener(widget.container, \"adjust-down\", () => {\n this.adjustDimensionPosition(widget.id, 1);\n });\n\n for (const getter of widgetFieldGetters) {\n const e = getter(widget);\n registerActionListener(e, \"maybe-tab-forward\", (event) => {\n this.handleLeftRightMovement(event, widget, 1, getter);\n });\n registerActionListener(e, \"maybe-tab-backward\", (event) => {\n this.handleLeftRightMovement(event, widget, -1, getter);\n });\n registerActionListener(e, \"tab-forward\", () => {\n this.selectAdjacentField(widget, 1, getter);\n });\n registerActionListener(e, \"tab-backward\", () => {\n this.selectAdjacentField(widget, -1, getter);\n });\n }\n\n registerActionListener(widget.coordinate, \"commit\", () => {\n this.updatePosition();\n });\n\n registerActionListener(widget.nameElement, \"commit\", () => {\n this.updateNames();\n });\n\n registerActionListener(widget.scaleElement, \"commit\", () => {\n this.updateScales();\n });\n\n registerActionListener(widget.coordinate, \"delete-backward\", (event) => {\n event.stopPropagation();\n const { coordinate } = widget;\n if (\n coordinate.selectionStart === coordinate.selectionEnd &&\n coordinate.selectionStart === 0\n ) {\n event.preventDefault();\n this.selectAdjacentCoordinate(widget, -1);\n }\n });\n\n if (this.showPlayback) {\n const setPaused = (paused: boolean) => {\n this.velocity?.togglePlayback(widget.id, paused);\n };\n widget.playButton.addEventListener(\"click\", () => setPaused(false));\n widget.pauseButton.addEventListener(\"click\", () => setPaused(true));\n }\n\n return widget;\n }\n\n private forceUpdateDimensions() {\n let {\n position: {\n coordinateSpace: { value: coordinateSpace },\n },\n } = this;\n if (!coordinateSpace.valid) {\n coordinateSpace = emptyInvalidCoordinateSpace;\n }\n this.coordinateSpace = coordinateSpace;\n const { dimensionWidgets, dimensionWidgetList } = this;\n dimensionWidgetList.length = 0;\n const {\n names,\n ids,\n scales,\n units,\n bounds: { lowerBounds, upperBounds },\n } = coordinateSpace;\n const getDimensionWidget = (id: DimensionId, i: number) => {\n // Calculate max position width.\n const lower = lowerBounds[i];\n const upper = upperBounds[i];\n const maxPositionWidth = Math.max(\n Number.isFinite(lower) ? Math.floor(lower).toString().length : 0,\n Number.isFinite(upper) ? Math.ceil(upper).toString().length : 0,\n );\n let widget = dimensionWidgets.get(id);\n if (widget === undefined) {\n widget = this.newDimension(coordinateSpace, id, i);\n dimensionWidgets.set(id, widget);\n widget.maxPositionWidthSeen = maxPositionWidth;\n } else {\n widget.coordinateSpace = coordinateSpace;\n }\n widget.maxPositionWidth = maxPositionWidth;\n const name = names[i];\n widget.nameElement.value = name;\n widget.nameElement.dataset.isValid = undefined;\n updateInputFieldWidth(widget.nameElement);\n const coordinateArray = getCoordinateArray(coordinateSpace, i);\n if (coordinateArray === undefined) {\n widget.container.dataset.coordinateArray = \"none\";\n } else if (coordinateArray === null) {\n widget.container.dataset.coordinateArray = \"invalid\";\n } else {\n widget.container.dataset.coordinateArray = \"valid\";\n }\n widget.scaleContainer.title =\n \"Drag to reorder, double click to change scale\";\n if (coordinateArray === null) {\n widget.scaleContainer.title +=\n \". Coordinate array disabled. To use the coordinate array, remove the unit/scale.\";\n }\n const { scale, prefix, unit } = formatScaleWithUnit(scales[i], units[i]);\n const scaleString = `${scale}${prefix}${unit}`;\n widget.scaleElement.value = scaleString;\n widget.scaleElement.dataset.isValid = undefined;\n updateScaleElementStyle(widget.scaleElement);\n dimensionWidgetList.push(widget);\n return widget.container;\n };\n const { singleDimensionId } = this;\n if (singleDimensionId !== undefined) {\n const dimensionIndex = this.getDimensionIndex(singleDimensionId);\n if (dimensionIndex === -1) {\n updateChildren(this.dimensionContainer, []);\n } else {\n updateChildren(this.dimensionContainer, [\n getDimensionWidget(singleDimensionId, dimensionIndex),\n ]);\n }\n } else {\n updateChildren(this.dimensionContainer, ids.map(getDimensionWidget));\n }\n for (const [id, widget] of dimensionWidgets) {\n if (widget.coordinateSpace !== coordinateSpace) {\n this.closeDropdown(widget);\n dimensionWidgets.delete(id);\n }\n }\n }\n\n private updateDimensions() {\n const {\n position: {\n coordinateSpace: { value: coordinateSpace },\n },\n } = this;\n if (coordinateSpace === this.coordinateSpace) return;\n this.forceUpdateDimensions();\n }\n\n private selectAdjacentField(\n widget: DimensionWidget,\n dir: number,\n fieldGetter: (widget: DimensionWidget) => HTMLInputElement,\n ) {\n const { dimensionWidgetList } = this;\n let axisIndex = dimensionWidgetList.indexOf(widget);\n if (axisIndex === -1) return;\n while (true) {\n axisIndex += dir;\n if (axisIndex < 0 || axisIndex >= dimensionWidgetList.length) {\n return false;\n }\n const newWidget = dimensionWidgetList[axisIndex];\n const field = fieldGetter(newWidget);\n if (field.style.display === \"none\") continue;\n field.disabled = false;\n field.focus();\n field.selectionStart = 0;\n field.selectionEnd = field.value.length;\n field.selectionDirection = dir === 1 ? \"forward\" : \"backward\";\n return true;\n }\n }\n\n private selectAdjacentCoordinate(widget: DimensionWidget, dir: number) {\n return this.selectAdjacentField(widget, dir, (w) => w.coordinate);\n }\n\n private handleLeftRightMovement(\n event: ActionEvent,\n widget: DimensionWidget,\n dir: number,\n getter: (widget: DimensionWidget) => HTMLInputElement,\n ) {\n event.stopPropagation();\n const element = getter(widget);\n if (\n element.selectionStart !== element.selectionEnd ||\n element.selectionStart !== (dir === 1 ? element.value.length : 0)\n ) {\n return;\n }\n if (this.selectAdjacentField(widget, dir, getter)) {\n event.preventDefault();\n }\n }\n\n private updateNameValidity() {\n const { dimensionWidgetList } = this;\n const names = dimensionWidgetList.map((w) => w.nameElement.value);\n const rank = names.length;\n const isValid = this.combiner.getRenameValidity(names);\n for (let i = 0; i < rank; ++i) {\n dimensionWidgetList[i].nameElement.dataset.isValid =\n isValid[i] === false ? \"false\" : \"true\";\n }\n }\n\n private updateScaleValidity(widget: DimensionWidget) {\n const isValid = parseScale(widget.scaleElement.value) !== undefined;\n widget.scaleElement.dataset.isValid = isValid.toString();\n }\n\n constructor(\n public position: Borrowed,\n public combiner: CoordinateSpaceCombiner,\n {\n copyButton = true,\n velocity = undefined,\n singleDimensionId = undefined,\n getToolBinder = undefined,\n allowFocus = true,\n showPlayback = true,\n }: {\n copyButton?: boolean;\n velocity?: CoordinateSpacePlaybackVelocity;\n singleDimensionId?: DimensionId;\n getToolBinder?: (() => LocalToolBinder | undefined) | undefined;\n allowFocus?: boolean;\n showPlayback?: boolean;\n } = {},\n ) {\n super();\n const { element, dimensionContainer } = this;\n this.velocity = velocity;\n this.singleDimensionId = singleDimensionId;\n this.getToolBinder = getToolBinder;\n this.allowFocus = allowFocus;\n this.showPlayback = showPlayback;\n this.registerDisposer(\n position.coordinateSpace.changed.add(\n this.registerCancellable(\n animationFrameDebounce(() => this.updateDimensions()),\n ),\n ),\n );\n element.className = \"neuroglancer-position-widget\";\n dimensionContainer.style.display = \"contents\";\n element.appendChild(dimensionContainer);\n if (copyButton) {\n const copyButton = makeCopyButton({\n title: \"Copy position to clipboard\",\n onClick: () => {\n const result = setClipboard(this.getPositionText());\n StatusMessage.showTemporaryMessage(\n result\n ? \"Position copied to clipboard\"\n : \"Failed to copy position to clipboard\",\n );\n },\n });\n copyButton.addEventListener(\"dragstart\", (event) => {\n event.dataTransfer!.setData(\n positionDragType,\n JSON.stringify({\n position: position.toJSON(),\n dimensions: position.coordinateSpace.value.names,\n }),\n );\n event.dataTransfer!.setData(\"text\", this.getPositionText());\n event.stopPropagation();\n });\n copyButton.draggable = true;\n element.appendChild(copyButton);\n }\n\n const debouncedUpdateView = this.registerCancellable(\n animationFrameDebounce(() => this.updateView()),\n );\n this.registerDisposer(position.changed.add(debouncedUpdateView));\n if (velocity !== undefined) {\n this.registerDisposer(velocity.changed.add(debouncedUpdateView));\n }\n\n const shouldIgnoreEvent = (event: Event) => {\n const target = event.target;\n if (\n target instanceof Element &&\n target.matches(\".neuroglancer-position-dimension-playback *\")\n ) {\n return true;\n }\n return false;\n };\n if (allowFocus) {\n const keyboardHandler = this.registerDisposer(\n new KeyboardEventBinder(element, inputEventMap),\n );\n keyboardHandler.allShortcutsAreGlobal = true;\n keyboardHandler.shouldIgnore = shouldIgnoreEvent;\n }\n const mouseHandler = this.registerDisposer(\n new MouseEventBinder(element, inputEventMap),\n );\n mouseHandler.shouldIgnore = shouldIgnoreEvent;\n this.registerDisposer(\n registerActionListener(element, \"cancel\", (event) => {\n this.coordinateSpace = undefined;\n this.updateView();\n this.closeDropdown();\n const { target } = event;\n if (target instanceof HTMLElement) {\n target.blur();\n }\n }),\n );\n this.updateView();\n }\n\n adjustDimensionPosition(id: DimensionId, adjustment: number) {\n const axisIndex = this.getDimensionIndex(id);\n if (axisIndex === -1) return;\n this.updatePosition();\n const { position } = this;\n if (!position.valid) {\n return;\n }\n const coordinateSpace = position.coordinateSpace.value;\n const { bounds } = coordinateSpace;\n const voxelCoordinates = Float32Array.from(position.value);\n voxelCoordinates[axisIndex] = clampAndRoundCoordinateToVoxelCenter(\n bounds,\n axisIndex,\n voxelCoordinates[axisIndex] + adjustment,\n );\n this.position.value = voxelCoordinates;\n this.updateView();\n }\n\n adjustDimensionVelocity(widget: DimensionWidget, factor: number) {\n const { velocity } = this;\n if (velocity === undefined) return;\n velocity.multiplyVelocity(widget.id, factor);\n }\n\n private updatePosition() {\n if (!this.allowFocus) return;\n const { dimensionWidgetList } = this;\n const { position } = this;\n const { value: voxelCoordinates } = position;\n const coordinateSpace = position.coordinateSpace.value;\n if (voxelCoordinates === undefined) return;\n const rank = dimensionWidgetList.length;\n let modified = false;\n for (let i = 0; i < rank; ++i) {\n const widget = dimensionWidgetList[i];\n if (!widget.modified) continue;\n widget.modified = false;\n modified = true;\n const valueString = widget.coordinate.value;\n let value = Number(valueString);\n if (!Number.isFinite(value)) continue;\n // If `valueString` contains a decimal point, don't adjust to voxel center.\n if (\n Number.isInteger(value) &&\n !valueString.includes(\".\") &&\n coordinateSpace !== undefined &&\n !coordinateSpace.bounds.voxelCenterAtIntegerCoordinates[i]\n ) {\n value += 0.5;\n }\n voxelCoordinates[i] = value;\n }\n if (modified) {\n position.value = voxelCoordinates;\n }\n }\n\n private updateNames() {\n if (!this.allowFocus) return;\n const { dimensionWidgetList } = this;\n const {\n position: { coordinateSpace },\n } = this;\n const existing = coordinateSpace.value;\n const names = dimensionWidgetList.map((x) => x.nameElement.value);\n if (this.combiner.getRenameValidity(names).includes(false)) return false;\n const existingNames = existing.names;\n if (arraysEqual(existingNames, names)) return false;\n const timestamps = existing.timestamps.map((t, i) =>\n existingNames[i] === names[i] ? t : Date.now(),\n );\n const newSpace = { ...existing, names, timestamps };\n coordinateSpace.value = newSpace;\n return true;\n }\n\n private updateScales() {\n if (!this.allowFocus) return;\n const { dimensionWidgetList } = this;\n const {\n position: { coordinateSpace },\n } = this;\n const existing = coordinateSpace.value;\n const scalesAndUnits = dimensionWidgetList.map((x) =>\n parseScale(x.scaleElement.value),\n );\n if (scalesAndUnits.includes(undefined)) {\n return false;\n }\n const newScales = Float64Array.from(scalesAndUnits, (x) => x!.scale);\n const newUnits = Array.from(scalesAndUnits, (x) => x!.unit);\n const { scales, units } = existing;\n if (arraysEqual(scales, newScales) && arraysEqual(units, newUnits))\n return false;\n const timestamps = existing.timestamps.map((t, i) =>\n newScales[i] === scales[i] && newUnits[i] === units[i] ? t : Date.now(),\n );\n const newSpace = makeCoordinateSpace({\n valid: existing.valid,\n rank: existing.rank,\n scales: newScales,\n units: newUnits,\n timestamps,\n ids: existing.ids,\n names: existing.names,\n boundingBoxes: existing.boundingBoxes,\n coordinateArrays: existing.coordinateArrays,\n });\n coordinateSpace.value = newSpace;\n return true;\n }\n\n private getPositionText() {\n const { position } = this;\n if (position.valid) {\n return position.value.map((x) => Math.floor(x)).join(\", \");\n }\n return \"\";\n }\n\n private updateView() {\n this.updateDimensions();\n const {\n position: { value: voxelCoordinates },\n dimensionWidgetList,\n } = this;\n const rank = dimensionWidgetList.length;\n if (voxelCoordinates === undefined) {\n return;\n }\n const coordinateSpace = this.coordinateSpace!;\n const { velocity } = this;\n for (let i = 0; i < rank; ++i) {\n const widget = dimensionWidgetList[i];\n const inputElement = widget.coordinate;\n const newCoord = Math.floor(voxelCoordinates[i]);\n const newValue = newCoord.toString();\n updateCoordinateFieldWidth(widget, newValue);\n inputElement.value = newValue;\n const coordinateArray = getCoordinateArray(coordinateSpace, i);\n let label = \"\";\n if (coordinateArray != null) {\n const { coordinates } = coordinateArray;\n const index = binarySearch(coordinates, newCoord, (a, b) => a - b);\n if (index !== coordinates.length) {\n label = coordinateArray.labels[index];\n }\n }\n const labelElement = widget.coordinateLabel;\n labelElement.textContent = label;\n if (this.showPlayback) {\n const velocityInfo = velocity?.value?.[i];\n if (velocityInfo !== undefined) {\n const paused = velocityInfo.paused;\n widget.playButton.style.display = paused ? \"\" : \"none\";\n widget.pauseButton.style.display = !paused ? \"\" : \"none\";\n } else {\n widget.playButton.style.display = \"none\";\n widget.pauseButton.style.display = \"none\";\n }\n }\n }\n }\n\n disposed() {\n this.closeDropdown();\n removeFromParent(this.element);\n super.disposed();\n }\n}\n\nexport class MousePositionWidget extends RefCounted {\n tempPosition = vec3.create();\n constructor(\n public element: HTMLElement,\n public mouseState: MouseSelectionState,\n public coordinateSpace: WatchableValueInterface<\n CoordinateSpace | undefined\n >,\n ) {\n super();\n element.className = \"neuroglancer-mouse-position-widget\";\n const updateViewFunction = this.registerCancellable(\n animationFrameDebounce(() => this.updateView()),\n );\n this.registerDisposer(mouseState.changed.add(updateViewFunction));\n this.registerDisposer(coordinateSpace.changed.add(updateViewFunction));\n }\n updateView() {\n let text = \"\";\n const {\n mouseState,\n coordinateSpace: { value: coordinateSpace },\n } = this;\n if (mouseState.active && coordinateSpace !== undefined) {\n const p = mouseState.position;\n const { rank, names } = coordinateSpace;\n for (let i = 0; i < rank; ++i) {\n if (i !== 0) text += \" \";\n text += `${names[i]} ${Math.floor(p[i])}`;\n }\n }\n this.element.textContent = text;\n }\n disposed() {\n removeFromParent(this.element);\n super.disposed();\n }\n}\n\nconst DIMENSION_TOOL_ID = \"dimension\";\n\ninterface SupportsDimensionTool {\n position: Position;\n velocity: CoordinateSpacePlaybackVelocity;\n coordinateSpaceCombiner: CoordinateSpaceCombiner;\n toolBinder: LocalToolBinder;\n}\n\nconst TOOL_INPUT_EVENT_MAP = EventActionMap.fromObject({\n \"at:shift?+wheel\": { action: \"adjust-position-via-wheel\" },\n \"at:shift?+alt+wheel\": { action: \"adjust-velocity-via-wheel\" },\n \"shift?+alt?+space\": { action: \"toggle-playback\" },\n \"at:shift?+alt?+mousedown0\": { action: \"toggle-playback\" },\n});\n\nclass DimensionTool extends Tool {\n get position() {\n return this.viewer.position;\n }\n get velocity() {\n return this.viewer.velocity;\n }\n get coordinateSpace() {\n return this.viewer.coordinateSpaceCombiner.combined;\n }\n\n activate(activation: ToolActivation) {\n const { viewer } = this;\n const { content } = makeToolActivationStatusMessage(activation);\n content.classList.add(\"neuroglancer-position-tool\");\n activation.bindInputEventMap(TOOL_INPUT_EVENT_MAP);\n const positionWidget = new PositionWidget(\n viewer.position,\n viewer.coordinateSpaceCombiner,\n {\n velocity: viewer.velocity,\n singleDimensionId: this.dimensionId,\n copyButton: false,\n allowFocus: false,\n showPlayback: false,\n },\n );\n positionWidget.element.style.userSelect = \"none\";\n content.appendChild(activation.registerDisposer(positionWidget).element);\n const plot = activation.registerDisposer(\n new PositionPlot(viewer.position, this.dimensionId, \"row\"),\n );\n plot.element.style.flex = \"1\";\n content.appendChild(plot.element);\n activation.bindAction(\n \"adjust-position-via-wheel\",\n (actionEvent) => {\n actionEvent.stopPropagation();\n const event = actionEvent.detail;\n const { deltaY } = event;\n if (deltaY === 0) {\n return;\n }\n positionWidget.adjustDimensionPosition(\n this.dimensionId,\n Math.sign(deltaY),\n );\n },\n );\n\n const watchableVelocity = this.velocity.dimensionVelocity(\n activation,\n this.dimensionId,\n );\n const enabled = activation.registerDisposer(\n makeCachedDerivedWatchableValue(\n (value) => value !== undefined,\n [watchableVelocity],\n ),\n );\n content.appendChild(\n activation.registerDisposer(\n new DependentViewWidget(enabled, (enabledValue, parent, context) => {\n if (!enabledValue) return;\n parent.classList.add(\"neuroglancer-position-dimension-playback\");\n const playButton = document.createElement(\"div\");\n const pauseButton = document.createElement(\"div\");\n playButton.classList.add(\"neuroglancer-icon\");\n pauseButton.classList.add(\"neuroglancer-icon\");\n playButton.innerHTML = svg_play;\n pauseButton.innerHTML = svg_pause;\n parent.appendChild(playButton);\n parent.appendChild(pauseButton);\n const togglePlayback = () =>\n viewer.velocity.togglePlayback(this.dimensionId);\n playButton.addEventListener(\"click\", togglePlayback);\n pauseButton.addEventListener(\"click\", togglePlayback);\n const updatePlayPause = () => {\n const paused = watchableVelocity.value?.paused;\n playButton.style.display = paused ? \"\" : \"none\";\n pauseButton.style.display = !paused ? \"\" : \"none\";\n };\n context.registerDisposer(\n watchableVelocity.changed.add(updatePlayPause),\n );\n updatePlayPause();\n const velocityModel = new WatchableValue(0);\n velocityModel.changed.add(() => {\n const newValue = velocityModel.value;\n const velocity = watchableVelocity.value;\n if (velocity === undefined) return;\n if (velocity.velocity === newValue) return;\n watchableVelocity.value = { ...velocity, velocity: newValue };\n });\n const negateButton = makeIcon({\n text: \"±\",\n title: \"Negate velocity\",\n onClick: () => {\n velocityModel.value = -velocityModel.value;\n },\n });\n const velocityInputWidget = context.registerDisposer(\n new NumberInputWidget(velocityModel),\n );\n velocityInputWidget.inputElement.disabled = true;\n velocityInputWidget.element.insertBefore(\n negateButton,\n velocityInputWidget.element.firstChild,\n );\n velocityInputWidget.element.title =\n \"Velocity in coordinates per second\";\n const rateSpan = document.createElement(\"span\");\n rateSpan.textContent = \"/s\";\n velocityInputWidget.element.appendChild(rateSpan);\n parent.appendChild(velocityInputWidget.element);\n const trackableEnum = new TrackableEnum(\n VelocityBoundaryBehavior,\n VelocityBoundaryBehavior.STOP,\n );\n const watchableVelocityChanged = () => {\n trackableEnum.value =\n watchableVelocity.value?.atBoundary ??\n VelocityBoundaryBehavior.STOP;\n velocityModel.value = watchableVelocity.value?.velocity ?? 0;\n };\n watchableVelocityChanged();\n context.registerDisposer(\n watchableVelocity.changed.add(watchableVelocityChanged),\n );\n trackableEnum.changed.add(() => {\n const atBoundary = trackableEnum.value;\n const velocity = watchableVelocity.value;\n if (velocity === undefined) return;\n if (velocity.atBoundary === atBoundary) return;\n watchableVelocity.value = { ...velocity, atBoundary };\n });\n const selectWidget = new EnumSelectWidget(trackableEnum).element;\n parent.appendChild(selectWidget);\n selectWidget.title = \"Behavior when lower/upper bound is reached\";\n }),\n ).element,\n );\n content.appendChild(\n activation.registerDisposer(\n new CheckboxIcon(viewer.velocity.playbackEnabled(this.dimensionId), {\n svg: svg_video,\n enableTitle: \"Enable playback/velocity\",\n disableTitle: \"Disable playback/velocity\",\n backgroundScheme: \"dark\",\n }),\n ).element,\n );\n\n activation.bindAction(\n \"adjust-velocity-via-wheel\",\n (actionEvent) => {\n actionEvent.stopPropagation();\n const factor = getWheelZoomAmount(actionEvent.detail);\n viewer.velocity.multiplyVelocity(this.dimensionId, factor);\n },\n );\n activation.bindAction(\"toggle-playback\", (event) => {\n event.stopPropagation();\n viewer.velocity.togglePlayback(this.dimensionId);\n });\n }\n\n get description() {\n return `dim ${this.dimensionName}`;\n }\n\n dimensionIndex: number;\n dimensionName: string;\n\n constructor(\n public viewer: SupportsDimensionTool,\n public dimensionId: DimensionId,\n ) {\n super(viewer.toolBinder);\n const coordinateSpace = this.coordinateSpace.value;\n const i = (this.dimensionIndex = coordinateSpace.ids.indexOf(dimensionId));\n this.dimensionName = coordinateSpace.names[i];\n this.registerDisposer(\n this.coordinateSpace.changed.add(() => {\n const coordinateSpace = this.coordinateSpace.value;\n const i = (this.dimensionIndex =\n this.coordinateSpace.value.ids.indexOf(dimensionId));\n if (i === -1) {\n this.unbind();\n return;\n }\n const newName = coordinateSpace.names[i];\n if (this.dimensionName !== newName) {\n this.dimensionName = newName;\n this.changed.dispatch();\n }\n }),\n );\n }\n\n toJSON() {\n return {\n type: DIMENSION_TOOL_ID,\n dimension: this.dimensionName,\n };\n }\n}\n\nfunction makeDimensionTool(viewer: SupportsDimensionTool, obj: unknown) {\n const dimension = verifyObjectProperty(obj, \"dimension\", verifyString);\n const coordinateSpace = viewer.coordinateSpaceCombiner.combined.value;\n const dimensionIndex = coordinateSpace.names.indexOf(dimension);\n if (dimensionIndex === -1) {\n throw new Error(`Invalid dimension name: ${JSON.stringify(dimension)}`);\n }\n return new DimensionTool(viewer, coordinateSpace.ids[dimensionIndex]);\n}\n\nexport function registerDimensionToolForViewer(contextType: typeof Viewer) {\n registerTool(contextType, DIMENSION_TOOL_ID, (viewer, obj) =>\n makeDimensionTool(\n {\n position: viewer.position,\n velocity: viewer.velocity,\n coordinateSpaceCombiner:\n viewer.layerSpecification.coordinateSpaceCombiner,\n toolBinder: viewer.toolBinder,\n },\n obj,\n ),\n );\n}\n\nexport function registerDimensionToolForUserLayer(\n contextType: typeof UserLayer,\n) {\n registerTool(contextType, DIMENSION_TOOL_ID, (layer, obj) =>\n makeDimensionTool(\n {\n position: layer.localPosition,\n velocity: layer.localVelocity,\n coordinateSpaceCombiner: layer.localCoordinateSpaceCombiner,\n toolBinder: layer.toolBinder,\n },\n obj,\n ),\n );\n}\n\nexport function registerDimensionToolForLayerGroupViewer(\n contextType: typeof LayerGroupViewer,\n) {\n registerTool(contextType, DIMENSION_TOOL_ID, (layerGroupViewer, obj) =>\n makeDimensionTool(\n {\n position: layerGroupViewer.viewerNavigationState.position.value,\n velocity: layerGroupViewer.viewerNavigationState.velocity.velocity,\n coordinateSpaceCombiner:\n layerGroupViewer.layerSpecification.root.coordinateSpaceCombiner,\n toolBinder: layerGroupViewer.toolBinder,\n },\n obj,\n ),\n );\n}\n","/**\n * @license\n * Copyright 2024 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport \"#src/widget/transfer_function.css\";\n\nimport type { CoordinateSpaceCombiner } from \"#src/coordinate_transform.js\";\nimport type { DisplayContext } from \"#src/display_context.js\";\nimport { IndirectRenderedPanel } from \"#src/display_context.js\";\nimport type { UserLayer } from \"#src/layer/index.js\";\nimport { Position } from \"#src/navigation_state.js\";\nimport type { WatchableValueInterface } from \"#src/trackable_value.js\";\nimport { makeCachedDerivedWatchableValue } from \"#src/trackable_value.js\";\nimport type { ToolActivation } from \"#src/ui/tool.js\";\nimport {\n arraysEqual,\n arraysEqualWithPredicate,\n findClosestMatchInSortedArray,\n} from \"#src/util/array.js\";\nimport { DATA_TYPE_SIGNED, DataType } from \"#src/util/data_type.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport {\n EventActionMap,\n registerActionListener,\n} from \"#src/util/event_action_map.js\";\nimport { kZeroVec4, vec3, vec4 } from \"#src/util/geom.js\";\nimport type { DataTypeInterval } from \"#src/util/lerp.js\";\nimport {\n computeInvlerp,\n computeLerp,\n defaultDataTypeRange,\n getIntervalBoundsEffectiveFraction,\n parseDataTypeValue,\n} from \"#src/util/lerp.js\";\nimport { MouseEventBinder } from \"#src/util/mouse_bindings.js\";\nimport { startRelativeMouseDrag } from \"#src/util/mouse_drag.js\";\nimport type { Uint64 } from \"#src/util/uint64.js\";\nimport { getWheelZoomAmount } from \"#src/util/wheel_zoom.js\";\nimport type { WatchableVisibilityPriority } from \"#src/visibility_priority/frontend.js\";\nimport type { Buffer } from \"#src/webgl/buffer.js\";\nimport { getMemoizedBuffer } from \"#src/webgl/buffer.js\";\nimport type { GL } from \"#src/webgl/context.js\";\nimport type { HistogramSpecifications } from \"#src/webgl/empirical_cdf.js\";\nimport {\n defineInvlerpShaderFunction,\n enableLerpShaderFunction,\n} from \"#src/webgl/lerp.js\";\nimport {\n defineLineShader,\n drawLines,\n initializeLineShader,\n VERTICES_PER_LINE,\n} from \"#src/webgl/lines.js\";\nimport { drawQuads } from \"#src/webgl/quad.js\";\nimport { createGriddedRectangleArray } from \"#src/webgl/rectangle_grid_buffer.js\";\nimport type { ShaderCodePart, ShaderProgram } from \"#src/webgl/shader.js\";\nimport { ShaderBuilder } from \"#src/webgl/shader.js\";\nimport { getShaderType } from \"#src/webgl/shader_lib.js\";\nimport { setRawTextureParameters } from \"#src/webgl/texture.js\";\nimport { ColorWidget } from \"#src/widget/color.js\";\nimport {\n getUpdatedRangeAndWindowParameters,\n updateInputBoundValue,\n updateInputBoundWidth,\n createCDFLineShader,\n NUM_CDF_LINES,\n} from \"#src/widget/invlerp.js\";\nimport type {\n LayerControlFactory,\n LayerControlTool,\n} from \"#src/widget/layer_control.js\";\nimport { PositionWidget } from \"#src/widget/position_widget.js\";\nimport { Tab } from \"#src/widget/tab_view.js\";\n\nconst TRANSFER_FUNCTION_PANEL_SIZE = 512;\nexport const NUM_COLOR_CHANNELS = 4;\nconst POSITION_VALUES_PER_LINE = 4; // x1, y1, x2, y2\nconst CONTROL_POINT_X_GRAB_DISTANCE = 0.05;\nconst TRANSFER_FUNCTION_BORDER_WIDTH = 0.05;\n\nconst transferFunctionSamplerTextureUnit = Symbol(\n \"transferFunctionSamplerTexture\",\n);\nconst histogramSamplerTextureUnit = Symbol(\"histogramSamplerTexture\");\n\nconst defaultTransferFunctionSizes: Record = {\n [DataType.UINT8]: 256,\n [DataType.INT8]: 256,\n [DataType.UINT16]: 8192,\n [DataType.INT16]: 8192,\n [DataType.UINT32]: 8192,\n [DataType.INT32]: 8192,\n [DataType.UINT64]: 8192,\n [DataType.FLOAT32]: 8192,\n};\n\n/**\n * Options to update a lookup table texture with a direct lookup table\n */\nexport interface LookupTableTextureOptions {\n /** A lookup table is a series of color values (0 - 255) for each index in the transfer function texture\n */\n lookupTable: LookupTable;\n /** textureUnit to update with the new transfer function texture data */\n textureUnit: number | undefined;\n}\n\n/**\n * Options to update a transfer function texture using control points\n */\nexport interface ControlPointTextureOptions {\n /** controlPoints will be used to generate a lookup table as a first step */\n sortedControlPoints: SortedControlPoints;\n /** textureUnit to update with the new transfer function texture data */\n textureUnit: number | undefined;\n /** Data type of the control points */\n dataType: DataType;\n /** Lookup table number of elements*/\n lookupTableSize: number;\n}\n\nexport interface TransferFunctionParameters {\n sortedControlPoints: SortedControlPoints;\n window: DataTypeInterval;\n channel: number[];\n defaultColor: vec3;\n}\n\ninterface CanvasPosition {\n normalizedX: number;\n normalizedY: number;\n}\n\n/**\n * Transfer functions are controlled via a set of control points\n * with an input value and an output RGBA color (Uint8).\n * These control points are interpolated between to form a lookup table\n * which maps an input data value to an RGBA color.\n * Such a lookup table is used to form a texture, which can be sampled\n * from during rendering.\n */\nexport class ControlPoint {\n constructor(\n public inputValue: number | Uint64,\n public outputColor: vec4 = kZeroVec4,\n ) {}\n\n /** Convert the input value to a normalized value between 0 and 1 */\n normalizedInput(range: DataTypeInterval): number {\n return computeInvlerp(range, this.inputValue);\n }\n\n /** Convert the input value to an integer index into the transfer function lookup texture */\n transferFunctionIndex(\n dataRange: DataTypeInterval,\n transferFunctionSize: number,\n ): number {\n return Math.floor(\n this.normalizedInput(dataRange) * (transferFunctionSize - 1),\n );\n }\n interpolateColor(other: ControlPoint, t: number): vec4 {\n const outputColor = vec4.create();\n for (let i = 0; i < 4; ++i) {\n outputColor[i] = computeLerp(\n [this.outputColor[i], other.outputColor[i]],\n DataType.UINT8,\n t,\n ) as number;\n }\n return outputColor;\n }\n static copyFrom(other: ControlPoint) {\n const inputValue = other.inputValue;\n const outputColor = vec4.clone(other.outputColor);\n return new ControlPoint(inputValue, outputColor);\n }\n}\n\nexport class SortedControlPoints {\n public range: DataTypeInterval;\n constructor(\n public controlPoints: ControlPoint[] = [],\n public dataType: DataType,\n private autoComputeRange: boolean = true,\n ) {\n this.controlPoints = controlPoints;\n this.range = defaultDataTypeRange[dataType];\n this.sortAndComputeRange();\n }\n get length() {\n return this.controlPoints.length;\n }\n addPoint(controlPoint: ControlPoint) {\n const { inputValue, outputColor } = controlPoint;\n const exactMatch = this.controlPoints.findIndex(\n (point) => point.inputValue === inputValue,\n );\n if (exactMatch !== -1) {\n this.updatePointColor(exactMatch, outputColor);\n }\n const newPoint = new ControlPoint(inputValue, outputColor);\n this.controlPoints.push(newPoint);\n this.sortAndComputeRange();\n }\n removePoint(index: number) {\n this.controlPoints.splice(index, 1);\n this.computeRange();\n }\n updatePoint(index: number, controlPoint: ControlPoint): number {\n this.controlPoints[index] = controlPoint;\n const value = controlPoint.inputValue;\n const outputValue = controlPoint.outputColor;\n this.sortAndComputeRange();\n // Return the index of the original point after sorting\n for (let i = 0; i < this.controlPoints.length; ++i) {\n if (\n this.controlPoints[i].inputValue === value &&\n arraysEqual(this.controlPoints[i].outputColor, outputValue)\n ) {\n return i;\n }\n }\n return -1;\n }\n updatePointColor(index: number, color: vec4 | vec3) {\n let outputColor = vec4.create();\n if (color.length === 3) {\n const opacity = this.controlPoints[index].outputColor[3];\n outputColor = vec4.fromValues(color[0], color[1], color[2], opacity);\n } else {\n outputColor = vec4.clone(color as vec4);\n }\n this.controlPoints[index].outputColor = outputColor;\n }\n findNearestControlPointIndex(inputValue: number | Uint64) {\n const controlPoint = new ControlPoint(inputValue);\n const valueToFind = controlPoint.normalizedInput(this.range);\n return this.findNearestControlPointIndexByNormalizedInput(valueToFind);\n }\n findNearestControlPointIndexByNormalizedInput(normalizedInput: number) {\n return findClosestMatchInSortedArray(\n this.controlPoints.map((point) => point.normalizedInput(this.range)),\n normalizedInput,\n (a, b) => a - b,\n );\n }\n private sortAndComputeRange() {\n this.controlPoints.sort(\n (a, b) => a.normalizedInput(this.range) - b.normalizedInput(this.range),\n );\n this.computeRange();\n }\n private computeRange() {\n if (this.autoComputeRange) {\n if (this.controlPoints.length == 0) {\n this.range = defaultDataTypeRange[this.dataType];\n } else if (this.controlPoints.length === 1) {\n let rangeEnd = defaultDataTypeRange[this.dataType][1];\n if (\n this.dataType === DataType.FLOAT32 &&\n rangeEnd <= this.controlPoints[0].inputValue\n ) {\n rangeEnd = (this.controlPoints[0].inputValue as number) + 1;\n }\n this.range = [\n this.controlPoints[0].inputValue,\n rangeEnd,\n ] as DataTypeInterval;\n } else {\n this.range = [\n this.controlPoints[0].inputValue,\n this.controlPoints[this.controlPoints.length - 1].inputValue,\n ] as DataTypeInterval;\n }\n }\n if (this.range[0] === this.range[1]) {\n this.range = defaultDataTypeRange[this.dataType];\n }\n }\n copy() {\n const copy = new SortedControlPoints(\n [],\n this.dataType,\n this.autoComputeRange,\n );\n copy.range = this.range;\n copy.controlPoints = this.controlPoints.map((point) =>\n ControlPoint.copyFrom(point),\n );\n return copy;\n }\n}\n\nexport class LookupTable {\n outputValues: Uint8Array;\n constructor(public lookupTableSize: number) {\n this.outputValues = new Uint8Array(\n lookupTableSize * NUM_COLOR_CHANNELS,\n ).fill(0);\n }\n\n resize(newSize: number) {\n this.lookupTableSize = newSize;\n this.outputValues = new Uint8Array(newSize * NUM_COLOR_CHANNELS).fill(0);\n }\n\n /**\n * Fill a lookup table with color values between control points via linear interpolation.\n * Everything before the first point is transparent,\n * everything after the last point has the color of the last point.\n *\n * @param controlPoints The control points to interpolate between\n * @param dataRange The range of the input data space\n */\n updateFromControlPoints(\n sortedControlPoints: SortedControlPoints,\n window: DataTypeInterval | undefined = undefined,\n ) {\n const range = window ? window : sortedControlPoints.range;\n const { controlPoints } = sortedControlPoints;\n const out = this.outputValues;\n const size = this.lookupTableSize;\n function addLookupValue(index: number, color: vec4) {\n out[index] = color[0];\n out[index + 1] = color[1];\n out[index + 2] = color[2];\n out[index + 3] = color[3];\n }\n /**\n * Convert the control point input value to an index in the transfer function lookup table\n */\n function toTransferFunctionSpace(controlPoint: ControlPoint) {\n return controlPoint.transferFunctionIndex(range, size);\n }\n\n // If no control points - return all transparent\n if (controlPoints.length === 0) {\n out.fill(0);\n return;\n }\n\n // If first control point not at 0 - fill in transparent values\n // up to the first point\n const firstInputValue = toTransferFunctionSpace(controlPoints[0]);\n if (firstInputValue > 0) {\n const transparent = vec4.fromValues(0, 0, 0, 0);\n for (let i = 0; i < firstInputValue; ++i) {\n const index = i * NUM_COLOR_CHANNELS;\n addLookupValue(index, transparent);\n }\n }\n\n // Interpolate between control points and fill to end with last color\n let controlPointIndex = 0;\n for (let i = firstInputValue; i < size; ++i) {\n const currentPoint = controlPoints[controlPointIndex];\n const lookupIndex = i * NUM_COLOR_CHANNELS;\n if (controlPointIndex === controlPoints.length - 1) {\n addLookupValue(lookupIndex, currentPoint.outputColor);\n } else {\n const nextPoint = controlPoints[controlPointIndex + 1];\n const currentPointIndex = toTransferFunctionSpace(currentPoint);\n const nextPointIndex = toTransferFunctionSpace(nextPoint);\n const t =\n (i - currentPointIndex) / (nextPointIndex - currentPointIndex);\n const lerpedColor = currentPoint.interpolateColor(nextPoint, t);\n addLookupValue(lookupIndex, lerpedColor);\n if (i >= nextPointIndex) {\n controlPointIndex++;\n }\n }\n }\n }\n static equal(a: LookupTable, b: LookupTable) {\n return arraysEqual(a.outputValues, b.outputValues);\n }\n copy() {\n const copy = new LookupTable(this.lookupTableSize);\n copy.outputValues.set(this.outputValues);\n return copy;\n }\n}\n\n/**\n * Handles a linked lookup table and control points for a transfer function.\n */\nexport class TransferFunction extends RefCounted {\n lookupTable: LookupTable;\n constructor(\n public dataType: DataType,\n public trackable: WatchableValueInterface,\n size: number = defaultTransferFunctionSizes[dataType],\n ) {\n super();\n this.lookupTable = new LookupTable(size);\n this.updateLookupTable();\n }\n get sortedControlPoints() {\n return this.trackable.value.sortedControlPoints;\n }\n get range() {\n return this.sortedControlPoints.range;\n }\n get size() {\n return this.lookupTable.lookupTableSize;\n }\n updateLookupTable(window: DataTypeInterval | undefined = undefined) {\n this.lookupTable.updateFromControlPoints(this.sortedControlPoints, window);\n }\n addPoint(controlPoint: ControlPoint) {\n this.sortedControlPoints.addPoint(controlPoint);\n }\n updatePoint(index: number, controlPoint: ControlPoint): number {\n return this.sortedControlPoints.updatePoint(index, controlPoint);\n }\n removePoint(index: number) {\n this.sortedControlPoints.removePoint(index);\n }\n updatePointColor(index: number, color: vec4 | vec3) {\n this.sortedControlPoints.updatePointColor(index, color);\n }\n findNearestControlPointIndex(\n normalizedInputValue: number,\n dataWindow: DataTypeInterval,\n ) {\n const absoluteValue = computeLerp(\n dataWindow,\n this.dataType,\n normalizedInputValue,\n );\n return this.sortedControlPoints.findNearestControlPointIndex(absoluteValue);\n }\n}\n\nabstract class BaseLookupTexture extends RefCounted {\n texture: WebGLTexture | null = null;\n protected width: number;\n protected height = 1;\n protected priorOptions:\n | LookupTableTextureOptions\n | ControlPointTextureOptions\n | undefined = undefined;\n constructor(public gl: GL | null) {\n super();\n }\n /**\n * Compare the existing options to the new options to determine if the texture needs to be updated\n */\n abstract optionsEqual(\n newOptions: LookupTableTextureOptions | ControlPointTextureOptions,\n ): boolean;\n abstract createLookupTable(\n options: LookupTableTextureOptions | ControlPointTextureOptions,\n ): LookupTable;\n abstract setOptions(\n options: LookupTableTextureOptions | ControlPointTextureOptions,\n ): void;\n updateAndActivate(\n options: LookupTableTextureOptions | ControlPointTextureOptions,\n ) {\n const { gl } = this;\n if (gl === null) return;\n let { texture } = this;\n\n function activateAndBindTexture(gl: GL, textureUnit: number | undefined) {\n if (textureUnit === undefined) {\n throw new Error(\n \"Texture unit must be defined for transfer function texture\",\n );\n }\n gl.activeTexture(WebGL2RenderingContext.TEXTURE0 + textureUnit);\n gl.bindTexture(WebGL2RenderingContext.TEXTURE_2D, texture);\n }\n // If the texture is already up to date, just bind and activate it\n if (texture !== null && this.optionsEqual(options)) {\n activateAndBindTexture(gl, options.textureUnit);\n return this.width * this.height;\n }\n // If the texture has not been created yet, create it\n if (texture === null) {\n texture = this.texture = gl.createTexture();\n }\n // Update the texture\n activateAndBindTexture(gl, options.textureUnit);\n setRawTextureParameters(gl);\n const lookupTable = this.createLookupTable(options);\n\n gl.texImage2D(\n WebGL2RenderingContext.TEXTURE_2D,\n 0,\n WebGL2RenderingContext.RGBA,\n this.width,\n this.height,\n 0,\n WebGL2RenderingContext.RGBA,\n WebGL2RenderingContext.UNSIGNED_BYTE,\n lookupTable.outputValues,\n );\n\n // Update the prior options to the current options for future comparisons\n this.setOptions(options);\n return this.width * this.height;\n }\n setTextureWidthAndHeightFromSize(size: number) {\n this.width = size;\n }\n disposed() {\n this.gl?.deleteTexture(this.texture);\n this.texture = null;\n this.priorOptions = undefined;\n super.disposed();\n }\n}\n\n/**\n * Represent the underlying transfer function lookup table as a texture\n */\nclass DirectLookupTableTexture extends BaseLookupTexture {\n texture: WebGLTexture | null = null;\n protected priorOptions: LookupTableTextureOptions | undefined = undefined;\n\n constructor(public gl: GL | null) {\n super(gl);\n }\n optionsEqual(newOptions: LookupTableTextureOptions) {\n const existingOptions = this.priorOptions;\n if (existingOptions === undefined) return false;\n const lookupTableEqual = LookupTable.equal(\n existingOptions.lookupTable,\n newOptions.lookupTable,\n );\n const textureUnitEqual =\n existingOptions.textureUnit === newOptions.textureUnit;\n return lookupTableEqual && textureUnitEqual;\n }\n createLookupTable(options: LookupTableTextureOptions): LookupTable {\n this.setTextureWidthAndHeightFromSize(options.lookupTable.lookupTableSize);\n return options.lookupTable;\n }\n setOptions(options: LookupTableTextureOptions) {\n this.priorOptions = {\n ...options,\n lookupTable: options.lookupTable.copy(),\n };\n }\n}\n\nexport class ControlPointTexture extends BaseLookupTexture {\n protected priorOptions: ControlPointTextureOptions | undefined;\n constructor(public gl: GL | null) {\n super(gl);\n }\n optionsEqual(newOptions: ControlPointTextureOptions): boolean {\n const existingOptions = this.priorOptions;\n if (existingOptions === undefined) return false;\n const controlPointsEqual = arraysEqualWithPredicate(\n existingOptions.sortedControlPoints.controlPoints,\n newOptions.sortedControlPoints.controlPoints,\n (a, b) =>\n a.inputValue === b.inputValue &&\n arraysEqual(a.outputColor, b.outputColor),\n );\n const textureUnitEqual =\n existingOptions.textureUnit === newOptions.textureUnit;\n const dataTypeEqual = existingOptions.dataType === newOptions.dataType;\n return controlPointsEqual && textureUnitEqual && dataTypeEqual;\n }\n setOptions(options: ControlPointTextureOptions) {\n this.priorOptions = {\n ...options,\n sortedControlPoints: options.sortedControlPoints.copy(),\n };\n }\n createLookupTable(options: ControlPointTextureOptions): LookupTable {\n const lookupTableSize = this.ensureTextureSize(options.lookupTableSize);\n if (lookupTableSize === undefined) return new LookupTable(0);\n this.setTextureWidthAndHeightFromSize(lookupTableSize);\n const lookupTable = new LookupTable(lookupTableSize);\n const sortedControlPoints = options.sortedControlPoints;\n lookupTable.updateFromControlPoints(sortedControlPoints);\n return lookupTable;\n }\n ensureTextureSize(size: number) {\n const gl = this.gl;\n if (gl === null) return;\n const maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);\n const tableTextureSize = Math.min(size, maxTextureSize);\n return tableTextureSize;\n }\n}\n\n/**\n * Display the UI canvas for the transfer function widget and\n * handle shader updates for elements of the canvas\n */\nclass TransferFunctionPanel extends IndirectRenderedPanel {\n texture: DirectLookupTableTexture;\n private textureVertexBuffer: Buffer;\n private textureVertexBufferArray: Float32Array;\n private controlPointsVertexBuffer: Buffer;\n private controlPointsPositionArray = new Float32Array();\n private controlPointsColorBuffer: Buffer;\n private controlPointsColorArray = new Float32Array();\n private linePositionBuffer: Buffer;\n private linePositionArray = new Float32Array();\n get drawOrder() {\n return 1;\n }\n transferFunction = this.registerDisposer(\n new TransferFunction(\n this.parent.dataType,\n this.parent.trackable,\n TRANSFER_FUNCTION_PANEL_SIZE,\n ),\n );\n controller = this.registerDisposer(\n new TransferFunctionController(\n this.element,\n this.parent.dataType,\n this.transferFunction,\n () => this.parent.trackable.value,\n (value: TransferFunctionParameters) => {\n this.parent.trackable.value = value;\n },\n ),\n );\n private dataValuesBuffer = this.registerDisposer(\n getMemoizedBuffer(this.gl, WebGL2RenderingContext.ARRAY_BUFFER, () => {\n const array = new Uint8Array(NUM_CDF_LINES * VERTICES_PER_LINE);\n for (let i = 0; i < NUM_CDF_LINES; ++i) {\n for (let j = 0; j < VERTICES_PER_LINE; ++j) {\n array[i * VERTICES_PER_LINE + j] = i;\n }\n }\n return array;\n }),\n ).value;\n\n constructor(public parent: TransferFunctionWidget) {\n super(parent.display, document.createElement(\"div\"), parent.visibility);\n const { element, gl } = this;\n element.classList.add(\"neuroglancer-transfer-function-panel\");\n this.textureVertexBufferArray = createGriddedRectangleArray(\n TRANSFER_FUNCTION_PANEL_SIZE,\n );\n this.texture = this.registerDisposer(new DirectLookupTableTexture(gl));\n\n function createBuffer(dataArray: Float32Array) {\n return getMemoizedBuffer(\n gl,\n WebGL2RenderingContext.ARRAY_BUFFER,\n () => dataArray,\n ).value;\n }\n this.textureVertexBuffer = this.registerDisposer(\n createBuffer(this.textureVertexBufferArray),\n );\n this.controlPointsVertexBuffer = this.registerDisposer(\n createBuffer(this.controlPointsPositionArray),\n );\n this.controlPointsColorBuffer = this.registerDisposer(\n createBuffer(this.controlPointsColorArray),\n );\n this.linePositionBuffer = this.registerDisposer(\n createBuffer(this.linePositionArray),\n );\n }\n\n updateTransferFunctionPointsAndLines() {\n // Normalize position to [-1, 1] for shader (x axis)\n const window = this.parent.trackable.value.window;\n function normalizeInput(input: number | Uint64) {\n const lerpedInput = computeInvlerp(window, input);\n return lerpedInput * 2 - 1;\n }\n // Normalize opacity to [-1, 1] for shader (y axis)\n function normalizeOpacity(opacity: number) {\n return (opacity / 255) * 2 - 1;\n }\n // Normalize color to [0, 1] for shader (color channels)\n function normalizeColor(colorComponent: number) {\n return colorComponent / 255;\n }\n function addLine(\n array: Float32Array,\n index: number,\n positions: vec4,\n ): number {\n for (let i = 0; i < VERTICES_PER_LINE; ++i) {\n array[index++] = positions[0];\n array[index++] = positions[1];\n array[index++] = positions[2];\n array[index++] = positions[3];\n }\n return index;\n }\n function isInWindow(normalizedInput: number) {\n return normalizedInput >= -1 && normalizedInput <= 1;\n }\n\n const { transferFunction } = this;\n const { controlPoints } =\n transferFunction.trackable.value.sortedControlPoints;\n let numLines = Math.max(controlPoints.length - 1, 0);\n const colorChannels = NUM_COLOR_CHANNELS - 1; // ignore alpha\n const colorArray = new Float32Array(controlPoints.length * colorChannels);\n const positionArray = new Float32Array(controlPoints.length * 2);\n let linePositionArrayIndex = 0;\n let lineFromLeftEdge = null;\n let lineToRightEdge = null;\n // Map all control points to normalized values for the shader\n const normalizedControlPoints = controlPoints.map((point) => {\n const input = normalizeInput(point.inputValue);\n const output = normalizeOpacity(point.outputColor[3]);\n return { input, output };\n });\n\n // Create start and end lines if there are any control points\n if (controlPoints.length > 0) {\n // Try to find the first and last point in the window\n\n const {\n firstPointIndexInWindow,\n lastPointIndexInWindow,\n pointClosestToLeftEdge,\n pointClosestToRightEdge,\n } = findPointsNearWindowBounds();\n // If there are no points in the window, check if everything is left or right of the window\n // Draw a single line from the left edge to the right edge if all points are left of the window\n if (firstPointIndexInWindow === null) {\n const allPointsLeftOfWindow =\n normalizedControlPoints[controlPoints.length - 1].input < -1;\n const allPointsRightOfWindow = normalizedControlPoints[0].input > 1;\n if (allPointsLeftOfWindow) {\n drawHorizontalLineFromPointOutsideLeftWindow();\n }\n // There are no points in the window, but points on either side\n // Draw lines from the leftmost and rightmost points starting\n // from the left edge and ending at the right edge via interpolation\n else if (!allPointsRightOfWindow && controlPoints.length > 1) {\n drawLineBetweenPointsBothOutsideWindow(\n pointClosestToLeftEdge,\n pointClosestToRightEdge,\n );\n }\n } else {\n const firstPointInWindow =\n normalizedControlPoints[firstPointIndexInWindow];\n if (firstPointInWindow.input > -1) {\n // If there is a value to the left, draw a line from the point outside the window to the first point in the window\n if (firstPointIndexInWindow > 0) {\n drawLineBetweenPointInWindowAndLeftPointOutsideWindow(\n firstPointIndexInWindow,\n firstPointInWindow,\n );\n }\n // If the first point in the window is the leftmost point, draw a 0 line up to the point\n else {\n lineFromLeftEdge = vec4.fromValues(\n firstPointInWindow.input,\n -1,\n firstPointInWindow.input,\n firstPointInWindow.output,\n );\n }\n numLines += 1;\n }\n // Need to draw a line from the last control point in the window to the right edge\n const lastPointInWindow =\n normalizedControlPoints[lastPointIndexInWindow!];\n if (lastPointInWindow.input < 1) {\n // If there is a value to the right, draw a line from the last point in the window to the point outside the window\n if (lastPointIndexInWindow! < controlPoints.length - 1) {\n drawLineBetweenPointInWindowAndRightPointOutsideWindow(\n lastPointIndexInWindow,\n lastPointInWindow,\n );\n }\n // If the last point in the window is the rightmost point, draw a line from the point to the right edge\n else {\n lineToRightEdge = vec4.fromValues(\n lastPointInWindow.input,\n lastPointInWindow.output,\n 1,\n lastPointInWindow.output,\n );\n }\n numLines += 1;\n }\n }\n }\n\n const lines: vec4[] = [];\n // Update points and draw lines between control points\n for (let i = 0; i < controlPoints.length; ++i) {\n const colorIndex = i * colorChannels;\n const positionIndex = i * 2;\n const inputValue = normalizedControlPoints[i].input;\n const outputValue = normalizedControlPoints[i].output;\n const { outputColor } = controlPoints[i];\n colorArray[colorIndex] = normalizeColor(outputColor[0]);\n colorArray[colorIndex + 1] = normalizeColor(outputColor[1]);\n colorArray[colorIndex + 2] = normalizeColor(outputColor[2]);\n positionArray[positionIndex] = inputValue;\n positionArray[positionIndex + 1] = outputValue;\n\n // Don't create a line for the last point\n if (i === controlPoints.length - 1) break;\n if (!(isInWindow(inputValue) && isInWindow(outputValue))) continue;\n numLines += 1;\n const lineBetweenPoints = vec4.fromValues(\n inputValue,\n outputValue,\n normalizedControlPoints[i + 1].input,\n normalizedControlPoints[i + 1].output,\n );\n lines.push(lineBetweenPoints);\n }\n\n // Create and fill the line position array\n const linePositionArray = new Float32Array(\n numLines * POSITION_VALUES_PER_LINE * VERTICES_PER_LINE,\n );\n\n if (lineFromLeftEdge !== null) {\n linePositionArrayIndex = addLine(\n linePositionArray,\n linePositionArrayIndex,\n lineFromLeftEdge,\n );\n }\n\n for (const lineBetweenPoints of lines) {\n linePositionArrayIndex = addLine(\n linePositionArray,\n linePositionArrayIndex,\n lineBetweenPoints,\n );\n }\n\n // Draw a horizontal line out from the last point\n if (lineToRightEdge !== null) {\n addLine(linePositionArray, linePositionArrayIndex, lineToRightEdge);\n }\n\n // Update buffers\n this.controlPointsColorArray = colorArray;\n this.controlPointsPositionArray = positionArray;\n this.linePositionArray = linePositionArray;\n this.controlPointsVertexBuffer.setData(this.controlPointsPositionArray);\n this.controlPointsColorBuffer.setData(this.controlPointsColorArray);\n this.linePositionBuffer.setData(this.linePositionArray);\n\n function drawLineBetweenPointInWindowAndRightPointOutsideWindow(\n lastPointIndexInWindow: number | null,\n lastPointInWindow: { input: number; output: number },\n ) {\n const pointAfterWindow =\n normalizedControlPoints[lastPointIndexInWindow! + 1];\n const interpFactor = computeInvlerp(\n [lastPointInWindow.input, pointAfterWindow.input],\n 1,\n );\n const lineEndY = computeLerp(\n [lastPointInWindow.output, pointAfterWindow.output],\n DataType.FLOAT32,\n interpFactor,\n ) as number;\n lineToRightEdge = vec4.fromValues(\n lastPointInWindow.input,\n lastPointInWindow.output,\n 1,\n lineEndY,\n );\n }\n\n function drawLineBetweenPointInWindowAndLeftPointOutsideWindow(\n firstPointIndexInWindow: number,\n firstPointInWindow: { input: number; output: number },\n ) {\n const pointBeforeWindow =\n normalizedControlPoints[firstPointIndexInWindow - 1];\n const interpFactor = computeInvlerp(\n [pointBeforeWindow.input, firstPointInWindow.input],\n -1,\n );\n const lineStartY = computeLerp(\n [pointBeforeWindow.output, firstPointInWindow.output],\n DataType.FLOAT32,\n interpFactor,\n ) as number;\n lineFromLeftEdge = vec4.fromValues(\n -1,\n lineStartY,\n firstPointInWindow.input,\n firstPointInWindow.output,\n );\n }\n\n function drawLineBetweenPointsBothOutsideWindow(\n pointClosestToLeftEdge: { input: number; output: number } | null,\n pointClosestToRightEdge: { input: number; output: number } | null,\n ) {\n numLines += 1;\n if (pointClosestToLeftEdge === null || pointClosestToRightEdge === null) {\n throw new Error(\n \"Could not find points closest to the left and right edges\",\n );\n }\n const leftInterpFactor = computeInvlerp(\n [pointClosestToLeftEdge.input, pointClosestToRightEdge.input],\n -1,\n );\n const rightInterpFactor = computeInvlerp(\n [pointClosestToLeftEdge.input, pointClosestToRightEdge.input],\n 1,\n );\n const leftLineY = computeLerp(\n [pointClosestToLeftEdge.output, pointClosestToRightEdge.output],\n DataType.FLOAT32,\n leftInterpFactor,\n ) as number;\n const rightLineY = computeLerp(\n [pointClosestToLeftEdge.output, pointClosestToRightEdge.output],\n DataType.FLOAT32,\n rightInterpFactor,\n ) as number;\n lineFromLeftEdge = vec4.fromValues(-1, leftLineY, 1, rightLineY);\n }\n\n function findPointsNearWindowBounds() {\n let firstPointIndexInWindow = null;\n let lastPointIndexInWindow = null;\n let pointClosestToLeftEdge = null;\n let pointClosestToRightEdge = null;\n for (let i = 0; i < controlPoints.length; ++i) {\n const point = normalizedControlPoints[i];\n if (isInWindow(point.input)) {\n firstPointIndexInWindow = firstPointIndexInWindow ?? i;\n lastPointIndexInWindow = i;\n }\n if (point.input < -1) {\n pointClosestToLeftEdge = point;\n } else if (point.input > 1) {\n pointClosestToRightEdge = point;\n break;\n }\n }\n return {\n firstPointIndexInWindow,\n lastPointIndexInWindow,\n pointClosestToLeftEdge,\n pointClosestToRightEdge,\n };\n }\n\n function drawHorizontalLineFromPointOutsideLeftWindow() {\n const indexOfReferencePoint = controlPoints.length - 1;\n numLines += 1;\n const referenceOpacity =\n normalizedControlPoints[indexOfReferencePoint].output;\n lineFromLeftEdge = vec4.fromValues(\n -1,\n referenceOpacity,\n 1,\n referenceOpacity,\n );\n }\n }\n\n private histogramLineShader = this.registerDisposer(\n (() => createCDFLineShader(this.gl, histogramSamplerTextureUnit))(),\n );\n\n private transferFunctionLineShader = this.registerDisposer(\n (() => {\n const builder = new ShaderBuilder(this.gl);\n defineLineShader(builder);\n builder.addAttribute(\"vec4\", \"aLineStartEnd\");\n builder.addOutputBuffer(\"vec4\", \"out_color\", 0);\n builder.addVarying(\"float\", \"vColor\");\n builder.setVertexMain(`\nvec4 start = vec4(aLineStartEnd[0], aLineStartEnd[1], 0.0, 1.0);\nvec4 end = vec4(aLineStartEnd[2], aLineStartEnd[3], 0.0, 1.0);\nemitLine(start, end, 1.0);\n`);\n builder.setFragmentMain(`\nout_color = vec4(0.35, 0.35, 0.35, getLineAlpha());\n`);\n return builder.build();\n })(),\n );\n\n private transferFunctionShader = this.registerDisposer(\n (() => {\n const builder = new ShaderBuilder(this.gl);\n builder.addAttribute(\"vec2\", \"aVertexPosition\");\n builder.addVarying(\"vec2\", \"vTexCoord\");\n builder.addOutputBuffer(\"vec4\", \"out_color\", 0);\n builder.addTextureSampler(\n \"sampler2D\",\n \"uSampler\",\n transferFunctionSamplerTextureUnit,\n );\n builder.addUniform(\"float\", \"uTransferFunctionEnd\");\n builder.setVertexMain(`\ngl_Position = vec4(aVertexPosition, 0.0, 1.0);\nvTexCoord = (aVertexPosition + 1.0) / 2.0;\n`);\n builder.setFragmentMain(`\nivec2 texel = ivec2(floor(vTexCoord.x * uTransferFunctionEnd), 0);\nout_color = texelFetch(uSampler, texel, 0);\n`);\n return builder.build();\n })(),\n );\n\n private controlPointsShader = this.registerDisposer(\n (() => {\n const builder = new ShaderBuilder(this.gl);\n builder.addAttribute(\"vec2\", \"aVertexPosition\");\n builder.addAttribute(\"vec3\", \"aVertexColor\");\n builder.addVarying(\"vec3\", \"vColor\");\n builder.addOutputBuffer(\"vec4\", \"out_color\", 0);\n builder.setVertexMain(`\ngl_Position = vec4(aVertexPosition, 0.0, 1.0);\ngl_PointSize = 14.0;\nvColor = aVertexColor;\n`);\n // Draw control points as circles with a border\n // The border is white if the color is dark, black if the color is light\n builder.setFragmentMain(`\nfloat vColorSum = vColor.r + vColor.g + vColor.b;\nvec3 bordercolor = vec3(0.0, 0.0, 0.0);\nif (vColorSum < 0.4) {\n bordercolor = vec3(1.0, 1.0, 1.0);\n}\nfloat dist = distance(gl_PointCoord, vec2(0.5, 0.5));\nfloat alpha = smoothstep(0.25, 0.4, dist);\nvec4 tempColor = vec4(mix(vColor, bordercolor, alpha), 1.0);\nalpha = 1.0 - smoothstep(0.4, 0.5, dist);\nout_color = tempColor * alpha;\n`);\n return builder.build();\n })(),\n );\n\n drawIndirect() {\n const {\n transferFunctionLineShader,\n gl,\n transferFunctionShader,\n controlPointsShader,\n histogramLineShader: lineShader,\n } = this;\n this.setGLLogicalViewport();\n gl.clearColor(0.0, 0.0, 0.0, 0.0);\n gl.clear(WebGL2RenderingContext.COLOR_BUFFER_BIT);\n gl.enable(WebGL2RenderingContext.BLEND);\n gl.blendFunc(\n WebGL2RenderingContext.SRC_ALPHA,\n WebGL2RenderingContext.ONE_MINUS_SRC_ALPHA,\n );\n gl.disable(WebGL2RenderingContext.DEPTH_TEST);\n gl.disable(WebGL2RenderingContext.STENCIL_TEST);\n {\n // Draw transfer function texture\n transferFunctionShader.bind();\n const aVertexPosition =\n transferFunctionShader.attribute(\"aVertexPosition\");\n gl.uniform1f(\n transferFunctionShader.uniform(\"uTransferFunctionEnd\"),\n TRANSFER_FUNCTION_PANEL_SIZE - 1,\n );\n this.textureVertexBuffer.bindToVertexAttrib(\n aVertexPosition,\n /*components=*/ 2,\n /*attributeType=*/ WebGL2RenderingContext.FLOAT,\n );\n const textureUnit = transferFunctionShader.textureUnit(\n transferFunctionSamplerTextureUnit,\n );\n this.texture.updateAndActivate({\n lookupTable: this.transferFunction.lookupTable,\n textureUnit,\n });\n drawQuads(this.gl, TRANSFER_FUNCTION_PANEL_SIZE, 1);\n gl.disableVertexAttribArray(aVertexPosition);\n gl.bindTexture(WebGL2RenderingContext.TEXTURE_2D, null);\n }\n // Draw CDF lines\n if (this.parent.histogramSpecifications.producerVisibility.visible) {\n const { renderViewport } = this;\n lineShader.bind();\n initializeLineShader(\n lineShader,\n {\n width: renderViewport.logicalWidth,\n height: renderViewport.logicalHeight,\n },\n /*featherWidthInPixels=*/ 1.0,\n );\n const histogramTextureUnit = lineShader.textureUnit(\n histogramSamplerTextureUnit,\n );\n gl.uniform1f(\n lineShader.uniform(\"uBoundsFraction\"),\n getIntervalBoundsEffectiveFraction(\n this.parent.dataType,\n this.parent.trackable.value.window,\n ),\n );\n gl.activeTexture(WebGL2RenderingContext.TEXTURE0 + histogramTextureUnit);\n gl.bindTexture(WebGL2RenderingContext.TEXTURE_2D, this.parent.texture);\n setRawTextureParameters(gl);\n const aDataValue = lineShader.attribute(\"aDataValue\");\n this.dataValuesBuffer.bindToVertexAttribI(\n aDataValue,\n /*componentsPerVertexAttribute=*/ 1,\n /*attributeType=*/ WebGL2RenderingContext.UNSIGNED_BYTE,\n );\n drawLines(gl, /*linesPerInstance=*/ NUM_CDF_LINES, /*numInstances=*/ 1);\n gl.disableVertexAttribArray(aDataValue);\n gl.bindTexture(WebGL2RenderingContext.TEXTURE_2D, null);\n }\n\n // Draw lines and control points on top of transfer function - if there are any\n if (this.controlPointsPositionArray.length > 0) {\n const { renderViewport } = this;\n\n // Draw transfer function lerp indicator lines\n transferFunctionLineShader.bind();\n const aLineStartEnd =\n transferFunctionLineShader.attribute(\"aLineStartEnd\");\n this.linePositionBuffer.bindToVertexAttrib(\n aLineStartEnd,\n /*components=*/ 4,\n /*attributeType=*/ WebGL2RenderingContext.FLOAT,\n );\n initializeLineShader(\n transferFunctionLineShader,\n {\n width: renderViewport.logicalWidth,\n height: renderViewport.logicalHeight,\n },\n /*featherWidthInPixels=*/ 1,\n );\n drawLines(\n gl,\n this.linePositionArray.length /\n (VERTICES_PER_LINE * POSITION_VALUES_PER_LINE),\n 1,\n );\n gl.disableVertexAttribArray(aLineStartEnd);\n\n // Draw control points of the transfer function\n controlPointsShader.bind();\n const aVertexPosition = controlPointsShader.attribute(\"aVertexPosition\");\n this.controlPointsVertexBuffer.bindToVertexAttrib(\n aVertexPosition,\n /*components=*/ 2,\n /*attributeType=*/ WebGL2RenderingContext.FLOAT,\n );\n const aVertexColor = controlPointsShader.attribute(\"aVertexColor\");\n this.controlPointsColorBuffer.bindToVertexAttrib(\n aVertexColor,\n /*components=*/ 3,\n /*attributeType=*/ WebGL2RenderingContext.FLOAT,\n );\n gl.drawArrays(gl.POINTS, 0, this.controlPointsPositionArray.length / 2);\n gl.disableVertexAttribArray(aVertexPosition);\n gl.disableVertexAttribArray(aVertexColor);\n }\n gl.disable(WebGL2RenderingContext.BLEND);\n }\n update() {\n this.transferFunction.updateLookupTable(this.parent.trackable.value.window);\n this.updateTransferFunctionPointsAndLines();\n }\n isReady() {\n return true;\n }\n}\n\n/**\n * Create the bounds on the UI window inputs for the transfer function widget\n */\nfunction createWindowBoundInputs(\n dataType: DataType,\n model: WatchableValueInterface,\n) {\n function createWindowBoundInput(endpoint: number): HTMLInputElement {\n const e = document.createElement(\"input\");\n e.addEventListener(\"focus\", () => {\n e.select();\n });\n e.classList.add(\"neuroglancer-transfer-function-widget-bound\");\n e.type = \"text\";\n e.spellcheck = false;\n e.autocomplete = \"off\";\n e.title = `${\n endpoint === 0 ? \"Lower\" : \"Upper\"\n } window for transfer function`;\n return e;\n }\n\n const container = document.createElement(\"div\");\n container.classList.add(\"neuroglancer-transfer-function-window-bounds\");\n const inputs = [createWindowBoundInput(0), createWindowBoundInput(1)];\n for (let endpointIndex = 0; endpointIndex < 2; ++endpointIndex) {\n const input = inputs[endpointIndex];\n input.addEventListener(\"input\", () => {\n updateInputBoundWidth(input);\n });\n input.addEventListener(\"change\", () => {\n const existingBounds = model.value.window;\n const intervals = { range: existingBounds, window: existingBounds };\n try {\n const value = parseDataTypeValue(dataType, input.value);\n const window = getUpdatedRangeAndWindowParameters(\n intervals,\n \"window\",\n endpointIndex,\n value,\n /*fitRangeInWindow=*/ true,\n ).window;\n if (window[0] === window[1]) {\n throw new Error(\"Window bounds cannot be equal\");\n }\n model.value = { ...model.value, window };\n } catch {\n updateInputBoundValue(input, existingBounds[endpointIndex]);\n }\n });\n }\n container.appendChild(inputs[0]);\n container.appendChild(inputs[1]);\n return {\n container,\n inputs,\n };\n}\n\nconst inputEventMap = EventActionMap.fromObject({\n \"shift?+mousedown0\": { action: \"add-or-drag-point\" },\n \"shift+dblclick0\": { action: \"remove-point\" },\n \"shift?+mousedown2\": { action: \"change-point-color\" },\n \"shift?+wheel\": { action: \"zoom-via-wheel\" },\n});\n\n/**\n * Controller for the transfer function widget. Handles mouse events and updates to the model.\n */\nclass TransferFunctionController extends RefCounted {\n private currentGrabbedControlPointIndex = -1;\n constructor(\n public element: HTMLElement,\n public dataType: DataType,\n private transferFunction: TransferFunction,\n public getModel: () => TransferFunctionParameters,\n public setModel: (value: TransferFunctionParameters) => void,\n ) {\n super();\n element.title = inputEventMap.describe();\n this.registerDisposer(new MouseEventBinder(element, inputEventMap));\n registerActionListener(\n element,\n \"add-or-drag-point\",\n (actionEvent) => {\n const mouseEvent = actionEvent.detail;\n this.updateValue(this.addControlPoint(mouseEvent));\n startRelativeMouseDrag(mouseEvent, (newEvent: MouseEvent) => {\n this.updateValue(this.moveControlPoint(newEvent));\n });\n },\n );\n registerActionListener(\n element,\n \"remove-point\",\n (actionEvent) => {\n const mouseEvent = actionEvent.detail;\n const nearestIndex = this.findControlPointIfNearCursor(mouseEvent);\n if (nearestIndex !== -1) {\n this.transferFunction.removePoint(nearestIndex);\n this.updateValue({\n ...this.getModel(),\n sortedControlPoints:\n this.transferFunction.trackable.value.sortedControlPoints,\n });\n }\n },\n );\n registerActionListener(\n element,\n \"change-point-color\",\n (actionEvent) => {\n const mouseEvent = actionEvent.detail;\n const nearestIndex = this.findControlPointIfNearCursor(mouseEvent);\n if (nearestIndex !== -1) {\n const color = this.transferFunction.trackable.value.defaultColor;\n const colorInAbsoluteValue =\n this.convertPanelSpaceColorToAbsoluteValue(color);\n this.transferFunction.updatePointColor(\n nearestIndex,\n colorInAbsoluteValue,\n );\n this.updateValue({\n ...this.getModel(),\n sortedControlPoints:\n this.transferFunction.trackable.value.sortedControlPoints,\n });\n }\n },\n );\n registerActionListener(\n element,\n \"zoom-via-wheel\",\n (actionEvent) => {\n const wheelEvent = actionEvent.detail;\n const zoomAmount = getWheelZoomAmount(wheelEvent);\n const relativeX = this.getTargetFraction(wheelEvent);\n const { dataType } = this;\n const model = this.getModel();\n const newLower = computeLerp(\n model.window,\n dataType,\n relativeX * (1 - zoomAmount),\n );\n const newUpper = computeLerp(\n model.window,\n dataType,\n (1 - relativeX) * zoomAmount + relativeX,\n );\n if (newLower !== newUpper) {\n this.setModel({\n ...model,\n window: [newLower, newUpper] as DataTypeInterval,\n });\n }\n },\n );\n }\n /**\n * Get fraction of distance in x along bounding rect for a MouseEvent.\n */\n getTargetFraction(event: MouseEvent) {\n const clientRect = this.element.getBoundingClientRect();\n return (event.clientX - clientRect.left) / clientRect.width;\n }\n updateValue(value: TransferFunctionParameters | undefined) {\n if (value === undefined) return;\n this.setModel(value);\n }\n convertPanelSpaceInputToAbsoluteValue(inputValue: number) {\n return computeLerp(\n this.transferFunction.trackable.value.window,\n this.dataType,\n inputValue,\n );\n }\n convertPanelSpaceColorToAbsoluteValue(color: vec3 | vec4) {\n if (color.length === 3) {\n // If color is vec3\n return vec3.fromValues(\n Math.round(color[0] * 255),\n Math.round(color[1] * 255),\n Math.round(color[2] * 255),\n );\n } else {\n // If color is vec4\n return vec4.fromValues(\n Math.round(color[0] * 255),\n Math.round(color[1] * 255),\n Math.round(color[2] * 255),\n Math.round(color[3] * 255),\n );\n }\n }\n addControlPoint(event: MouseEvent): TransferFunctionParameters | undefined {\n const color = this.transferFunction.trackable.value.defaultColor;\n const nearestIndex = this.findControlPointIfNearCursor(event);\n if (nearestIndex !== -1) {\n this.currentGrabbedControlPointIndex = nearestIndex;\n return undefined;\n }\n const position = this.getControlPointPosition(event);\n if (position === undefined) return undefined;\n const { normalizedX, normalizedY } = position;\n const outputColor = vec4.fromValues(\n color[0],\n color[1],\n color[2],\n normalizedY,\n );\n this.transferFunction.addPoint(\n new ControlPoint(\n this.convertPanelSpaceInputToAbsoluteValue(normalizedX),\n this.convertPanelSpaceColorToAbsoluteValue(outputColor) as vec4,\n ),\n );\n this.currentGrabbedControlPointIndex =\n this.findControlPointIfNearCursor(event);\n return {\n ...this.getModel(),\n sortedControlPoints:\n this.transferFunction.trackable.value.sortedControlPoints,\n };\n }\n moveControlPoint(event: MouseEvent): TransferFunctionParameters | undefined {\n if (this.currentGrabbedControlPointIndex !== -1) {\n const position = this.getControlPointPosition(event);\n if (position === undefined) return undefined;\n const { normalizedX, normalizedY } = position;\n const newColor =\n this.transferFunction.trackable.value.sortedControlPoints.controlPoints[\n this.currentGrabbedControlPointIndex\n ].outputColor;\n newColor[3] = Math.round(normalizedY * 255);\n this.currentGrabbedControlPointIndex = this.transferFunction.updatePoint(\n this.currentGrabbedControlPointIndex,\n new ControlPoint(\n this.convertPanelSpaceInputToAbsoluteValue(normalizedX),\n newColor,\n ),\n );\n return {\n ...this.getModel(),\n sortedControlPoints:\n this.transferFunction.trackable.value.sortedControlPoints,\n };\n }\n return undefined;\n }\n getControlPointPosition(event: MouseEvent): CanvasPosition | undefined {\n const clientRect = this.element.getBoundingClientRect();\n let normalizedX = (event.clientX - clientRect.left) / clientRect.width;\n let normalizedY = (clientRect.bottom - event.clientY) / clientRect.height;\n if (\n normalizedX < 0 ||\n normalizedX > 1 ||\n normalizedY < 0 ||\n normalizedY > 1\n )\n return undefined;\n\n // Near the borders of the transfer function, snap the control point to the border\n if (normalizedX < TRANSFER_FUNCTION_BORDER_WIDTH / 3) {\n normalizedX = 0.0;\n } else if (normalizedX > 1 - TRANSFER_FUNCTION_BORDER_WIDTH / 3) {\n normalizedX = 1.0;\n }\n if (normalizedY < TRANSFER_FUNCTION_BORDER_WIDTH) {\n normalizedY = 0.0;\n } else if (normalizedY > 1 - TRANSFER_FUNCTION_BORDER_WIDTH) {\n normalizedY = 1.0;\n }\n\n return { normalizedX, normalizedY };\n }\n /**\n * Find the nearest control point to the cursor or -1 if no control point is near the cursor.\n * If multiple control points are near the cursor in X, the control point with the smallest\n * distance in the Y direction is returned.\n */\n findControlPointIfNearCursor(event: MouseEvent) {\n const { transferFunction } = this;\n const { window } = transferFunction.trackable.value;\n const numControlPoints =\n transferFunction.sortedControlPoints.controlPoints.length;\n function convertControlPointInputToPanelSpace(controlPointIndex: number) {\n if (controlPointIndex < 0 || controlPointIndex >= numControlPoints) {\n return null;\n }\n return computeInvlerp(\n window,\n transferFunction.sortedControlPoints.controlPoints[controlPointIndex]\n .inputValue,\n );\n }\n function convertControlPointOpacityToPanelSpace(controlPointIndex: number) {\n if (controlPointIndex < 0 || controlPointIndex >= numControlPoints) {\n return null;\n }\n return (\n transferFunction.sortedControlPoints.controlPoints[controlPointIndex]\n .outputColor[3] / 255\n );\n }\n const position = this.getControlPointPosition(event);\n if (position === undefined) return -1;\n const mouseXPosition = position.normalizedX;\n const mouseYPosition = position.normalizedY;\n const nearestControlPointIndex =\n transferFunction.findNearestControlPointIndex(mouseXPosition, window);\n if (nearestControlPointIndex === -1) {\n return -1;\n }\n const nearestControlPointPanelPosition =\n convertControlPointInputToPanelSpace(nearestControlPointIndex)!;\n if (\n Math.abs(mouseXPosition - nearestControlPointPanelPosition) >\n CONTROL_POINT_X_GRAB_DISTANCE\n ) {\n return -1;\n }\n // If points are nearby in X space, use Y space to break ties\n const possibleMatches: [number, number][] = [\n [\n nearestControlPointIndex,\n Math.abs(\n convertControlPointOpacityToPanelSpace(nearestControlPointIndex)! -\n mouseYPosition,\n ),\n ],\n ];\n const nextPosition = convertControlPointInputToPanelSpace(\n nearestControlPointIndex + 1,\n );\n const nextDistance =\n nextPosition !== null\n ? Math.abs(nextPosition - mouseXPosition)\n : Infinity;\n if (nextDistance <= CONTROL_POINT_X_GRAB_DISTANCE) {\n possibleMatches.push([\n nearestControlPointIndex + 1,\n Math.abs(\n convertControlPointOpacityToPanelSpace(\n nearestControlPointIndex + 1,\n )! - mouseYPosition,\n ),\n ]);\n }\n\n const previousPosition = convertControlPointInputToPanelSpace(\n nearestControlPointIndex - 1,\n );\n const previousDistance =\n previousPosition !== null\n ? Math.abs(previousPosition - mouseXPosition)\n : Infinity;\n if (previousDistance <= CONTROL_POINT_X_GRAB_DISTANCE) {\n possibleMatches.push([\n nearestControlPointIndex - 1,\n Math.abs(\n convertControlPointOpacityToPanelSpace(\n nearestControlPointIndex - 1,\n )! - mouseYPosition,\n ),\n ]);\n }\n const bestMatch = possibleMatches.sort((a, b) => a[1] - b[1])[0][0];\n return bestMatch;\n }\n}\n\n/**\n * Widget for the transfer function. Creates the UI elements required for the transfer function.\n */\nclass TransferFunctionWidget extends Tab {\n private transferFunctionPanel = this.registerDisposer(\n new TransferFunctionPanel(this),\n );\n\n window = createWindowBoundInputs(this.dataType, this.trackable);\n\n get texture() {\n return this.histogramSpecifications.getFramebuffers(this.display.gl)[\n this.histogramIndex\n ].colorBuffers[0].texture;\n }\n constructor(\n visibility: WatchableVisibilityPriority,\n public display: DisplayContext,\n public dataType: DataType,\n public trackable: WatchableValueInterface,\n public histogramSpecifications: HistogramSpecifications,\n public histogramIndex: number,\n ) {\n super(visibility);\n this.registerDisposer(\n histogramSpecifications.visibility.add(this.visibility),\n );\n const { element } = this;\n element.classList.add(\"neuroglancer-transfer-function-widget\");\n element.appendChild(this.transferFunctionPanel.element);\n\n // Range bounds element\n element.appendChild(this.window.container);\n this.window.container.dispatchEvent(new Event(\"change\"));\n\n // Color picker element\n const colorPickerDiv = document.createElement(\"div\");\n colorPickerDiv.classList.add(\"neuroglancer-transfer-function-color-picker\");\n const colorPicker = this.registerDisposer(\n new ColorWidget(\n makeCachedDerivedWatchableValue(\n (x: TransferFunctionParameters) => x.defaultColor,\n [trackable],\n ),\n () => vec3.fromValues(1, 1, 1),\n ),\n );\n colorPicker.element.title = \"Transfer Function Color Picker\";\n colorPicker.element.id = \"neuroglancer-tf-color-widget\";\n colorPicker.element.addEventListener(\"change\", () => {\n trackable.value = {\n ...this.trackable.value,\n defaultColor: colorPicker.model.value,\n };\n });\n colorPicker.element.addEventListener(\"input\", () => {\n trackable.value = {\n ...this.trackable.value,\n defaultColor: colorPicker.model.value,\n };\n });\n colorPickerDiv.appendChild(colorPicker.element);\n\n element.appendChild(colorPickerDiv);\n this.updateControlPointsAndDraw();\n this.registerDisposer(\n this.trackable.changed.add(() => {\n this.updateControlPointsAndDraw();\n }),\n );\n }\n updateView() {\n for (let i = 0; i < 2; ++i) {\n updateInputBoundValue(\n this.window.inputs[i],\n this.trackable.value.window[i],\n );\n }\n this.transferFunctionPanel.scheduleRedraw();\n }\n updateControlPointsAndDraw() {\n this.transferFunctionPanel.update();\n this.updateView();\n }\n}\n\n/**\n * Create a shader function for the transfer function to grab the nearest lookup table value\n */\nexport function defineTransferFunctionShader(\n builder: ShaderBuilder,\n name: string,\n dataType: DataType,\n channel: number[],\n) {\n builder.addUniform(\"highp float\", `uTransferFunctionEnd_${name}`);\n builder.addTextureSampler(\n \"sampler2D\",\n `uTransferFunctionSampler_${name}`,\n `TransferFunction.${name}`,\n );\n const invlerpShaderCode = defineInvlerpShaderFunction(\n builder,\n name,\n dataType,\n true,\n ) as ShaderCodePart[];\n const shaderType = getShaderType(dataType);\n // Use ${name}_ to avoid name collisions with other shader functions in the case of FLOAT32 dtype\n let code = `\nvec4 ${name}_(float inputValue) {\n int index = clamp(int(round(inputValue * uTransferFunctionEnd_${name})), 0, int(uTransferFunctionEnd_${name}));\n return texelFetch(uTransferFunctionSampler_${name}, ivec2(index, 0), 0);\n}\nvec4 ${name}(${shaderType} inputValue) {\n float v = computeInvlerp(inputValue, uLerpParams_${name});\n defaultMaxProjectionIntensity = v;\n return v < 0.0 ? vec4(0.0, 0.0, 0.0, 0.0) : ${name}_(clamp(v, 0.0, 1.0));\n}\nvec4 ${name}() {\n return ${name}(getDataValue(${channel.join(\",\")}));\n}\n`;\n if (dataType !== DataType.UINT64 && dataType !== DataType.FLOAT32) {\n const scalarType = DATA_TYPE_SIGNED[dataType] ? \"int\" : \"uint\";\n code += `\nvec4 ${name}(${scalarType} inputValue) {\n return ${name}(${shaderType}(inputValue));\n}\n`;\n }\n return [\n invlerpShaderCode[0],\n invlerpShaderCode[1],\n invlerpShaderCode[2],\n code,\n ];\n}\n\n/**\n * Create a lookup table and bind that lookup table to a shader via uniforms\n */\nexport function enableTransferFunctionShader(\n shader: ShaderProgram,\n name: string,\n dataType: DataType,\n sortedControlPoints: SortedControlPoints,\n lookupTableSize: number = defaultTransferFunctionSizes[dataType],\n) {\n const { gl } = shader;\n const texture = shader.transferFunctionTextures.get(\n `TransferFunction.${name}`,\n );\n // Create a lookup table texture if it does not exist\n if (texture === undefined) {\n shader.transferFunctionTextures.set(\n `TransferFunction.${name}`,\n new ControlPointTexture(gl),\n );\n }\n const textureSize = shader.bindAndUpdateTransferFunctionTexture(\n `TransferFunction.${name}`,\n sortedControlPoints,\n dataType,\n lookupTableSize,\n );\n if (textureSize === undefined) {\n throw new Error(\"Failed to create transfer function texture\");\n }\n\n // Bind the length of the lookup table to the shader as a uniform\n gl.uniform1f(shader.uniform(`uTransferFunctionEnd_${name}`), textureSize - 1);\n\n // Use the lerp shader function to grab an index into the lookup table\n const interval = sortedControlPoints.range;\n enableLerpShaderFunction(shader, name, dataType, interval);\n}\n\n/**\n * Behaviour of the transfer function widget in the tool popup window\n */\nexport function activateTransferFunctionTool(\n activation: ToolActivation,\n control: TransferFunctionWidget,\n) {\n activation.bindInputEventMap(inputEventMap);\n control;\n}\n\n/**\n * Create a layer control factory for the transfer function widget\n */\nexport function transferFunctionLayerControl(\n getter: (layer: LayerType) => {\n watchableValue: WatchableValueInterface;\n defaultChannel: number[];\n channelCoordinateSpaceCombiner: CoordinateSpaceCombiner | undefined;\n histogramSpecifications: HistogramSpecifications;\n histogramIndex: number;\n dataType: DataType;\n },\n): LayerControlFactory {\n return {\n makeControl: (layer, context, options) => {\n const {\n watchableValue,\n channelCoordinateSpaceCombiner,\n defaultChannel,\n histogramSpecifications,\n histogramIndex,\n dataType,\n } = getter(layer);\n\n // Setup the ability to change the channel through the UI here\n // but only if the data has multiple channels\n if (\n channelCoordinateSpaceCombiner !== undefined &&\n defaultChannel.length !== 0\n ) {\n const position = context.registerDisposer(\n new Position(channelCoordinateSpaceCombiner.combined),\n );\n const positiionWidget = context.registerDisposer(\n new PositionWidget(position, channelCoordinateSpaceCombiner, {\n copyButton: false,\n }),\n );\n context.registerDisposer(\n position.changed.add(() => {\n const value = position.value;\n const newChannel = Array.from(value, (x) => Math.floor(x));\n const oldParams = watchableValue.value;\n if (!arraysEqual(oldParams.channel, newChannel)) {\n watchableValue.value = {\n ...watchableValue.value,\n channel: newChannel,\n };\n }\n }),\n );\n const updatePosition = () => {\n const value = position.value;\n const params = watchableValue.value;\n if (!arraysEqual(params.channel, value)) {\n value.set(params.channel);\n position.changed.dispatch();\n }\n };\n updatePosition();\n context.registerDisposer(watchableValue.changed.add(updatePosition));\n options.labelContainer.appendChild(positiionWidget.element);\n }\n const control = context.registerDisposer(\n new TransferFunctionWidget(\n options.visibility,\n options.display,\n dataType,\n watchableValue,\n histogramSpecifications,\n histogramIndex,\n ),\n );\n return { control, controlElement: control.element };\n },\n activateTool: (activation, control) => {\n activateTransferFunctionTool(activation, control);\n },\n };\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { CoordinateSpaceCombiner } from \"#src/coordinate_transform.js\";\nimport { TrackableBoolean } from \"#src/trackable_boolean.js\";\nimport type {\n TrackableValueInterface,\n WatchableValueInterface,\n} from \"#src/trackable_value.js\";\nimport {\n constantWatchableValue,\n makeCachedDerivedWatchableValue,\n makeCachedLazyDerivedWatchableValue,\n TrackableValue,\n} from \"#src/trackable_value.js\";\nimport { arraysEqual, arraysEqualWithPredicate } from \"#src/util/array.js\";\nimport {\n parseRGBColorSpecification,\n serializeColor,\n TrackableRGB,\n} from \"#src/util/color.js\";\nimport { DataType } from \"#src/util/data_type.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport { kZeroVec4, vec3, vec4 } from \"#src/util/geom.js\";\nimport {\n parseArray,\n parseFixedLengthArray,\n verifyFiniteFloat,\n verifyInt,\n verifyObject,\n verifyOptionalObjectProperty,\n verifyString,\n} from \"#src/util/json.js\";\nimport type { DataTypeInterval } from \"#src/util/lerp.js\";\nimport {\n computeLerp,\n convertDataTypeInterval,\n dataTypeIntervalToJson,\n defaultDataTypeRange,\n normalizeDataTypeInterval,\n parseDataTypeInterval,\n parseDataTypeValue,\n parseUnknownDataTypeInterval,\n validateDataTypeInterval,\n} from \"#src/util/lerp.js\";\nimport { NullarySignal } from \"#src/util/signal.js\";\nimport type { Trackable } from \"#src/util/trackable.js\";\nimport type { Uint64 } from \"#src/util/uint64.js\";\nimport type { GL } from \"#src/webgl/context.js\";\nimport type { HistogramChannelSpecification } from \"#src/webgl/empirical_cdf.js\";\nimport { HistogramSpecifications } from \"#src/webgl/empirical_cdf.js\";\nimport {\n defineInvlerpShaderFunction,\n enableLerpShaderFunction,\n} from \"#src/webgl/lerp.js\";\nimport type { ShaderBuilder, ShaderProgram } from \"#src/webgl/shader.js\";\nimport type { TransferFunctionParameters } from \"#src/widget/transfer_function.js\";\nimport {\n defineTransferFunctionShader,\n enableTransferFunctionShader,\n SortedControlPoints,\n ControlPoint,\n} from \"#src/widget/transfer_function.js\";\n\nexport interface ShaderSliderControl {\n type: \"slider\";\n valueType: \"int\" | \"uint\" | \"float\";\n min: number;\n max: number;\n step: number;\n default: number;\n}\n\nexport interface ShaderColorControl {\n type: \"color\";\n valueType: \"vec3\";\n defaultString: string;\n default: vec3;\n}\n\nexport interface ShaderImageInvlerpControl {\n type: \"imageInvlerp\";\n dataType: DataType;\n clamp: boolean;\n default: ImageInvlerpParameters;\n}\n\nexport type PropertiesSpecification = Map;\n\nexport interface ShaderPropertyInvlerpControl {\n type: \"propertyInvlerp\";\n clamp: boolean;\n properties: PropertiesSpecification;\n default: PropertyInvlerpParameters;\n}\n\nexport interface ShaderCheckboxControl {\n type: \"checkbox\";\n valueType: \"bool\";\n default: boolean;\n}\n\nexport interface ShaderTransferFunctionControl {\n type: \"transferFunction\";\n dataType: DataType;\n default: TransferFunctionParameters;\n}\n\nexport type ShaderUiControl =\n | ShaderSliderControl\n | ShaderColorControl\n | ShaderImageInvlerpControl\n | ShaderPropertyInvlerpControl\n | ShaderCheckboxControl\n | ShaderTransferFunctionControl;\n\nexport interface ShaderControlParseError {\n line: number;\n message: string;\n}\n\nexport interface ShaderControlsParseResult {\n // Original source code entered by user.\n source: string;\n // Source code with comments stripped and UI controls replaced by appropriate text.\n code: string;\n controls: Map;\n errors: ShaderControlParseError[];\n}\n\nexport interface ShaderControlsBuilderState {\n key: string;\n parseResult: ShaderControlsParseResult;\n builderValues: ShaderBuilderValues;\n referencedProperties: string[];\n}\n\n// Strips comments from GLSL code. Also handles string literals since they are used in ui control\n// directives.\nexport function stripComments(code: string) {\n // https://stackoverflow.com/a/241506\n const commentPattern =\n /\\/\\/.*?$|\\/\\*(?:.|\\n)*?\\*\\/|'(?:\\\\.|[^\\\\'])*'|\"(?:\\\\.|[^\\\\\"])*\"/gm;\n return code.replace(commentPattern, (m) => {\n if (m.startsWith(\"/\")) {\n return m.replace(/[^\\s]/g, \" \");\n }\n return m;\n });\n}\n\ntype DirectiveParameters = Map;\n\n// Returns the length of the prefix that may be a valid directive parameter.\nfunction matchDirectiveParameterValue(input: string): number {\n const valueTokenPattern =\n /^(?:-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?|\"(?:\\\\.|[^\\\\\"])*\"|true|false|:|\\s+|,|\\[|\\]|\\{|\\})/;\n let depth = 0;\n const initialInput = input;\n outerLoop: while (input.length) {\n const m = input.match(valueTokenPattern);\n if (m === null) break;\n const token = m[0];\n switch (token.charAt(0)) {\n case \"[\":\n case \"{\":\n ++depth;\n break;\n case \"]\":\n case \"}\":\n if (--depth < 0) return -1;\n break;\n case \",\":\n if (depth === 0) break outerLoop;\n break;\n default:\n if (depth === 0) {\n input = input.substring(token.length);\n break outerLoop;\n }\n break;\n }\n input = input.substring(token.length);\n }\n if (depth !== 0) return -1;\n return initialInput.length - input.length;\n}\n\nexport function parseDirectiveParameters(input: string | undefined): {\n parameters: DirectiveParameters;\n errors: string[];\n} {\n const errors: string[] = [];\n const parameters = new Map();\n if (input === undefined) {\n return { errors, parameters };\n }\n const startPattern = /^([_a-z][_a-zA-Z0-9]*)[ \\t]*=/;\n while (true) {\n input = input.trim();\n if (input.length === 0) break;\n const m = input.match(startPattern);\n if (m === null) {\n errors.push(\n \"Invalid #uicontrol parameter syntax, expected: =, ...\",\n );\n break;\n }\n const name = m[1];\n input = input.substring(m[0].length);\n const valueLength = matchDirectiveParameterValue(input);\n if (valueLength <= 0) {\n errors.push(\n \"Invalid #uicontrol parameter syntax, expected: =, ...\",\n );\n break;\n }\n let value;\n try {\n value = JSON.parse(input.substring(0, valueLength));\n } catch {\n errors.push(`Invalid #uicontrol parameter value for ${name}: ${value}`);\n break;\n }\n if (parameters.has(name)) {\n errors.push(`Duplicate #uicontrol parameter: ${name}`);\n } else {\n parameters.set(name, value);\n }\n input = input.substring(valueLength);\n input = input.trim();\n if (input.length > 0 && !input.startsWith(\",\")) {\n errors.push(\n \"Invalid #uicontrol parameter syntax, expected: =, ...\",\n );\n }\n input = input.substring(1);\n }\n return { parameters, errors };\n}\n\ntype DirectiveParseResult =\n | {\n control: ShaderUiControl;\n errors: undefined;\n }\n | { errors: string[] };\n\nfunction parseSliderDirective(\n valueType: string,\n parameters: DirectiveParameters,\n): DirectiveParseResult {\n let min: number | undefined;\n let max: number | undefined;\n let step: number | undefined;\n let defaultValue: number | undefined;\n const errors = [];\n if (valueType !== \"float\" && valueType !== \"uint\" && valueType !== \"int\") {\n errors.push(\"type must be float, int, or uint\");\n }\n for (const [key, value] of parameters) {\n const getValue = (): number | undefined => {\n if (typeof value !== \"number\") {\n errors.push(`Expected ${key} argument to be a number`);\n return undefined;\n }\n if (valueType === \"int\" || valueType === \"uint\") {\n if (!Number.isInteger(value)) {\n errors.push(`Expected ${key} argument to be an integer`);\n }\n if (valueType === \"uint\" && value < 0) {\n errors.push(`Expected ${key} argument to be an unsigned integer`);\n }\n }\n return value;\n };\n if (key === \"min\") {\n min = getValue();\n } else if (key === \"max\") {\n max = getValue();\n } else if (key === \"default\") {\n defaultValue = getValue();\n } else if (key === \"step\") {\n step = getValue();\n } else {\n errors.push(`Invalid parameter: ${key}`);\n }\n }\n if (min === undefined) {\n errors.push(\"min must be specified\");\n }\n if (max === undefined) {\n errors.push(\"max must be specified\");\n }\n if (min !== undefined && max !== undefined) {\n if (min > max) {\n errors.push(\"min must be less than max\");\n }\n if (step === undefined) {\n if (valueType === \"float\") {\n step = (max - min) / 100;\n } else {\n step = 1;\n }\n }\n if (defaultValue !== undefined) {\n if (defaultValue < min || defaultValue > max) {\n errors.push(\"default must be within valid range\");\n }\n } else {\n if (valueType === \"float\") {\n defaultValue = (min + max) / 2;\n } else {\n defaultValue = min;\n }\n }\n }\n if (errors.length > 0) {\n return { errors };\n }\n return {\n control: {\n type: \"slider\",\n valueType,\n min,\n max,\n step,\n default: defaultValue,\n } as ShaderSliderControl,\n errors: undefined,\n };\n}\n\nfunction parseCheckboxDirective(\n valueType: string,\n parameters: DirectiveParameters,\n): DirectiveParseResult {\n let defaultValue = false;\n const errors = [];\n if (valueType !== \"bool\") {\n errors.push(\"type must be bool\");\n }\n for (const [key, value] of parameters) {\n if (key === \"default\") {\n if (typeof value !== \"boolean\") {\n errors.push(`Expected ${key} argument to be a boolean`);\n continue;\n }\n defaultValue = value;\n } else {\n errors.push(`Invalid parameter: ${key}`);\n }\n }\n if (errors.length > 0) {\n return { errors };\n }\n return {\n control: {\n type: \"checkbox\",\n valueType,\n default: defaultValue,\n } as ShaderCheckboxControl,\n errors: undefined,\n };\n}\n\nfunction parseColorDirective(\n valueType: string,\n parameters: DirectiveParameters,\n): DirectiveParseResult {\n let defaultColor = \"white\";\n const errors = [];\n if (valueType !== \"vec3\") {\n errors.push(\"type must be vec3\");\n }\n for (const [key, value] of parameters) {\n if (key === \"default\") {\n if (typeof value !== \"string\") {\n errors.push(\"Expected default argument to be a string\");\n } else {\n defaultColor = value;\n }\n } else {\n errors.push(`Invalid parameter: ${key}`);\n }\n }\n if (errors.length > 0) {\n return { errors };\n }\n return {\n control: {\n type: \"color\",\n valueType,\n defaultString: defaultColor,\n default: parseRGBColorSpecification(defaultColor),\n } as ShaderColorControl,\n errors: undefined,\n };\n}\n\nfunction parseInvlerpChannel(value: unknown, rank: number) {\n if (typeof value === \"number\") {\n value = [value];\n }\n const channel = new Array(rank);\n parseFixedLengthArray(channel, value, (x) => {\n if (!Number.isInteger(x) || x < 0) {\n throw new Error(\n `Expected non-negative integer, but received: ${JSON.stringify(x)}`,\n );\n }\n return x;\n });\n return channel;\n}\n\nfunction parseInvlerpDirective(\n valueType: string,\n parameters: DirectiveParameters,\n dataContext: ShaderDataContext,\n): DirectiveParseResult {\n const { imageData, properties } = dataContext;\n if (imageData !== undefined) {\n return parseImageInvlerpDirective(valueType, parameters, imageData);\n }\n if (properties !== undefined) {\n return parsePropertyInvlerpDirective(valueType, parameters, properties);\n }\n const errors = [];\n errors.push(\"invlerp control not supported\");\n return { errors };\n}\n\nfunction parseImageInvlerpDirective(\n valueType: string,\n parameters: DirectiveParameters,\n imageData: ImageDataSpecification,\n) {\n const errors = [];\n if (valueType !== \"invlerp\") {\n errors.push(\"type must be invlerp\");\n }\n let channel = new Array(imageData.channelRank).fill(0);\n const { dataType } = imageData;\n let clamp = true;\n let range = defaultDataTypeRange[dataType];\n let window: DataTypeInterval | undefined;\n for (const [key, value] of parameters) {\n try {\n switch (key) {\n case \"range\": {\n range = parseDataTypeInterval(value, dataType);\n break;\n }\n case \"window\": {\n window = validateDataTypeInterval(\n parseDataTypeInterval(value, dataType),\n );\n break;\n }\n case \"clamp\": {\n if (typeof value !== \"boolean\") {\n errors.push(`Invalid clamp value: ${JSON.stringify(value)}`);\n } else {\n clamp = value;\n }\n break;\n }\n case \"channel\": {\n channel = parseInvlerpChannel(value, channel.length);\n break;\n }\n default:\n errors.push(`Invalid parameter: ${key}`);\n break;\n }\n } catch (e) {\n errors.push(`Invalid ${key} value: ${e.message}`);\n }\n }\n if (errors.length > 0) {\n return { errors };\n }\n return {\n control: {\n type: \"imageInvlerp\",\n dataType,\n clamp,\n default: {\n range,\n window: window ?? normalizeDataTypeInterval(range),\n channel,\n },\n } as ShaderImageInvlerpControl,\n errors: undefined,\n };\n}\n\nfunction parsePropertyInvlerpDirective(\n valueType: string,\n parameters: DirectiveParameters,\n properties: Map,\n) {\n const errors = [];\n if (valueType !== \"invlerp\") {\n errors.push(\"type must be invlerp\");\n }\n let clamp = true;\n let range: any;\n let window: any;\n let property: string | undefined;\n for (const [key, value] of parameters) {\n try {\n switch (key) {\n case \"range\": {\n range = parseUnknownDataTypeInterval(value);\n break;\n }\n case \"window\": {\n window = parseUnknownDataTypeInterval(value);\n break;\n }\n case \"clamp\": {\n if (typeof value !== \"boolean\") {\n errors.push(`Invalid clamp value: ${JSON.stringify(value)}`);\n } else {\n clamp = value;\n }\n break;\n }\n case \"property\": {\n const s = verifyString(value);\n if (!properties.has(s)) {\n throw new Error(\n `Property not defined: ${JSON.stringify(property)}`,\n );\n }\n property = s;\n break;\n }\n default:\n errors.push(`Invalid parameter: ${key}`);\n break;\n }\n } catch (e) {\n errors.push(`Invalid ${key} value: ${e.message}`);\n }\n }\n if (errors.length > 0) {\n return { errors };\n }\n if (property === undefined) {\n for (const p of properties.keys()) {\n property = p;\n break;\n }\n }\n const dataType = properties.get(property!)!;\n if (range !== undefined) {\n range = convertDataTypeInterval(range, dataType);\n }\n if (window !== undefined) {\n window = convertDataTypeInterval(window, dataType);\n }\n return {\n control: {\n type: \"propertyInvlerp\",\n clamp,\n properties,\n default: { range, window, property, dataType },\n } as ShaderPropertyInvlerpControl,\n errors: undefined,\n };\n}\n\nfunction parseTransferFunctionDirective(\n valueType: string,\n parameters: DirectiveParameters,\n dataContext: ShaderDataContext,\n): DirectiveParseResult {\n const imageData = dataContext.imageData;\n const dataType = imageData?.dataType;\n const channelRank = imageData?.channelRank;\n const errors = [];\n let channel = new Array(channelRank).fill(0);\n let defaultColor = vec3.fromValues(1.0, 1.0, 1.0);\n let window: DataTypeInterval | undefined;\n let sortedControlPoints = new SortedControlPoints(\n [],\n dataType !== undefined ? dataType : DataType.FLOAT32,\n );\n let specifedPoints = false;\n if (valueType !== \"transferFunction\") {\n errors.push(\"type must be transferFunction\");\n }\n if (dataType === undefined) {\n errors.push(\"image data must be provided to use a transfer function\");\n }\n for (const [key, value] of parameters) {\n try {\n switch (key) {\n case \"channel\": {\n channel = parseInvlerpChannel(value, channel.length);\n break;\n }\n case \"defaultColor\": {\n defaultColor = parseRGBColorSpecification(value);\n break;\n }\n case \"window\": {\n if (dataType !== undefined) {\n window = validateDataTypeInterval(\n parseDataTypeInterval(value, dataType),\n );\n }\n break;\n }\n case \"controlPoints\": {\n specifedPoints = true;\n if (dataType !== undefined) {\n sortedControlPoints = parseTransferFunctionControlPoints(\n value,\n dataType,\n );\n }\n break;\n }\n default:\n errors.push(`Invalid parameter: ${key}`);\n break;\n }\n } catch (e) {\n errors.push(`Invalid ${key} value: ${e.message}`);\n }\n }\n\n if (window === undefined) {\n window = sortedControlPoints.range;\n }\n // Set a simple black to white transfer function if no control points are specified.\n if (\n sortedControlPoints.length === 0 &&\n !specifedPoints &&\n dataType !== undefined\n ) {\n const startPoint = computeLerp(window, dataType, 0.4) as number;\n const endPoint = computeLerp(window, dataType, 0.7) as number;\n sortedControlPoints.addPoint(new ControlPoint(startPoint, kZeroVec4));\n sortedControlPoints.addPoint(\n new ControlPoint(endPoint, vec4.fromValues(255, 255, 255, 255)),\n );\n }\n if (errors.length > 0) {\n return { errors };\n }\n return {\n control: {\n type: \"transferFunction\",\n dataType,\n default: {\n sortedControlPoints,\n channel,\n defaultColor,\n window,\n },\n } as ShaderTransferFunctionControl,\n errors: undefined,\n };\n}\n\nexport interface ImageDataSpecification {\n dataType: DataType;\n channelRank: number;\n}\n\nexport interface ShaderDataContext {\n imageData?: ImageDataSpecification;\n properties?: Map;\n}\n\nconst controlParsers = new Map<\n string,\n (\n valueType: string,\n parameters: DirectiveParameters,\n context: ShaderDataContext,\n ) => DirectiveParseResult\n>([\n [\"slider\", parseSliderDirective],\n [\"color\", parseColorDirective],\n [\"invlerp\", parseInvlerpDirective],\n [\"checkbox\", parseCheckboxDirective],\n [\"transferFunction\", parseTransferFunctionDirective],\n]);\n\nexport function parseShaderUiControls(\n code: string,\n dataContext: ShaderDataContext = {},\n): ShaderControlsParseResult {\n code = stripComments(code);\n // Matches any #uicontrols directive. Syntax errors in the directive are handled later.\n const directivePattern = /^[ \\t]*#[ \\t]*uicontrol[ \\t]+(.*)$/gm;\n const innerPattern =\n /^([_a-zA-Z][_a-zA-Z0-9]*)[ \\t]+([a-z][a-zA-Z0-9_]*)(?:[ \\t]+([a-z]+))?[ \\t]*(?:\\([ \\t]*(.*)\\)[ \\t]*)?/;\n const errors: { line: number; message: string }[] = [];\n const controls = new Map();\n const newCode = code.replace(\n directivePattern,\n (_match, innerPart: string, offset: number) => {\n const m = innerPart.match(innerPattern);\n const getLineNumber = () => {\n return Math.max(0, code.substring(0, offset).split(\"\\n\").length - 1);\n };\n if (m === null) {\n errors.push({\n line: getLineNumber(),\n message:\n \"Invalid #uicontrol syntax, expected: #uicontrol (=, ...)\",\n });\n return \"\";\n }\n const typeName = m[1];\n const variableName = m[2];\n const controlName = m[3] ?? typeName;\n const parameterText = m[4];\n const { parameters, errors: innerErrors } =\n parseDirectiveParameters(parameterText);\n for (const error of innerErrors) {\n errors.push({ line: getLineNumber(), message: error });\n }\n if (controls.has(variableName)) {\n errors.push({\n line: getLineNumber(),\n message: `Duplicate definition for control ${variableName}`,\n });\n }\n if (innerErrors.length > 0) {\n return \"\";\n }\n const parser = controlParsers.get(controlName);\n if (parser === undefined) {\n errors.push({\n line: getLineNumber(),\n message: `Invalid control type ${controlName}`,\n });\n return \"\";\n }\n const result = parser(typeName, parameters, dataContext);\n if (result.errors !== undefined) {\n for (const error of result.errors) {\n errors.push({ line: getLineNumber(), message: error });\n }\n return \"\";\n }\n controls.set(variableName, result.control);\n return \"\";\n },\n );\n return { source: code, code: newCode, errors, controls };\n}\n\nexport type Controls = Map;\n\nfunction uniformName(controlName: string) {\n return `u_shaderControl_${controlName}`;\n}\n\nexport function addControlsToBuilder(\n builderState: ShaderControlsBuilderState,\n builder: ShaderBuilder,\n) {\n const { builderValues } = builderState;\n for (const [name, control] of builderState.parseResult.controls) {\n const uName = uniformName(name);\n const builderValue = builderValues[name];\n switch (control.type) {\n case \"imageInvlerp\": {\n const code = [\n defineInvlerpShaderFunction(\n builder,\n uName,\n control.dataType,\n control.clamp,\n ),\n `\nfloat ${uName}() {\n return ${uName}(getDataValue(${builderValue.channel.join(\",\")}));\n}\n`,\n ];\n builder.addFragmentCode(code);\n builder.addFragmentCode(`#define ${name} ${uName}\\n`);\n break;\n }\n case \"propertyInvlerp\": {\n const property = builderValue.property;\n const dataType = control.properties.get(property)!;\n const code = [\n defineInvlerpShaderFunction(builder, uName, dataType, control.clamp),\n `\nfloat ${uName}() {\n return ${uName}(prop_${property}());\n}\n`,\n ];\n builder.addVertexCode(code);\n builder.addVertexCode(`#define ${name} ${uName}\\n`);\n break;\n }\n case \"checkbox\": {\n const code = `#define ${name} ${builderValue.value}\\n`;\n builder.addFragmentCode(code);\n builder.addVertexCode(code);\n break;\n }\n case \"transferFunction\": {\n builder.addFragmentCode(`#define ${name} ${uName}\\n`);\n builder.addFragmentCode(\n defineTransferFunctionShader(\n builder,\n uName,\n control.dataType,\n builderValue.channel,\n ),\n );\n break;\n }\n default: {\n builder.addUniform(`highp ${control.valueType}`, uName);\n builder.addVertexCode(`#define ${name} ${uName}\\n`);\n builder.addFragmentCode(`#define ${name} ${uName}\\n`);\n break;\n }\n }\n }\n}\n\nfunction objectFromEntries(entries: Iterable<[string, any]>) {\n const obj: any = {};\n for (const [key, value] of entries) {\n obj[key] = value;\n }\n return obj;\n}\n\nfunction replaceMap(_key: string, value: unknown) {\n if (value instanceof Map) {\n return Array.from(value.entries());\n }\n return value;\n}\n\nfunction encodeControls(controls: Controls | undefined) {\n if (controls === undefined) return undefined;\n return JSON.stringify(objectFromEntries(controls), replaceMap);\n}\n\nexport class WatchableShaderUiControls\n implements WatchableValueInterface\n{\n changed = new NullarySignal();\n controls: Controls | undefined = undefined;\n get value() {\n return this.controls;\n }\n set value(newControls: Controls | undefined) {\n if (encodeControls(newControls) === encodeControls(this.controls)) {\n return;\n }\n this.controls = newControls;\n this.changed.dispatch();\n }\n}\n\nexport interface InvlerpParameters {\n range: DataTypeInterval;\n window: DataTypeInterval;\n}\n\nexport interface ImageInvlerpParameters extends InvlerpParameters {\n channel: number[];\n}\n\nexport interface PropertyInvlerpParameters {\n range: DataTypeInterval | undefined;\n window: DataTypeInterval | undefined;\n property: string;\n dataType: DataType;\n}\n\nfunction parseImageInvlerpParameters(\n obj: unknown,\n dataType: DataType,\n defaultValue: ImageInvlerpParameters,\n): ImageInvlerpParameters {\n if (obj === undefined) return defaultValue;\n verifyObject(obj);\n return {\n range: verifyOptionalObjectProperty(\n obj,\n \"range\",\n (x) => parseDataTypeInterval(x, dataType),\n defaultValue.range,\n ),\n window: verifyOptionalObjectProperty(\n obj,\n \"window\",\n (x) => validateDataTypeInterval(parseDataTypeInterval(x, dataType)),\n defaultValue.window,\n ),\n channel: verifyOptionalObjectProperty(\n obj,\n \"channel\",\n (x) => parseInvlerpChannel(x, defaultValue.channel.length),\n defaultValue.channel,\n ),\n };\n}\n\nclass TrackableImageInvlerpParameters extends TrackableValue {\n constructor(\n public dataType: DataType,\n public defaultValue: ImageInvlerpParameters,\n ) {\n super(defaultValue, (obj) =>\n parseImageInvlerpParameters(obj, dataType, defaultValue),\n );\n }\n\n toJSON() {\n const {\n value: { range, window, channel },\n dataType,\n defaultValue,\n } = this;\n const rangeJson = dataTypeIntervalToJson(\n range,\n dataType,\n defaultValue.range,\n );\n const windowJson = dataTypeIntervalToJson(\n window,\n dataType,\n defaultValue.window,\n );\n const channelJson = arraysEqual(defaultValue.channel, channel)\n ? undefined\n : channel;\n if (\n rangeJson === undefined &&\n windowJson === undefined &&\n channelJson === undefined\n ) {\n return undefined;\n }\n return { range: rangeJson, window: windowJson, channel: channelJson };\n }\n}\n\nfunction parsePropertyInvlerpParameters(\n obj: unknown,\n properties: PropertiesSpecification,\n defaultValue: PropertyInvlerpParameters,\n): PropertyInvlerpParameters {\n if (obj === undefined) return defaultValue;\n verifyObject(obj);\n const property = verifyOptionalObjectProperty(\n obj,\n \"property\",\n (property) => {\n property = verifyString(property);\n if (!properties.has(property)) {\n throw new Error(`Invalid value: ${JSON.stringify(property)}`);\n }\n return property;\n },\n defaultValue.property,\n );\n const dataType = properties.get(property)!;\n return {\n property,\n dataType,\n range: verifyOptionalObjectProperty(\n obj,\n \"range\",\n (x) => parseDataTypeInterval(x, dataType),\n defaultValue.range,\n ),\n window: verifyOptionalObjectProperty(\n obj,\n \"window\",\n (x) => validateDataTypeInterval(parseDataTypeInterval(x, dataType)),\n defaultValue.window,\n ),\n };\n}\n\nclass TrackablePropertyInvlerpParameters extends TrackableValue {\n constructor(\n public properties: PropertiesSpecification,\n public defaultValue: PropertyInvlerpParameters,\n ) {\n super(defaultValue, (obj) =>\n parsePropertyInvlerpParameters(obj, properties, defaultValue),\n );\n }\n\n toJSON() {\n const {\n value: { range, window, property, dataType },\n defaultValue,\n } = this;\n const defaultRange = defaultDataTypeRange[dataType];\n const rangeJson = dataTypeIntervalToJson(\n range ?? defaultRange,\n dataType,\n defaultValue.range ?? defaultRange,\n );\n const windowJson = dataTypeIntervalToJson(\n window ?? defaultRange,\n dataType,\n defaultValue.window ?? defaultRange,\n );\n const propertyJson =\n property === defaultValue.property ? undefined : property;\n if (\n rangeJson === undefined &&\n windowJson === undefined &&\n propertyJson === undefined\n ) {\n return undefined;\n }\n return { range: rangeJson, window: windowJson, property: propertyJson };\n }\n}\n\nfunction parseTransferFunctionControlPoints(\n controlPointsDefinition: unknown,\n dataType: DataType,\n) {\n const parsedPoints = parseArray(controlPointsDefinition, (x) => {\n // Validate input length and types\n const allowedInput =\n dataType === DataType.UINT64\n ? typeof x[0] === \"string\" || typeof x[0] === \"number\"\n : typeof x[0] === \"number\";\n if (\n x.length !== 3 ||\n !allowedInput ||\n typeof x[1] !== \"string\" ||\n typeof x[2] !== \"number\"\n ) {\n throw new Error(\n `Expected array of length 3 (x, \"#RRGGBB\", A), but received: ${JSON.stringify(\n x,\n )}`,\n );\n }\n const inputValue = parseDataTypeValue(dataType, x[0]);\n\n if (x[1].length !== 7 || x[1][0] !== \"#\") {\n throw new Error(\n `Expected #RRGGBB, but received: ${JSON.stringify(x[1])}`,\n );\n }\n if (x[2] < 0 || x[2] > 1) {\n throw new Error(\n `Expected opacity in range [0, 1], but received: ${JSON.stringify(\n x[2],\n )}`,\n );\n }\n const color = parseRGBColorSpecification(x[1]);\n function floatToUint8(float: number) {\n return Math.min(255, Math.max(Math.round(float * 255), 0));\n }\n return new ControlPoint(\n inputValue,\n vec4.fromValues(\n floatToUint8(color[0]),\n floatToUint8(color[1]),\n floatToUint8(color[2]),\n floatToUint8(x[2]),\n ),\n );\n });\n return new SortedControlPoints(parsedPoints, dataType);\n}\n\nexport function parseTransferFunctionParameters(\n obj: unknown,\n dataType: DataType,\n defaultValue: TransferFunctionParameters,\n): TransferFunctionParameters {\n if (obj === undefined) return defaultValue;\n verifyObject(obj);\n const sortedControlPoints = verifyOptionalObjectProperty(\n obj,\n \"controlPoints\",\n (x) => parseTransferFunctionControlPoints(x, dataType),\n defaultValue.sortedControlPoints,\n );\n const window = verifyOptionalObjectProperty(\n obj,\n \"window\",\n (x) => parseDataTypeInterval(x, dataType),\n defaultValue.window,\n );\n return {\n sortedControlPoints,\n channel: verifyOptionalObjectProperty(\n obj,\n \"channel\",\n (x) => parseInvlerpChannel(x, defaultValue.channel.length),\n defaultValue.channel,\n ),\n defaultColor: verifyOptionalObjectProperty(\n obj,\n \"defaultColor\",\n (x) => parseRGBColorSpecification(x),\n defaultValue.defaultColor,\n ),\n window,\n };\n}\n\nfunction copyTransferFunctionParameters(\n defaultValue: TransferFunctionParameters,\n) {\n return {\n ...defaultValue,\n sortedControlPoints: defaultValue.sortedControlPoints.copy(),\n };\n}\n\nexport class TrackableTransferFunctionParameters extends TrackableValue {\n constructor(\n public dataType: DataType,\n public defaultValue: TransferFunctionParameters,\n ) {\n // Create a copy of the default value to enable detecting changes\n // to the control points in the trackable value.\n const defaultValueCopy = copyTransferFunctionParameters(defaultValue);\n super(defaultValueCopy, (obj) =>\n parseTransferFunctionParameters(obj, dataType, defaultValueCopy),\n );\n }\n\n controlPointsToJson(controlPoints: ControlPoint[], dataType: DataType) {\n function inputToJson(inputValue: number | Uint64) {\n if (dataType === DataType.UINT64) {\n return (inputValue as Uint64).toJSON();\n }\n return inputValue;\n }\n\n return controlPoints.map((x) => [\n inputToJson(x.inputValue),\n serializeColor(\n vec3.fromValues(\n x.outputColor[0] / 255,\n x.outputColor[1] / 255,\n x.outputColor[2] / 255,\n ),\n ),\n x.outputColor[3] / 255,\n ]);\n }\n\n toJSON() {\n const {\n value: { channel, sortedControlPoints, defaultColor, window },\n dataType,\n defaultValue,\n } = this;\n const windowJson = dataTypeIntervalToJson(\n window,\n dataType,\n defaultValue.window,\n );\n const channelJson = arraysEqual(defaultValue.channel, channel)\n ? undefined\n : channel;\n const colorJson = arraysEqual(defaultValue.defaultColor, defaultColor)\n ? undefined\n : serializeColor(defaultColor);\n const controlPointsJson = arraysEqualWithPredicate(\n defaultValue.sortedControlPoints.controlPoints,\n sortedControlPoints.controlPoints,\n (a, b) =>\n arraysEqual(a.outputColor, b.outputColor) &&\n a.inputValue === b.inputValue,\n )\n ? undefined\n : this.controlPointsToJson(sortedControlPoints.controlPoints, dataType);\n if (\n channelJson === undefined &&\n colorJson === undefined &&\n controlPointsJson === undefined &&\n windowJson === undefined\n ) {\n return undefined;\n }\n return {\n channel: channelJson,\n defaultColor: colorJson,\n controlPoints: controlPointsJson,\n window: windowJson,\n };\n }\n}\n\nfunction getControlTrackable(control: ShaderUiControl): {\n trackable: TrackableValueInterface;\n getBuilderValue: (value: any) => any;\n} {\n switch (control.type) {\n case \"slider\":\n return {\n trackable: new TrackableValue(control.default, (x) => {\n let v: number;\n if (control.valueType === \"float\") {\n v = verifyFiniteFloat(x);\n } else {\n v = verifyInt(x);\n }\n if (v < control.min || v > control.max) {\n throw new Error(\n `${JSON.stringify(x)} is outside valid range [${control.min}, ${\n control.max\n }]`,\n );\n }\n return v;\n }),\n getBuilderValue: () => null,\n };\n case \"color\":\n return {\n trackable: new TrackableRGB(control.default),\n getBuilderValue: () => null,\n };\n case \"imageInvlerp\":\n return {\n trackable: new TrackableImageInvlerpParameters(\n control.dataType,\n control.default,\n ),\n getBuilderValue: (value: ImageInvlerpParameters) => ({\n channel: value.channel,\n dataType: control.dataType,\n }),\n };\n case \"propertyInvlerp\":\n return {\n trackable: new TrackablePropertyInvlerpParameters(\n control.properties,\n control.default,\n ),\n getBuilderValue: (value: PropertyInvlerpParameters) => ({\n property: value.property,\n dataType: value.dataType,\n }),\n };\n case \"checkbox\":\n return {\n trackable: new TrackableBoolean(control.default),\n getBuilderValue: (value) => ({ value }),\n };\n case \"transferFunction\":\n return {\n trackable: new TrackableTransferFunctionParameters(\n control.dataType,\n control.default,\n ),\n getBuilderValue: (value: TransferFunctionParameters) => ({\n channel: value.channel,\n dataType: control.dataType,\n }),\n };\n }\n}\n\nexport interface SingleShaderControlState {\n control: ShaderUiControl;\n trackable: TrackableValueInterface;\n getBuilderValue: (value: any) => any;\n}\n\nexport type ShaderControlMap = Map;\n\nexport type ShaderBuilderValues = {\n [key: string]: any;\n};\n\nfunction encodeBuilderStateKey(\n builderValues: ShaderBuilderValues,\n parseResult: ShaderControlsParseResult,\n) {\n return JSON.stringify(builderValues) + \"\\0\" + parseResult.source;\n}\n\nexport function getFallbackBuilderState(\n parseResult: ShaderControlsParseResult,\n): ShaderControlsBuilderState {\n const builderValues: ShaderBuilderValues = {};\n const referencedProperties = [];\n for (const [key, control] of parseResult.controls) {\n const { trackable, getBuilderValue } = getControlTrackable(control);\n const builderValue = getBuilderValue(trackable.value);\n builderValues[key] = builderValue;\n if (control.type === \"propertyInvlerp\") {\n referencedProperties.push(builderValue.property);\n }\n }\n return {\n builderValues,\n parseResult,\n key: encodeBuilderStateKey(builderValues, parseResult),\n referencedProperties,\n };\n}\n\nexport class ShaderControlState\n extends RefCounted\n implements Trackable, WatchableValueInterface\n{\n changed = new NullarySignal();\n controls = new WatchableShaderUiControls();\n parseErrors: WatchableValueInterface;\n processedFragmentMain: WatchableValueInterface;\n parseResult: WatchableValueInterface;\n builderState: WatchableValueInterface;\n histogramSpecifications: HistogramSpecifications;\n\n private fragmentMainGeneration = -1;\n private dataContextGeneration = -1;\n private parseErrors_: ShaderControlParseError[] = [];\n private processedFragmentMain_ = \"\";\n private parseResult_: ShaderControlsParseResult;\n private controlsGeneration = -1;\n private parseResultChanged = new NullarySignal();\n\n constructor(\n public fragmentMain: WatchableValueInterface,\n public dataContext: WatchableValueInterface = constantWatchableValue(\n {},\n ),\n public channelCoordinateSpaceCombiner?: CoordinateSpaceCombiner | undefined,\n ) {\n super();\n this.registerDisposer(\n fragmentMain.changed.add(() => this.handleFragmentMainChanged()),\n );\n this.registerDisposer(\n this.controls.changed.add(() => this.handleControlsChanged()),\n );\n this.registerDisposer(\n this.dataContext.changed.add(() => this.handleFragmentMainChanged()),\n );\n this.handleFragmentMainChanged();\n const self = this;\n this.parseErrors = {\n changed: this.parseResultChanged,\n get value() {\n self.handleFragmentMainChanged();\n return self.parseErrors_;\n },\n };\n this.processedFragmentMain = {\n changed: this.parseResultChanged,\n get value() {\n self.handleFragmentMainChanged();\n return self.processedFragmentMain_;\n },\n };\n this.parseResult = {\n changed: this.parseResultChanged,\n get value() {\n return self.parseResult_;\n },\n };\n this.builderState = makeCachedDerivedWatchableValue(\n (parseResult: ShaderControlsParseResult, state: ShaderControlMap) => {\n const builderValues: ShaderBuilderValues = {};\n const referencedProperties = [];\n for (const [key, { control, trackable, getBuilderValue }] of state) {\n const builderValue = getBuilderValue(trackable.value);\n builderValues[key] = builderValue;\n if (control.type === \"propertyInvlerp\") {\n referencedProperties.push(builderValue.property);\n }\n }\n return {\n key: encodeBuilderStateKey(builderValues, parseResult),\n parseResult,\n builderValues,\n referencedProperties,\n };\n },\n [this.parseResult, this],\n (a, b) => a.key === b.key,\n );\n const histogramChannels = makeCachedDerivedWatchableValue(\n (state) => {\n const channels: HistogramChannelSpecification[] = [];\n for (const { control, trackable } of state.values()) {\n if (\n control.type !== \"imageInvlerp\" &&\n control.type !== \"transferFunction\"\n )\n continue;\n channels.push({ channel: trackable.value.channel });\n }\n return channels;\n },\n [this],\n (a, b) =>\n arraysEqualWithPredicate(a, b, (ca, cb) =>\n arraysEqual(ca.channel, cb.channel),\n ),\n );\n const histogramProperties = makeCachedDerivedWatchableValue(\n (state) => {\n const properties: string[] = [];\n for (const { control, trackable } of state.values()) {\n if (control.type !== \"propertyInvlerp\") continue;\n properties.push(trackable.value.property);\n }\n return properties;\n },\n [this],\n arraysEqual,\n );\n const histogramBounds = makeCachedLazyDerivedWatchableValue((state) => {\n const bounds: DataTypeInterval[] = [];\n for (const { control, trackable } of state.values()) {\n if (\n control.type === \"imageInvlerp\" ||\n control.type === \"transferFunction\"\n ) {\n bounds.push(trackable.value.window);\n } else if (control.type === \"propertyInvlerp\") {\n const { dataType, range, window } =\n trackable.value as PropertyInvlerpParameters;\n bounds.push(window ?? range ?? defaultDataTypeRange[dataType]);\n }\n }\n return bounds;\n }, this);\n this.histogramSpecifications = this.registerDisposer(\n new HistogramSpecifications(\n histogramChannels,\n histogramProperties,\n histogramBounds,\n ),\n );\n }\n\n private handleFragmentMainChanged() {\n const generation = this.fragmentMain.changed.count;\n const dataContextGeneration = this.dataContext.changed.count;\n if (\n generation === this.fragmentMainGeneration &&\n dataContextGeneration === this.dataContextGeneration\n ) {\n return;\n }\n this.fragmentMainGeneration = generation;\n this.dataContextGeneration = dataContextGeneration;\n const dataContext = this.dataContext.value;\n if (dataContext === null) {\n this.parseResult_ = {\n source: \"\",\n code: \"\",\n controls: new Map(),\n errors: [{ line: 0, message: \"Loading\" }],\n };\n this.parseErrors_ = [];\n this.processedFragmentMain_ = \"\";\n this.controls.value = undefined;\n } else {\n const result = (this.parseResult_ = parseShaderUiControls(\n this.fragmentMain.value,\n dataContext,\n ));\n this.parseErrors_ = result.errors;\n this.processedFragmentMain_ = result.code;\n if (result.errors.length === 0) {\n this.controls.value = result.controls;\n }\n }\n this.parseResultChanged.dispatch();\n }\n\n private handleControlsChanged() {\n const generation = this.controls.changed.count;\n if (generation === this.controlsGeneration) {\n return;\n }\n this.controlsGeneration = generation;\n const controls = this.controls.value;\n if (controls === undefined) {\n return;\n }\n let changed = false;\n const { state_, unparsedJson } = this;\n // Remove values in `state` not in `controls`.\n for (const [name, controlState] of state_) {\n const control = controls.get(name);\n if (control === undefined) {\n controlState.trackable.changed.remove(this.changed.dispatch);\n state_.delete(name);\n changed = true;\n }\n }\n for (const [name, control] of controls) {\n let controlState = state_.get(name);\n if (\n controlState !== undefined &&\n JSON.stringify(controlState.control) !== JSON.stringify(control)\n ) {\n controlState.trackable.changed.remove(this.changed.dispatch);\n controlState = undefined;\n }\n if (controlState === undefined) {\n const { trackable, getBuilderValue } = getControlTrackable(control);\n controlState = { control, trackable, getBuilderValue };\n controlState.trackable.changed.add(this.changed.dispatch);\n state_.set(name, controlState);\n changed = true;\n }\n if (\n unparsedJson !== undefined &&\n Object.prototype.hasOwnProperty.call(unparsedJson, name)\n ) {\n changed = true;\n try {\n controlState.trackable.restoreState(unparsedJson[name]);\n } catch {\n // Ignore error\n }\n }\n }\n if (unparsedJson !== undefined) {\n changed = true;\n }\n this.unparsedJson = undefined;\n if (changed) {\n this.changed.dispatch();\n }\n }\n\n private state_: ShaderControlMap = new Map();\n\n get state() {\n if (this.controls.changed.count !== this.controlsGeneration) {\n this.handleControlsChanged();\n }\n return this.state_;\n }\n\n get value() {\n return this.state;\n }\n\n private unparsedJson: any = undefined;\n\n restoreState(value: any) {\n if (value === undefined) return;\n const { state } = this;\n verifyObject(value);\n const controls = this.controls.value;\n if (controls === undefined) {\n this.unparsedJson = value;\n this.changed.dispatch();\n return;\n }\n for (const [key, controlState] of state) {\n const { trackable } = controlState;\n trackable.reset();\n if (Object.prototype.hasOwnProperty.call(value, key)) {\n try {\n trackable.restoreState(value[key]);\n } catch {\n // Ignore error\n }\n }\n }\n this.unparsedJson = undefined;\n }\n\n reset() {\n for (const controlState of this.state.values()) {\n controlState.trackable.reset();\n }\n if (this.unparsedJson !== undefined) {\n this.unparsedJson = undefined;\n this.changed.dispatch();\n }\n }\n\n toJSON() {\n const { state } = this;\n const { unparsedJson } = this;\n if (unparsedJson !== undefined) return unparsedJson;\n const obj: any = {};\n let empty = true;\n for (const [key, value] of state) {\n const valueJson = value.trackable.toJSON();\n if (valueJson !== undefined) {\n obj[key] = valueJson;\n empty = false;\n }\n }\n if (empty) return undefined;\n return obj;\n }\n}\n\nfunction setControlInShader(\n gl: GL,\n shader: ShaderProgram,\n name: string,\n control: ShaderUiControl,\n value: any,\n) {\n const uName = uniformName(name);\n const uniform = shader.uniform(uName);\n switch (control.type) {\n case \"slider\":\n switch (control.valueType) {\n case \"int\":\n case \"uint\":\n gl.uniform1i(uniform, value);\n break;\n case \"float\":\n gl.uniform1f(uniform, value);\n }\n break;\n case \"color\":\n gl.uniform3fv(uniform, value);\n break;\n case \"imageInvlerp\":\n enableLerpShaderFunction(shader, uName, control.dataType, value.range);\n break;\n case \"propertyInvlerp\": {\n const { dataType } = value as PropertyInvlerpParameters;\n enableLerpShaderFunction(\n shader,\n uName,\n dataType,\n value.range ?? defaultDataTypeRange[dataType],\n );\n break;\n }\n case \"checkbox\":\n // Value is hard-coded in shader.\n break;\n case \"transferFunction\":\n enableTransferFunctionShader(\n shader,\n uName,\n control.dataType,\n value.sortedControlPoints,\n );\n }\n}\n\nexport function setControlsInShader(\n gl: GL,\n shader: ShaderProgram,\n shaderControlState: ShaderControlState,\n controls: Controls,\n) {\n const { state } = shaderControlState;\n if (shaderControlState.controls.value === controls) {\n // Case when shader doesn't have any errors.\n for (const [name, controlState] of state) {\n setControlInShader(\n gl,\n shader,\n name,\n controlState.control,\n controlState.trackable.value,\n );\n }\n } else {\n // Case when shader does have errors and we are using the fallback shader, which may have a\n // different/incompatible set of controls.\n for (const [name, control] of controls) {\n const controlState = state.get(name);\n const value =\n controlState !== undefined &&\n JSON.stringify(controlState.control) === JSON.stringify(control)\n ? controlState.trackable.value\n : control.default;\n setControlInShader(gl, shader, name, control, value);\n }\n }\n}\n","/**\n * @license\n * Copyright 2018 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { MultiscaleAnnotationSource } from \"#src/annotation/frontend_source.js\";\nimport type {\n AnnotationPropertySpec,\n AnnotationSource,\n} from \"#src/annotation/index.js\";\nimport { propertyTypeDataType } from \"#src/annotation/index.js\";\nimport type { LayerDataSource } from \"#src/layer/layer_data_source.js\";\nimport type {\n ChunkTransformParameters,\n RenderLayerTransformOrError,\n} from \"#src/render_coordinate_transform.js\";\nimport { getChunkTransformParameters } from \"#src/render_coordinate_transform.js\";\nimport { RenderLayerRole } from \"#src/renderlayer.js\";\nimport type { SegmentationDisplayState } from \"#src/segmentation_display_state/frontend.js\";\nimport { TrackableBoolean } from \"#src/trackable_boolean.js\";\nimport type { WatchableValueInterface } from \"#src/trackable_value.js\";\nimport {\n makeCachedLazyDerivedWatchableValue,\n registerNested,\n WatchableValue,\n} from \"#src/trackable_value.js\";\nimport { TrackableRGB } from \"#src/util/color.js\";\nimport type { DataType } from \"#src/util/data_type.js\";\nimport type { Owned } from \"#src/util/disposable.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport type { ValueOrError } from \"#src/util/error.js\";\nimport { makeValueOrError, valueOrThrow } from \"#src/util/error.js\";\nimport { vec3 } from \"#src/util/geom.js\";\nimport { WatchableMap } from \"#src/util/watchable_map.js\";\nimport {\n makeTrackableFragmentMain,\n makeWatchableShaderError,\n} from \"#src/webgl/dynamic_shader.js\";\nimport {\n getFallbackBuilderState,\n parseShaderUiControls,\n ShaderControlState,\n} from \"#src/webgl/shader_ui_controls.js\";\n\nexport class AnnotationHoverState extends WatchableValue<\n | {\n id: string;\n partIndex: number;\n annotationLayerState: AnnotationLayerState;\n }\n | undefined\n> {}\n\n// null means loading\n// undefined means no attached layer\nexport type OptionalSegmentationDisplayState =\n | SegmentationDisplayState\n | null\n | undefined;\n\nexport interface AnnotationRelationshipState {\n segmentationState: WatchableValueInterface;\n showMatches: TrackableBoolean;\n}\n\nexport class WatchableAnnotationRelationshipStates extends WatchableMap<\n string,\n AnnotationRelationshipState\n> {\n constructor() {\n super((context, { showMatches, segmentationState }) => {\n context.registerDisposer(showMatches.changed.add(this.changed.dispatch));\n context.registerDisposer(\n segmentationState.changed.add(this.changed.dispatch),\n );\n context.registerDisposer(\n registerNested((nestedContext, segmentationState) => {\n if (segmentationState == null) return;\n const { segmentationGroupState } = segmentationState;\n nestedContext.registerDisposer(\n segmentationGroupState.changed.add(this.changed.dispatch),\n );\n nestedContext.registerDisposer(\n registerNested((groupContext, groupState) => {\n const { visibleSegments } = groupState;\n let wasEmpty = visibleSegments.size === 0;\n groupContext.registerDisposer(\n visibleSegments.changed.add(() => {\n const isEmpty = visibleSegments.size === 0;\n if (isEmpty !== wasEmpty) {\n wasEmpty = isEmpty;\n this.changed.dispatch();\n }\n }),\n );\n }, segmentationGroupState),\n );\n }, segmentationState),\n );\n });\n }\n\n get(name: string): AnnotationRelationshipState {\n let value = super.get(name);\n if (value === undefined) {\n value = {\n segmentationState: new WatchableValue(undefined),\n showMatches: new TrackableBoolean(false),\n };\n super.set(name, value);\n }\n return value;\n }\n}\n\nconst DEFAULT_FRAGMENT_MAIN = `\nvoid main() {\n setColor(defaultColor());\n}\n`;\n\nexport class AnnotationDisplayState extends RefCounted {\n annotationProperties = new WatchableValue<\n readonly Readonly[] | undefined\n >(undefined);\n shader = makeTrackableFragmentMain(DEFAULT_FRAGMENT_MAIN);\n shaderControls = new ShaderControlState(\n this.shader,\n makeCachedLazyDerivedWatchableValue((annotationProperties) => {\n const properties = new Map();\n if (annotationProperties === undefined) {\n return null;\n }\n for (const property of annotationProperties) {\n const dataType = propertyTypeDataType[property.type];\n if (dataType === undefined) continue;\n properties.set(property.identifier, dataType);\n }\n return { properties };\n }, this.annotationProperties),\n );\n fallbackShaderControls = new WatchableValue(\n getFallbackBuilderState(parseShaderUiControls(DEFAULT_FRAGMENT_MAIN)),\n );\n shaderError = makeWatchableShaderError();\n color = new TrackableRGB(vec3.fromValues(1, 1, 0));\n relationshipStates = this.registerDisposer(\n new WatchableAnnotationRelationshipStates(),\n );\n ignoreNullSegmentFilter = new TrackableBoolean(true);\n swapVisibleSegmentsOnMove = new TrackableBoolean(true);\n disablePicking = new WatchableValue(false);\n displayUnfiltered = makeCachedLazyDerivedWatchableValue(\n (map, ignoreNullSegmentFilter) => {\n for (const state of map.values()) {\n if (state.showMatches.value) {\n if (!ignoreNullSegmentFilter) return false;\n const segmentationState = state.segmentationState.value;\n if (segmentationState != null) {\n if (\n segmentationState.segmentationGroupState.value.visibleSegments\n .size > 0\n ) {\n return false;\n }\n }\n }\n }\n return true;\n },\n this.relationshipStates,\n this.ignoreNullSegmentFilter,\n );\n hoverState = new AnnotationHoverState(undefined);\n}\n\nexport class AnnotationLayerState extends RefCounted {\n transform: WatchableValueInterface;\n localPosition: WatchableValueInterface;\n source: Owned;\n role: RenderLayerRole;\n dataSource: LayerDataSource;\n subsourceId: string;\n subsourceIndex: number;\n displayState: AnnotationDisplayState;\n subsubsourceId?: string;\n\n readonly chunkTransform: WatchableValueInterface<\n ValueOrError\n >;\n\n constructor(options: {\n transform: WatchableValueInterface;\n localPosition: WatchableValueInterface;\n source: Owned;\n displayState: AnnotationDisplayState;\n dataSource: LayerDataSource;\n subsourceId: string;\n subsourceIndex: number;\n subsubsourceId?: string;\n role?: RenderLayerRole;\n }) {\n super();\n const {\n transform,\n localPosition,\n source,\n role = RenderLayerRole.ANNOTATION,\n } = options;\n this.transform = transform;\n this.localPosition = localPosition;\n this.source = this.registerDisposer(source);\n this.role = role;\n this.displayState = options.displayState;\n this.chunkTransform = this.registerDisposer(\n makeCachedLazyDerivedWatchableValue(\n (modelTransform) =>\n makeValueOrError(() =>\n getChunkTransformParameters(valueOrThrow(modelTransform)),\n ),\n this.transform,\n ),\n );\n this.dataSource = options.dataSource;\n this.subsourceId = options.subsourceId;\n this.subsourceIndex = options.subsourceIndex;\n this.subsubsourceId = options.subsubsourceId;\n }\n\n get sourceIndex() {\n const { dataSource } = this;\n return dataSource.layer.dataSources.indexOf(dataSource);\n }\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n validateDisplayDimensionRenderInfoProperty,\n type DisplayDimensionRenderInfo,\n} from \"#src/navigation_state.js\";\nimport { ProjectionParameters } from \"#src/projection_parameters.js\";\nimport { getChunkPositionFromCombinedGlobalLocalPositions } from \"#src/render_coordinate_transform.js\";\nimport { ChunkLayout } from \"#src/sliceview/chunk_layout.js\";\nimport type {\n WatchableValueChangeInterface,\n WatchableValueInterface,\n} from \"#src/trackable_value.js\";\nimport { DATA_TYPE_BYTES, DataType } from \"#src/util/data_type.js\";\nimport type { Disposable } from \"#src/util/disposable.js\";\nimport {\n getFrustrumPlanes,\n getViewFrustrumDepthRange,\n isAABBIntersectingPlane,\n isAABBVisible,\n mat4,\n vec3,\n} from \"#src/util/geom.js\";\nimport * as matrix from \"#src/util/matrix.js\";\nimport * as vector from \"#src/util/vector.js\";\nimport { SharedObject } from \"#src/worker_rpc.js\";\n\nexport { DATA_TYPE_BYTES, DataType };\n\nconst DEBUG_VISIBLE_SOURCES = false;\nconst DEBUG_CHUNK_VISIBILITY = false;\n\nconst tempMat4 = mat4.create();\n\n/**\n * Average cross-sectional area contained within a chunk of the specified size and rotation.\n *\n * This is estimated by taking the total volume of the chunk and dividing it by the total length of\n * the chunk along the z axis.\n */\nexport function estimateSliceAreaPerChunk(\n chunkLayout: ChunkLayout,\n viewMatrix: mat4,\n) {\n // Compute the length of the projection of the chunk along the z axis in view space.\n //\n // Each chunk dimension `i` can independently affect the z projection by the dot product of column\n // `i` of `chunkLayout.transform` and row 2 of `viewMatrix`.\n let viewZProjection = 0;\n let chunkVolume = Math.abs(chunkLayout.detTransform);\n const { transform, size } = chunkLayout;\n for (let i = 0; i < 3; ++i) {\n let sum = 0;\n for (let j = 0; j < 3; ++j) {\n sum += viewMatrix[j * 4 + 2] * transform[4 * i + j];\n }\n const s = size[i];\n viewZProjection += Math.abs(sum) * s;\n chunkVolume *= s;\n }\n return chunkVolume / viewZProjection;\n}\n\nexport interface MultiscaleVolumetricDataRenderLayer {\n localPosition: WatchableValueInterface;\n renderScaleTarget: WatchableValueInterface;\n}\n\nexport interface TransformedSource<\n RLayer extends MultiscaleVolumetricDataRenderLayer = SliceViewRenderLayer,\n Source extends SliceViewChunkSource = SliceViewChunkSource,\n> {\n renderLayer: RLayer;\n\n source: Source;\n\n /**\n * Approximate voxel size in each of the display dimensions.\n */\n effectiveVoxelSize: vec3;\n\n chunkLayout: ChunkLayout;\n\n /**\n * Arrays of length `rank` specifying the clip bounds (in voxels) for dimensions not in\n * `chunkDisplayDimensionIndices` and not channel dimensions. The values for display/channel\n * dimensions are set to -/+infinity.\n */\n nonDisplayLowerClipBound: Float32Array;\n nonDisplayUpperClipBound: Float32Array;\n\n /**\n * Arrays of length `rank` specifying the clip bounds (in voxels) for all dimensions.\n */\n lowerClipBound: Float32Array;\n upperClipBound: Float32Array;\n\n // Lower clip bound (in voxels) in the \"display\" subspace of the chunk coordinate space.\n lowerClipDisplayBound: vec3;\n // Upper clip bound (in voxels) in the \"display\" subspace of the chunk coordinate space.\n upperClipDisplayBound: vec3;\n\n // Lower bound (in chunks) within the \"display\" subspace of the chunk coordinate space.\n lowerChunkDisplayBound: vec3;\n // Upper bound (in chunks) within the \"display\" subspace of the chunk coordinate space.\n upperChunkDisplayBound: vec3;\n\n /**\n * Dimensions of the chunk corresponding to the 3 display dimensions of the slice view.\n */\n chunkDisplayDimensionIndices: number[];\n\n /**\n * Rank of \"layer\" space and the \"chunk clip\" space, which is >= rank of chunk space.\n */\n layerRank: number;\n\n /**\n * Transform from dimensions of layer space to dimensions of chunk space.\n *\n * Matrix has dimensions `(globalRank + localRank + 1) * layerRank`.\n *\n * Input space is `[global dimensions, local dimensions]`. Output space is the \"chunk clip\"\n * coordinate space, in units of voxels.\n *\n */\n combinedGlobalLocalToChunkTransform: Float32Array;\n\n /**\n * Transform from non-display dimensions of layer space to non-display dimensions of chunk space.\n *\n * Same as `combinedGlobalLocalToChunkTransform`, except that rows corresponding to \"display\"\n * chunk dimensions are all 0.\n *\n * Matrix has dimensions `(globalRank + localRank + 1) * layerRank`.\n *\n * Input space is `[global dimensions, local dimensions]`. Output space is the \"chunk clip\"\n * coordinate space, in units of voxels.\n */\n fixedLayerToChunkTransform: Float32Array;\n\n /**\n * When `computeVisibleChunks` invokes the `addChunk` callback, this is set to the position of the\n * chunk.\n */\n curPositionInChunks: Float32Array;\n\n fixedPositionWithinChunk: Uint32Array;\n}\n\nexport interface SliceViewRenderLayer {\n /**\n * Current position of non-global layer dimensions.\n */\n localPosition: WatchableValueInterface;\n renderScaleTarget: WatchableValueInterface;\n\n filterVisibleSources(\n sliceView: SliceViewBase,\n sources: readonly TransformedSource[],\n ): Iterable;\n}\n\nfunction updateFixedCurPositionInChunks<\n RLayer extends MultiscaleVolumetricDataRenderLayer,\n>(\n tsource: TransformedSource,\n globalPosition: Float32Array,\n localPosition: Float32Array,\n): boolean {\n const { curPositionInChunks, fixedPositionWithinChunk } = tsource;\n const { nonDisplayLowerClipBound, nonDisplayUpperClipBound } = tsource;\n const { rank, chunkDataSize } = tsource.source.spec;\n if (\n !getChunkPositionFromCombinedGlobalLocalPositions(\n curPositionInChunks,\n globalPosition,\n localPosition,\n tsource.layerRank,\n tsource.fixedLayerToChunkTransform,\n )\n ) {\n return false;\n }\n for (let chunkDim = 0; chunkDim < rank; ++chunkDim) {\n const x = curPositionInChunks[chunkDim];\n if (\n x < nonDisplayLowerClipBound[chunkDim] ||\n x >= nonDisplayUpperClipBound[chunkDim]\n ) {\n if (DEBUG_VISIBLE_SOURCES) {\n console.log(\n \"excluding source\",\n tsource,\n `because of chunkDim=${chunkDim}, sum=${x}`,\n nonDisplayLowerClipBound,\n nonDisplayUpperClipBound,\n tsource.fixedLayerToChunkTransform,\n );\n }\n return false;\n }\n const chunkSize = chunkDataSize[chunkDim];\n const chunk = (curPositionInChunks[chunkDim] = Math.floor(x / chunkSize));\n fixedPositionWithinChunk[chunkDim] = x - chunk * chunkSize;\n }\n return true;\n}\n\nfunction pickBestAlternativeSource<\n RLayer extends MultiscaleVolumetricDataRenderLayer,\n Source extends SliceViewChunkSource,\n Transformed extends TransformedSource,\n>(viewMatrix: mat4, alternatives: Transformed[]) {\n const numAlternatives = alternatives.length;\n let bestAlternativeIndex = 0;\n if (DEBUG_VISIBLE_SOURCES) {\n console.log(alternatives);\n }\n if (numAlternatives > 1) {\n let bestSliceArea = 0;\n for (\n let alternativeIndex = 0;\n alternativeIndex < numAlternatives;\n ++alternativeIndex\n ) {\n const alternative = alternatives[alternativeIndex];\n const { chunkLayout } = alternative;\n const sliceArea = estimateSliceAreaPerChunk(chunkLayout, viewMatrix);\n if (DEBUG_VISIBLE_SOURCES) {\n console.log(\n `chunksize = ${chunkLayout.size}, sliceArea = ${sliceArea}`,\n );\n }\n if (sliceArea > bestSliceArea) {\n bestSliceArea = sliceArea;\n bestAlternativeIndex = alternativeIndex;\n }\n }\n }\n return bestAlternativeIndex;\n}\n\nexport interface VisibleLayerSources<\n RLayer extends MultiscaleVolumetricDataRenderLayer,\n Source extends SliceViewChunkSource,\n Transformed extends TransformedSource,\n> {\n allSources: Transformed[][];\n visibleSources: Transformed[];\n displayDimensionRenderInfo: DisplayDimensionRenderInfo;\n}\n\nconst tempChunkLayout = new ChunkLayout(vec3.create(), mat4.create(), 0);\n\nexport class SliceViewProjectionParameters extends ProjectionParameters {\n /**\n * Normal vector of cross section in (non-isotropic) global voxel coordinates.\n */\n viewportNormalInGlobalCoordinates = vec3.create();\n\n /**\n * Normal vector of cross section in isotropic global canonical voxel coordinates.\n */\n viewportNormalInCanonicalCoordinates = vec3.create();\n\n centerDataPosition = vec3.create();\n\n /**\n * Size in physical units of a single pixel.\n */\n pixelSize = 0;\n}\n\nfunction visibleSourcesInvalidated(\n oldValue: SliceViewProjectionParameters,\n newValue: SliceViewProjectionParameters,\n) {\n if (\n oldValue.displayDimensionRenderInfo !== newValue.displayDimensionRenderInfo\n ) {\n return true;\n }\n if (oldValue.pixelSize !== newValue.pixelSize) return true;\n const { viewMatrix: oldViewMatrix } = oldValue;\n const { viewMatrix: newViewMatrix } = newValue;\n for (let i = 0; i < 12; ++i) {\n if (oldViewMatrix[i] !== newViewMatrix[i]) return true;\n }\n return false;\n}\n\nexport class SliceViewBase<\n Source extends SliceViewChunkSource = SliceViewChunkSource,\n RLayer extends SliceViewRenderLayer = SliceViewRenderLayer,\n Transformed extends TransformedSource = TransformedSource<\n RLayer,\n Source\n >,\n> extends SharedObject {\n visibleLayers = new Map<\n RLayer,\n VisibleLayerSources\n >();\n visibleSourcesStale = true;\n\n constructor(\n public projectionParameters: WatchableValueChangeInterface,\n ) {\n super();\n this.registerDisposer(\n projectionParameters.changed.add((oldValue, newValue) => {\n if (visibleSourcesInvalidated(oldValue, newValue)) {\n this.invalidateVisibleSources();\n }\n this.invalidateVisibleChunks();\n }),\n );\n }\n\n invalidateVisibleSources() {\n this.visibleSourcesStale = true;\n }\n\n invalidateVisibleChunks() {}\n\n /**\n * Computes the list of sources to use for each visible layer, based on the\n * current pixelSize.\n */\n updateVisibleSources() {\n if (!this.visibleSourcesStale) {\n return;\n }\n this.visibleSourcesStale = false;\n const curDisplayDimensionRenderInfo =\n this.projectionParameters.value.displayDimensionRenderInfo;\n\n const { visibleLayers } = this;\n for (const [renderLayer, visibleLayerSources] of visibleLayers) {\n const { allSources, visibleSources } = visibleLayerSources;\n visibleSources.length = 0;\n if (\n allSources.length === 0 ||\n !validateDisplayDimensionRenderInfoProperty(\n visibleLayerSources,\n curDisplayDimensionRenderInfo,\n )\n ) {\n continue;\n }\n const preferredOrientationIndex = pickBestAlternativeSource(\n this.projectionParameters.value.viewMatrix,\n allSources.map((x) => x[0]),\n );\n\n const sources = allSources[preferredOrientationIndex];\n\n for (const source of renderLayer.filterVisibleSources(this, sources)) {\n visibleSources.push(source as Transformed);\n }\n // Reverse visibleSources list since we added sources from coarsest to finest resolution, but\n // we want them ordered from finest to coarsest.\n visibleSources.reverse();\n if (DEBUG_VISIBLE_SOURCES) {\n console.log(\"visible sources chosen\", visibleSources);\n }\n }\n }\n}\n\n/**\n * By default, choose a chunk size with at most 2^18 = 262144 voxels.\n */\nexport const DEFAULT_MAX_VOXELS_PER_CHUNK_LOG2 = 18;\n\n/**\n * Specifies common options for getNearIsotropicBlockSize and getTwoDimensionalBlockSize.\n */\nexport interface BaseChunkLayoutOptions {\n /**\n * Number of chunk dimensions.\n */\n rank: number;\n\n /**\n * This, together with upperVoxelBound, specifies the total volume dimensions, which serves as a\n * bound on the maximum chunk size. If not specified, defaults to a zero vector.\n */\n lowerVoxelBound?: Float32Array;\n\n /**\n * Upper voxel bound. If not specified, the total volume dimensions are not used to bound the\n * chunk size.\n */\n upperVoxelBound?: Float32Array;\n\n /**\n * Base 2 logarithm of the maximum number of voxels per chunk. Defaults to\n * DEFAULT_MAX_VOXELS_PER_CHUNK_LOG2.\n */\n maxVoxelsPerChunkLog2?: number;\n\n /**\n * Linear (not affine) transformation matrix with `rank` columns and `displayRank` rows in\n * column-major order. Specifies the transformation from chunk space to an isotropic \"camera view\n * space\". Note that only relative scales of input dimensions are relevant, any rotations applied\n * are irrelevant.\n */\n chunkToViewTransform: Float32Array;\n displayRank: number;\n\n minBlockSize?: Uint32Array;\n maxBlockSize?: Uint32Array;\n}\n\nexport type GetNearIsotropicBlockSizeOptions = BaseChunkLayoutOptions;\n\n/**\n * Determines a near-isotropic (in camera view space) block size. All dimensions will be\n * powers of 2, and will not exceed upperVoxelBound - lowerVoxelBound. The total number of voxels\n * will not exceed maxVoxelsPerChunkLog2.\n */\nexport function getNearIsotropicBlockSize(\n options: GetNearIsotropicBlockSizeOptions,\n): Uint32Array {\n let {\n rank,\n upperVoxelBound,\n maxVoxelsPerChunkLog2 = DEFAULT_MAX_VOXELS_PER_CHUNK_LOG2,\n chunkToViewTransform,\n displayRank,\n minBlockSize,\n maxBlockSize,\n } = options;\n\n const { lowerVoxelBound = new Uint32Array(rank) } = options;\n\n // Adjust voxelSize by effective scaling factor.\n const effectiveVoxelSize = new Float32Array(rank);\n for (let chunkDim = 0; chunkDim < rank; ++chunkDim) {\n let factor = 0;\n for (let displayDim = 0; displayDim < displayRank; ++displayDim) {\n const c = chunkToViewTransform[chunkDim * displayRank + displayDim];\n factor += c * c;\n }\n effectiveVoxelSize[chunkDim] = Math.sqrt(factor);\n }\n\n const chunkDataSize = new Uint32Array(rank);\n if (minBlockSize !== undefined) {\n chunkDataSize.set(minBlockSize);\n } else {\n chunkDataSize.fill(1);\n }\n const chunkDataSizeUpperBound = new Array(rank);\n for (let chunkDim = 0; chunkDim < rank; ++chunkDim) {\n let bound = Number.POSITIVE_INFINITY;\n if (effectiveVoxelSize[chunkDim] === 0) {\n bound = chunkDataSize[chunkDim];\n } else {\n if (upperVoxelBound !== undefined) {\n bound =\n 2 **\n Math.floor(\n Math.log2(upperVoxelBound[chunkDim] - lowerVoxelBound[chunkDim]),\n );\n }\n if (maxBlockSize !== undefined) {\n bound = Math.min(bound, maxBlockSize[chunkDim]);\n }\n }\n chunkDataSizeUpperBound[chunkDim] = bound;\n }\n\n // Determine the dimension in which chunkDataSize should be increased. This is the smallest\n // dimension (in nanometers) that is < maxChunkDataSize (in voxels).\n //\n // Returns -1 if there is no such dimension.\n function findNextDimension() {\n let minSize = Infinity;\n let minDimension = -1;\n for (let chunkDim = 0; chunkDim < rank; ++chunkDim) {\n if (chunkDataSize[chunkDim] >= chunkDataSizeUpperBound[chunkDim]) {\n continue;\n }\n const size = chunkDataSize[chunkDim] * effectiveVoxelSize[chunkDim];\n if (size < minSize) {\n minSize = size;\n minDimension = chunkDim;\n }\n }\n return minDimension;\n }\n\n maxVoxelsPerChunkLog2 -= Math.log2(vector.prod(chunkDataSize));\n for (let i = 0; i < maxVoxelsPerChunkLog2; ++i) {\n const nextDim = findNextDimension();\n if (nextDim === -1) {\n break;\n }\n chunkDataSize[nextDim] *= 2;\n }\n return chunkDataSize;\n}\n\n/**\n * Returns an array of [xy, yz, xz] 2-dimensional block sizes, where [x, y, z] refer to the view\n * dimensions.\n */\nexport function getTwoDimensionalBlockSizes(options: BaseChunkLayoutOptions) {\n const chunkDataSizes: Uint32Array[] = [];\n const { displayRank, chunkToViewTransform, rank } = options;\n if (displayRank > 3) {\n throw new Error(\"Unsupported view transform\");\n }\n if (displayRank < 3) {\n return [getNearIsotropicBlockSize(options)];\n }\n for (let i = 0; i < 3; ++i) {\n const excludedDim = (i + 2) % 3;\n const restrictedTransform = new Float32Array(chunkToViewTransform);\n for (let j = 0; j < rank; ++j) {\n restrictedTransform[j * displayRank + excludedDim] = 0;\n }\n chunkDataSizes[i] = getNearIsotropicBlockSize({\n ...options,\n chunkToViewTransform: restrictedTransform,\n });\n }\n return chunkDataSizes;\n}\n\nexport enum ChunkLayoutPreference {\n /**\n * Indicates that isotropic chunks are desired.\n */\n ISOTROPIC = 0,\n\n /**\n * Indicates that 2-D chunks are desired.\n */\n FLAT = 1,\n}\n\nexport interface SliceViewSourceOptions {\n /**\n * Transform from the multiscale source coordinate space to a \"view\" coordinate space that\n * reflects the relative scales. This is a *linear* (not affine) transformation matrix with\n * `rank` columns and `displayRank` rows in column-major order, where `rank` is the rank of the\n * multiscale source.\n */\n multiscaleToViewTransform: Float32Array;\n displayRank: number;\n modelChannelDimensionIndices: readonly number[];\n}\n\nexport function getCombinedTransform(\n rank: number,\n bToC: Float32Array,\n aToB: Float32Array | undefined,\n) {\n if (aToB === undefined) {\n return bToC;\n }\n return matrix.multiply(\n new Float32Array((rank + 1) * (rank + 1)),\n rank + 1,\n bToC,\n rank + 1,\n aToB,\n rank + 1,\n rank + 1,\n rank + 1,\n rank + 1,\n );\n}\n\n/**\n * Specifies parameters for getChunkDataSizes.\n */\nexport interface ChunkLayoutOptions {\n /**\n * Chunk sizes in voxels.\n */\n chunkDataSizes?: Uint32Array[];\n\n /**\n * Preferred chunk layout, which determines chunk sizes to use if chunkDataSizes is not\n * specified.\n */\n chunkLayoutPreference?: ChunkLayoutPreference;\n}\n\nexport function getChunkDataSizes(\n options: ChunkLayoutOptions & BaseChunkLayoutOptions,\n) {\n if (options.chunkDataSizes !== undefined) {\n return options.chunkDataSizes;\n }\n const { chunkLayoutPreference = ChunkLayoutPreference.ISOTROPIC } = options;\n switch (chunkLayoutPreference) {\n case ChunkLayoutPreference.ISOTROPIC:\n return [getNearIsotropicBlockSize(options)];\n case ChunkLayoutPreference.FLAT:\n return getTwoDimensionalBlockSizes(options);\n }\n}\n\n/**\n * Generic specification for SliceView chunks specifying a layout and voxel size.\n */\nexport interface SliceViewChunkSpecification<\n ChunkDataSize extends Uint32Array | Float32Array = Uint32Array | Float32Array,\n> {\n rank: number;\n\n /**\n * Size of chunk in voxels.\n */\n chunkDataSize: ChunkDataSize;\n\n /**\n * All valid chunks are in the range [lowerChunkBound, upperChunkBound).\n *\n * These are specified in units of chunks (not voxels).\n */\n lowerChunkBound: Float32Array;\n upperChunkBound: Float32Array;\n\n lowerVoxelBound: Float32Array;\n upperVoxelBound: Float32Array;\n}\n\nexport function makeSliceViewChunkSpecification<\n ChunkDataSize extends Uint32Array | Float32Array,\n>(\n options: SliceViewChunkSpecificationOptions,\n): SliceViewChunkSpecification {\n const { rank, chunkDataSize, upperVoxelBound } = options;\n const { lowerVoxelBound = new Float32Array(rank) } = options;\n const lowerChunkBound = new Float32Array(rank);\n const upperChunkBound = new Float32Array(rank);\n for (let i = 0; i < rank; ++i) {\n lowerChunkBound[i] = Math.floor(lowerVoxelBound[i] / chunkDataSize[i]);\n upperChunkBound[i] = Math.floor(\n (upperVoxelBound[i] - 1) / chunkDataSize[i] + 1,\n );\n }\n return {\n rank,\n chunkDataSize,\n lowerChunkBound,\n upperChunkBound,\n lowerVoxelBound,\n upperVoxelBound,\n };\n}\n\nexport function* filterVisibleSources(\n sliceView: SliceViewBase,\n renderLayer: SliceViewRenderLayer,\n sources: readonly TransformedSource[],\n): Iterable {\n // Increase pixel size by a small margin.\n const pixelSize = sliceView.projectionParameters.value.pixelSize * 1.1;\n // At the smallest scale, all alternative sources must have the same voxel size, which is\n // considered to be the base voxel size.\n const smallestVoxelSize = sources[0].effectiveVoxelSize;\n\n const renderScaleTarget = renderLayer.renderScaleTarget.value;\n\n /**\n * Determines whether we should continue to look for a finer-resolution source *after* one\n * with the specified voxelSize.\n */\n const canImproveOnVoxelSize = (voxelSize: vec3) => {\n const targetSize = pixelSize * renderScaleTarget;\n for (let i = 0; i < 3; ++i) {\n const size = voxelSize[i];\n // If size <= pixelSize, no need for improvement.\n // If size === smallestVoxelSize, also no need for improvement.\n if (size > targetSize && size > 1.01 * smallestVoxelSize[i]) {\n return true;\n }\n }\n return false;\n };\n\n const improvesOnPrevVoxelSize = (voxelSize: vec3, prevVoxelSize: vec3) => {\n const targetSize = pixelSize * renderScaleTarget;\n for (let i = 0; i < 3; ++i) {\n const size = voxelSize[i];\n const prevSize = prevVoxelSize[i];\n if (\n Math.abs(targetSize - size) < Math.abs(targetSize - prevSize) &&\n size < 1.01 * prevSize\n ) {\n return true;\n }\n }\n return false;\n };\n let scaleIndex = sources.length - 1;\n let prevVoxelSize: vec3 | undefined;\n while (true) {\n const transformedSource = sources[scaleIndex];\n if (\n prevVoxelSize !== undefined &&\n !improvesOnPrevVoxelSize(\n transformedSource.effectiveVoxelSize,\n prevVoxelSize,\n )\n ) {\n break;\n }\n yield transformedSource;\n\n if (\n scaleIndex === 0 ||\n !canImproveOnVoxelSize(transformedSource.effectiveVoxelSize)\n ) {\n break;\n }\n prevVoxelSize = transformedSource.effectiveVoxelSize;\n --scaleIndex;\n }\n}\n\n/**\n * Common parameters for SliceView Chunks.\n */\nexport interface SliceViewChunkSpecificationBaseOptions {\n rank: number;\n\n /**\n * If not specified, defaults to an all-zero vector. This determines lowerChunkBound. If this is\n * not a multiple of chunkDataSize, then voxels at lower positions may still be requested.\n */\n lowerVoxelBound?: Float32Array;\n\n /**\n * Exclusive upper bound in \"chunk\" coordinate space, in voxels. This determines upperChunkBound.\n */\n upperVoxelBound: Float32Array;\n}\n\nexport interface SliceViewChunkSpecificationOptions<\n ChunkDataSize extends Uint32Array | Float32Array = Uint32Array | Float32Array,\n> extends SliceViewChunkSpecificationBaseOptions {\n chunkDataSize: ChunkDataSize;\n}\n\nexport interface SliceViewChunkSource<\n Spec extends SliceViewChunkSpecification = SliceViewChunkSpecification,\n> extends Disposable {\n spec: Spec;\n}\n\nexport const SLICEVIEW_RPC_ID = \"SliceView\";\nexport const SLICEVIEW_RENDERLAYER_RPC_ID = \"sliceview/RenderLayer\";\nexport const SLICEVIEW_ADD_VISIBLE_LAYER_RPC_ID = \"SliceView.addVisibleLayer\";\nexport const SLICEVIEW_REMOVE_VISIBLE_LAYER_RPC_ID =\n \"SliceView.removeVisibleLayer\";\nexport const SLICEVIEW_REQUEST_CHUNK_RPC_ID = \"ChunkManager.requestChunk\";\n\nconst tempVisibleVolumetricChunkLower = new Float32Array(3);\nconst tempVisibleVolumetricChunkUpper = new Float32Array(3);\nconst tempVisibleVolumetricModelViewProjection = mat4.create();\nconst tempVisibleVolumetricClippingPlanes = new Float32Array(24);\n\nfunction forEachVolumetricChunkWithinFrustrum<\n RLayer extends MultiscaleVolumetricDataRenderLayer,\n>(\n clippingPlanes: Float32Array,\n transformedSource: TransformedSource,\n callback: (positionInChunks: vec3, clippingPlanes: Float32Array) => void,\n predicate: (\n xLower: number,\n yLower: number,\n zLower: number,\n xUpper: number,\n yUpper: number,\n zUpper: number,\n clippingPlanes: Float32Array,\n ) => boolean,\n) {\n const lower = tempVisibleVolumetricChunkLower;\n const upper = tempVisibleVolumetricChunkUpper;\n const { lowerChunkDisplayBound, upperChunkDisplayBound } = transformedSource;\n for (let i = 0; i < 3; ++i) {\n lower[i] = Math.max(lower[i], lowerChunkDisplayBound[i]);\n upper[i] = Math.min(upper[i], upperChunkDisplayBound[i]);\n }\n const { curPositionInChunks, chunkDisplayDimensionIndices } =\n transformedSource;\n\n function recurse() {\n if (\n !predicate(\n lower[0],\n lower[1],\n lower[2],\n upper[0],\n upper[1],\n upper[2],\n clippingPlanes,\n )\n ) {\n return;\n }\n\n let splitDim = 0;\n let splitSize = Math.max(0, upper[0] - lower[0]);\n let volume = splitSize;\n for (let i = 1; i < 3; ++i) {\n const size = Math.max(0, upper[i] - lower[i]);\n volume *= size;\n if (size > splitSize) {\n splitSize = size;\n splitDim = i;\n }\n }\n if (volume === 0) return;\n if (volume === 1) {\n curPositionInChunks[chunkDisplayDimensionIndices[0]] = lower[0];\n curPositionInChunks[chunkDisplayDimensionIndices[1]] = lower[1];\n curPositionInChunks[chunkDisplayDimensionIndices[2]] = lower[2];\n callback(lower as vec3, clippingPlanes);\n return;\n }\n const prevLower = lower[splitDim];\n const prevUpper = upper[splitDim];\n const splitPoint = Math.floor(0.5 * (prevLower + prevUpper));\n upper[splitDim] = splitPoint;\n recurse();\n upper[splitDim] = prevUpper;\n lower[splitDim] = splitPoint;\n recurse();\n lower[splitDim] = prevLower;\n }\n recurse();\n}\n\nexport function forEachVisibleVolumetricChunk<\n RLayer extends MultiscaleVolumetricDataRenderLayer,\n>(\n projectionParameters: ProjectionParameters,\n localPosition: Float32Array,\n transformedSource: TransformedSource,\n callback: (positionInChunks: vec3, clippingPlanes: Float32Array) => void,\n) {\n if (\n !updateFixedCurPositionInChunks(\n transformedSource,\n projectionParameters.globalPosition,\n localPosition,\n )\n ) {\n return;\n }\n const { size: chunkSize } = transformedSource.chunkLayout;\n const modelViewProjection = mat4.multiply(\n tempVisibleVolumetricModelViewProjection,\n projectionParameters.viewProjectionMat,\n transformedSource.chunkLayout.transform,\n );\n for (let i = 0; i < 3; ++i) {\n const s = chunkSize[i];\n for (let j = 0; j < 4; ++j) {\n modelViewProjection[4 * i + j] *= s;\n }\n }\n\n const clippingPlanes = tempVisibleVolumetricClippingPlanes;\n getFrustrumPlanes(clippingPlanes, modelViewProjection);\n const lower = tempVisibleVolumetricChunkLower;\n const upper = tempVisibleVolumetricChunkUpper;\n lower.fill(Number.NEGATIVE_INFINITY);\n upper.fill(Number.POSITIVE_INFINITY);\n forEachVolumetricChunkWithinFrustrum(\n clippingPlanes,\n transformedSource,\n callback,\n isAABBVisible,\n );\n}\n\nexport function forEachPlaneIntersectingVolumetricChunk<\n RLayer extends MultiscaleVolumetricDataRenderLayer,\n>(\n projectionParameters: ProjectionParameters,\n localPosition: Float32Array,\n transformedSource: TransformedSource,\n chunkLayout: ChunkLayout,\n callback: (positionInChunks: vec3) => void,\n) {\n if (\n !updateFixedCurPositionInChunks(\n transformedSource,\n projectionParameters.globalPosition,\n localPosition,\n )\n ) {\n return;\n }\n const { size: chunkSize } = chunkLayout;\n const modelViewProjection = mat4.multiply(\n tempVisibleVolumetricModelViewProjection,\n projectionParameters.viewProjectionMat,\n chunkLayout.transform,\n );\n for (let i = 0; i < 3; ++i) {\n const s = chunkSize[i];\n for (let j = 0; j < 4; ++j) {\n modelViewProjection[4 * i + j] *= s;\n }\n }\n\n const invModelViewProjection = tempMat4;\n mat4.invert(invModelViewProjection, modelViewProjection);\n const lower = tempVisibleVolumetricChunkLower;\n const upper = tempVisibleVolumetricChunkUpper;\n const epsilon = 1e-3;\n for (let i = 0; i < 3; ++i) {\n // Add small offset of `epsilon` voxels to bias towards the higher coordinate if very close to a\n // voxel boundary.\n const c = invModelViewProjection[12 + i] + epsilon / chunkSize[i];\n const xCoeff = Math.abs(invModelViewProjection[i]);\n const yCoeff = Math.abs(invModelViewProjection[4 + i]);\n lower[i] = Math.floor(c - xCoeff - yCoeff);\n upper[i] = Math.floor(c + xCoeff + yCoeff + 1);\n }\n\n const clippingPlanes = tempVisibleVolumetricClippingPlanes;\n for (let i = 0; i < 3; ++i) {\n const xCoeff = modelViewProjection[4 * i];\n const yCoeff = modelViewProjection[4 * i + 1];\n const zCoeff = modelViewProjection[4 * i + 2];\n clippingPlanes[i] = xCoeff;\n clippingPlanes[4 + i] = -xCoeff;\n clippingPlanes[8 + i] = +yCoeff;\n clippingPlanes[12 + i] = -yCoeff;\n clippingPlanes[16 + i] = +zCoeff;\n clippingPlanes[20 + i] = -zCoeff;\n }\n {\n const i = 3;\n const xCoeff = modelViewProjection[4 * i];\n const yCoeff = modelViewProjection[4 * i + 1];\n const zCoeff = modelViewProjection[4 * i + 2];\n clippingPlanes[i] = 1 + xCoeff;\n clippingPlanes[4 + i] = 1 - xCoeff;\n clippingPlanes[8 + i] = 1 + yCoeff;\n clippingPlanes[12 + i] = 1 - yCoeff;\n clippingPlanes[16 + i] = zCoeff;\n clippingPlanes[20 + i] = -zCoeff;\n }\n if (DEBUG_CHUNK_VISIBILITY) {\n console.log(\"clippingPlanes\", clippingPlanes);\n console.log(\"modelViewProjection\", modelViewProjection.join(\",\"));\n console.log(`lower=${lower.join(\",\")}, upper=${upper.join(\",\")}`);\n }\n forEachVolumetricChunkWithinFrustrum(\n clippingPlanes,\n transformedSource,\n callback,\n isAABBIntersectingPlane,\n );\n}\n\n/**\n * For chunk layouts with finiteRank < 3, returns an adjusted chunk layout where chunk 0 in each\n * non-finite dimension is guaranteed to cover the viewport.\n */\nexport function getNormalizedChunkLayout(\n projectionParameters: ProjectionParameters,\n chunkLayout: ChunkLayout,\n): ChunkLayout {\n const { finiteRank } = chunkLayout;\n if (finiteRank === 3) return chunkLayout;\n tempChunkLayout.finiteRank = finiteRank;\n vec3.copy(tempChunkLayout.size, chunkLayout.size);\n const transform = mat4.copy(tempChunkLayout.transform, chunkLayout.transform);\n const invTransform = mat4.copy(\n tempChunkLayout.invTransform,\n chunkLayout.invTransform,\n );\n tempChunkLayout.detTransform = chunkLayout.detTransform;\n const { invViewMatrix, width, height } = projectionParameters;\n const depth = getViewFrustrumDepthRange(projectionParameters.projectionMat);\n for (let chunkRenderDim = finiteRank; chunkRenderDim < 3; ++chunkRenderDim) {\n // we want to ensure chunk [0] fully covers the viewport\n const offset = invViewMatrix[12 + chunkRenderDim];\n let lower = offset;\n let upper = offset;\n const xc = Math.abs(invViewMatrix[chunkRenderDim] * width);\n lower -= xc;\n upper += xc;\n const yc = Math.abs(invViewMatrix[chunkRenderDim + 4] * height);\n lower -= yc;\n upper += yc;\n const zc = Math.abs(invViewMatrix[chunkRenderDim + 8] * depth);\n lower -= zc;\n upper += zc;\n const scaleFactor = Math.max(1, upper - lower);\n transform[12 + chunkRenderDim] = lower;\n transform[5 * chunkRenderDim] = scaleFactor;\n }\n mat4.invert(invTransform, transform);\n return tempChunkLayout;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ProjectionParameters } from \"#src/projection_parameters.js\";\nimport type {\n MultiscaleVolumetricDataRenderLayer,\n SliceViewChunkSource,\n SliceViewChunkSpecification,\n TransformedSource,\n} from \"#src/sliceview/base.js\";\nimport { forEachVisibleVolumetricChunk } from \"#src/sliceview/base.js\";\nimport {\n getViewFrustrumVolume,\n mat3,\n mat3FromMat4,\n prod3,\n} from \"#src/util/geom.js\";\n\nexport const ANNOTATION_METADATA_CHUNK_SOURCE_RPC_ID =\n \"annotation.MetadataChunkSource\";\nexport const ANNOTATION_GEOMETRY_CHUNK_SOURCE_RPC_ID =\n \"annotation.GeometryChunkSource\";\nexport const ANNOTATION_SUBSET_GEOMETRY_CHUNK_SOURCE_RPC_ID =\n \"annotation.SubsetGeometryChunkSource\";\nexport const ANNOTATION_REFERENCE_ADD_RPC_ID = \"annotation.reference.add\";\nexport const ANNOTATION_REFERENCE_DELETE_RPC_ID = \"annotation.reference.delete\";\nexport const ANNOTATION_COMMIT_UPDATE_RPC_ID = \"annotation.commit\";\nexport const ANNOTATION_COMMIT_UPDATE_RESULT_RPC_ID = \"annotation.commit\";\n\nexport interface AnnotationGeometryChunkSpecification\n extends SliceViewChunkSpecification {\n /**\n * Must equal the `chunkToMultiscaleTransform` in the `SliceViewSingleResolutionSource`.\n */\n chunkToMultiscaleTransform: Float32Array;\n\n /**\n * Specifies the maximum density of annotations provided by this chunk source, as `limit` per the\n * chunk volume. The higher the value, the sooner chunks from this source will be subsampled. To\n * disable subsampling completely, set `limit` to 0.\n */\n limit: number;\n}\n\nexport const ANNOTATION_SPATIALLY_INDEXED_RENDER_LAYER_RPC_ID =\n \"annotation/SpatiallyIndexedRenderLayer\";\nexport const ANNOTATION_PERSPECTIVE_RENDER_LAYER_UPDATE_SOURCES_RPC_ID =\n \"annotation/PerspectiveRenderLayer:updateSources\";\nexport const ANNOTATION_RENDER_LAYER_RPC_ID = \"annotation/RenderLayer\";\nexport const ANNOTATION_RENDER_LAYER_UPDATE_SEGMENTATION_RPC_ID =\n \"annotation/RenderLayer.updateSegmentation\";\n\nconst tempMat3 = mat3.create();\n\nexport function forEachVisibleAnnotationChunk<\n RLayer extends MultiscaleVolumetricDataRenderLayer,\n Source extends SliceViewChunkSource,\n Transformed extends TransformedSource,\n>(\n projectionParameters: ProjectionParameters,\n localPosition: Float32Array,\n renderScaleTarget: number,\n transformedSources: readonly Transformed[],\n beginScale: (source: Transformed, index: number) => void,\n callback: (\n source: Transformed,\n index: number,\n drawFraction: number,\n physicalSpacing: number,\n pixelSpacing: number,\n ) => void,\n) {\n const {\n displayDimensionRenderInfo,\n viewMatrix,\n projectionMat,\n width,\n height,\n } = projectionParameters;\n const { voxelPhysicalScales } = displayDimensionRenderInfo;\n const viewDet = Math.abs(\n mat3.determinant(mat3FromMat4(tempMat3, viewMatrix)),\n );\n const canonicalToPhysicalScale = prod3(voxelPhysicalScales);\n const viewFrustrumVolume =\n (getViewFrustrumVolume(projectionMat) / viewDet) * canonicalToPhysicalScale;\n\n if (transformedSources.length === 0) return;\n const baseSource = transformedSources[0];\n let sourceVolume =\n Math.abs(baseSource.chunkLayout.detTransform) * canonicalToPhysicalScale;\n const { lowerClipDisplayBound, upperClipDisplayBound } = baseSource;\n for (let i = 0; i < 3; ++i) {\n sourceVolume *= upperClipDisplayBound[i] - lowerClipDisplayBound[i];\n }\n\n const effectiveVolume = Math.min(sourceVolume, viewFrustrumVolume);\n const viewportArea = width * height;\n const targetNumAnnotations = viewportArea / renderScaleTarget ** 2;\n const physicalDensityTarget = targetNumAnnotations / effectiveVolume;\n\n // Target density in annotations per physical volume.\n let totalPhysicalDensity = 0;\n for (\n let scaleIndex = transformedSources.length - 1;\n scaleIndex >= 0 && totalPhysicalDensity < physicalDensityTarget;\n --scaleIndex\n ) {\n const transformedSource = transformedSources[scaleIndex];\n const spec = transformedSource.source\n .spec as AnnotationGeometryChunkSpecification;\n const { chunkLayout } = transformedSource;\n const physicalVolume =\n prod3(chunkLayout.size) *\n Math.abs(chunkLayout.detTransform) *\n canonicalToPhysicalScale;\n const { limit, rank } = spec;\n const { nonDisplayLowerClipBound, nonDisplayUpperClipBound } =\n transformedSource;\n let sliceFraction = 1;\n for (let i = 0; i < rank; ++i) {\n const b = nonDisplayUpperClipBound[i] - nonDisplayLowerClipBound[i];\n if (Number.isFinite(b)) sliceFraction /= b;\n }\n const physicalDensity = (limit * sliceFraction) / physicalVolume;\n\n let firstChunk = true;\n const newTotalPhysicalDensity = totalPhysicalDensity + physicalDensity;\n const totalPhysicalSpacing = (1 / newTotalPhysicalDensity) ** (1 / 3);\n const totalPixelSpacing = Math.sqrt(\n viewportArea / (newTotalPhysicalDensity * effectiveVolume),\n );\n const desiredCount =\n ((physicalDensityTarget - totalPhysicalDensity) * physicalVolume) /\n sliceFraction;\n const drawFraction = Math.min(1, desiredCount / spec.limit);\n forEachVisibleVolumetricChunk(\n projectionParameters,\n localPosition,\n transformedSource,\n () => {\n if (firstChunk) {\n beginScale(transformedSource, scaleIndex);\n firstChunk = false;\n }\n callback(\n transformedSource,\n scaleIndex,\n drawFraction,\n totalPhysicalSpacing,\n totalPixelSpacing,\n );\n },\n );\n totalPhysicalDensity = newTotalPhysicalDensity;\n }\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport const glsl_COLORMAPS =\n `vec3 colormapJet(float x) {\n vec3 result;\n result.r = x < 0.89 ? ((x - 0.35) / 0.31) : (1.0 - (x - 0.89) / 0.11 * 0.5);\n result.g = x < 0.64 ? ((x - 0.125) * 4.0) : (1.0 - (x - 0.64) / 0.27);\n result.b = x < 0.34 ? (0.5 + x * 0.5 / 0.11) : (1.0 - (x - 0.34) / 0.31);\n return clamp(result, 0.0, 1.0);\n}\n` +\n /*\n * Adapted from http://www.mrao.cam.ac.uk/~dag/CUBEHELIX/CubeHelix.m\n * which is licensed under http://unlicense.org/\n */\n `vec3 colormapCubehelix(float x) {\n float xclamp = clamp(x, 0.0, 1.0);\n float angle = 2.0 * 3.1415926 * (4.0 / 3.0 + xclamp);\n float amp = xclamp * (1.0 - xclamp) / 2.0;\n vec3 result;\n float cosangle = cos(angle);\n float sinangle = sin(angle);\n result.r = -0.14861 * cosangle + 1.78277 * sinangle;\n result.g = -0.29227 * cosangle + -0.90649 * sinangle;\n result.b = 1.97294 * cosangle;\n result = clamp(xclamp + amp * result, 0.0, 1.0);\n return result;\n}\n`;\n","/**\n * @license\n * Copyright 2018 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n Annotation,\n AnnotationPropertySpec,\n AnnotationType,\n} from \"#src/annotation/index.js\";\nimport {\n annotationTypeHandlers,\n getPropertyOffsets,\n propertyTypeDataType,\n} from \"#src/annotation/index.js\";\nimport type { AnnotationLayer } from \"#src/annotation/renderlayer.js\";\nimport type { PerspectiveViewRenderContext } from \"#src/perspective_view/render_layer.js\";\nimport type { ChunkDisplayTransformParameters } from \"#src/render_coordinate_transform.js\";\nimport type { SliceViewPanelRenderContext } from \"#src/sliceview/renderlayer.js\";\nimport type { WatchableValueInterface } from \"#src/trackable_value.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport type { mat4 } from \"#src/util/geom.js\";\nimport type { Buffer } from \"#src/webgl/buffer.js\";\nimport { glsl_COLORMAPS } from \"#src/webgl/colormaps.js\";\nimport type { GL } from \"#src/webgl/context.js\";\nimport type {\n ParameterizedContextDependentShaderGetter,\n WatchableShaderError,\n} from \"#src/webgl/dynamic_shader.js\";\nimport {\n parameterizedEmitterDependentShaderGetter,\n shaderCodeWithLineDirective,\n} from \"#src/webgl/dynamic_shader.js\";\nimport {\n defineInvlerpShaderFunction,\n enableLerpShaderFunction,\n} from \"#src/webgl/lerp.js\";\nimport type { ShaderModule, ShaderProgram } from \"#src/webgl/shader.js\";\nimport { ShaderBuilder } from \"#src/webgl/shader.js\";\nimport type {\n ShaderControlsBuilderState,\n ShaderControlState,\n} from \"#src/webgl/shader_ui_controls.js\";\nimport {\n addControlsToBuilder,\n setControlsInShader,\n} from \"#src/webgl/shader_ui_controls.js\";\n\nconst DEBUG_HISTOGRAMS = false;\n\nexport type AnnotationShaderGetter = ParameterizedContextDependentShaderGetter<\n ShaderModule,\n ShaderControlsBuilderState\n>;\n\nexport interface AnnotationRenderContext {\n buffer: Buffer;\n annotationLayer: AnnotationLayer;\n renderContext: SliceViewPanelRenderContext | PerspectiveViewRenderContext;\n bufferOffset: number;\n count: number;\n basePickId: number;\n selectedIndex: number;\n modelViewProjectionMatrix: mat4;\n subspaceMatrix: Float32Array;\n renderSubspaceModelMatrix: mat4;\n renderSubspaceInvModelMatrix: mat4;\n modelClipBounds: Float32Array;\n chunkDisplayTransform: ChunkDisplayTransformParameters;\n}\n\ninterface AnnotationPropertyTypeRenderHandler {\n defineShader(builder: ShaderBuilder, identifier: string, rank: number): void;\n}\n\nfunction makeSimplePropertyRenderHandler(\n shaderType: string,\n bind: (\n gl: WebGL2RenderingContext,\n location: number,\n stride: number,\n offset: number,\n ) => void,\n) {\n return {\n defineShader(builder: ShaderBuilder, identifier: string) {\n const propName = `prop_${identifier}`;\n const aName = `a_${propName}`;\n builder.addAttribute(`${shaderType}`, aName);\n builder.addVertexCode(`${shaderType} ${propName}() { return ${aName}; }`);\n builder.addInitializer((shader) => {\n const location = shader.attribute(aName);\n const { gl } = shader;\n shader.vertexShaderInputBinders[propName] =\n location === -1\n ? {\n enable() {},\n disable() {},\n bind() {},\n }\n : {\n enable(divisor: number) {\n gl.enableVertexAttribArray(location);\n gl.vertexAttribDivisor(location, divisor);\n },\n disable() {\n gl.vertexAttribDivisor(location, 0);\n gl.disableVertexAttribArray(location);\n },\n bind(stride: number, offset: number) {\n bind(gl, location, stride, offset);\n },\n };\n });\n },\n };\n}\n\nfunction makeFloatPropertyRenderHandler(\n shaderType: string,\n numComponents: number,\n attributeType: number,\n normalized: boolean,\n) {\n return makeSimplePropertyRenderHandler(\n shaderType,\n (gl, location, stride, offset) => {\n gl.vertexAttribPointer(\n location,\n /*size=*/ numComponents,\n /*type=*/ attributeType,\n /*normalized=*/ normalized,\n stride,\n offset,\n );\n },\n );\n}\n\nfunction makeIntegerPropertyRenderHandler(\n shaderType: string,\n numComponents: number,\n attributeType: number,\n) {\n return makeSimplePropertyRenderHandler(\n shaderType,\n (gl, location, stride, offset) => {\n gl.vertexAttribIPointer(\n location,\n /*size=*/ numComponents,\n /*type=*/ attributeType,\n stride,\n offset,\n );\n },\n );\n}\n\nconst annotationPropertyTypeRenderHandlers: {\n [K in AnnotationPropertySpec[\"type\"]]: AnnotationPropertyTypeRenderHandler;\n} = {\n rgb: makeFloatPropertyRenderHandler(\n \"highp vec3\",\n 3,\n WebGL2RenderingContext.UNSIGNED_BYTE,\n /*normalized=*/ true,\n ),\n rgba: makeFloatPropertyRenderHandler(\n \"highp vec4\",\n 4,\n WebGL2RenderingContext.UNSIGNED_BYTE,\n /*normalized=*/ true,\n ),\n float32: makeFloatPropertyRenderHandler(\n \"highp float\",\n 1,\n WebGL2RenderingContext.FLOAT,\n /*normalized=*/ false,\n ),\n uint32: makeIntegerPropertyRenderHandler(\n \"highp uint\",\n 1,\n WebGL2RenderingContext.UNSIGNED_INT,\n ),\n int32: makeIntegerPropertyRenderHandler(\n \"highp int\",\n 1,\n WebGL2RenderingContext.INT,\n ),\n uint16: makeIntegerPropertyRenderHandler(\n \"highp uint\",\n 1,\n WebGL2RenderingContext.UNSIGNED_SHORT,\n ),\n int16: makeIntegerPropertyRenderHandler(\n \"highp int\",\n 1,\n WebGL2RenderingContext.SHORT,\n ),\n uint8: makeIntegerPropertyRenderHandler(\n \"highp uint\",\n 1,\n WebGL2RenderingContext.UNSIGNED_BYTE,\n ),\n int8: makeIntegerPropertyRenderHandler(\n \"highp int\",\n 1,\n WebGL2RenderingContext.BYTE,\n ),\n};\n\nclass AnnotationRenderHelperBase extends RefCounted {\n readonly serializedBytesPerAnnotation: number;\n readonly serializedGeometryBytesPerAnnotation: number;\n readonly propertyOffsets: { group: number; offset: number }[];\n readonly propertyGroupBytes: number[];\n readonly propertyGroupCumulativeBytes: number[];\n readonly geometryDataStride: number;\n\n constructor(\n public gl: GL,\n public annotationType: AnnotationType,\n public rank: number,\n public properties: readonly Readonly[],\n ) {\n super();\n const serializedGeometryBytesPerAnnotation =\n (this.serializedGeometryBytesPerAnnotation =\n annotationTypeHandlers[annotationType].serializedBytes(rank));\n const {\n offsets,\n serializedBytes: serializedBytesPerAnnotation,\n propertyGroupBytes,\n } = getPropertyOffsets(\n rank,\n serializedGeometryBytesPerAnnotation,\n properties,\n );\n this.serializedBytesPerAnnotation = serializedBytesPerAnnotation;\n this.propertyOffsets = offsets;\n this.propertyGroupBytes = propertyGroupBytes;\n this.geometryDataStride = propertyGroupBytes[0];\n const propertyGroupCumulativeBytes = (this.propertyGroupCumulativeBytes =\n new Array(propertyGroupBytes.length));\n propertyGroupCumulativeBytes[0] = 0;\n for (let i = 1; i < propertyGroupBytes.length; ++i) {\n propertyGroupCumulativeBytes[i] =\n propertyGroupCumulativeBytes[i - 1] + propertyGroupBytes[i - 1];\n }\n }\n\n protected defineProperties(\n builder: ShaderBuilder,\n referencedProperties: number[],\n ) {\n const { properties, rank } = this;\n for (const i of referencedProperties) {\n const property = properties[i];\n const handler = annotationPropertyTypeRenderHandlers[property.type];\n handler.defineShader(builder, property.identifier, rank);\n }\n const { propertyOffsets } = this;\n const { propertyGroupBytes, propertyGroupCumulativeBytes } = this;\n builder.addInitializer((shader) => {\n const binders = referencedProperties.map(\n (i) =>\n shader.vertexShaderInputBinders[`prop_${properties[i].identifier}`],\n );\n const numProperties = binders.length;\n shader.vertexShaderInputBinders.properties = {\n enable(divisor: number) {\n for (let i = 0; i < numProperties; ++i) {\n binders[i].enable(divisor);\n }\n },\n bind(stride: number, offset: number) {\n for (let i = 0; i < numProperties; ++i) {\n const { group, offset: propertyOffset } =\n propertyOffsets[referencedProperties[i]];\n binders[i].bind(\n /*stride=*/ propertyGroupBytes[group],\n /*offset=*/ offset +\n propertyOffset +\n propertyGroupCumulativeBytes[group] * stride,\n );\n }\n },\n disable() {\n for (let i = 0; i < numProperties; ++i) {\n binders[i].disable();\n }\n },\n };\n });\n }\n}\n\nexport abstract class AnnotationRenderHelper extends AnnotationRenderHelperBase {\n pickIdsPerInstance: number;\n targetIsSliceView: boolean;\n\n constructor(\n gl: GL,\n annotationType: AnnotationType,\n rank: number,\n properties: readonly Readonly[],\n public shaderControlState: ShaderControlState,\n public fallbackShaderParameters: WatchableValueInterface,\n public shaderError: WatchableShaderError,\n ) {\n super(gl, annotationType, rank, properties);\n }\n\n getDependentShader(\n memoizeKey: any,\n defineShader: (builder: ShaderBuilder) => void,\n ): AnnotationShaderGetter {\n return parameterizedEmitterDependentShaderGetter(this, this.gl, {\n memoizeKey: {\n t: \"annotation\",\n targetIsSliceView: this.targetIsSliceView,\n type: this.annotationType,\n subType: memoizeKey,\n properties: this.properties,\n rank: this.rank,\n },\n fallbackParameters: this.fallbackShaderParameters,\n parameters: this.shaderControlState.builderState,\n shaderError: this.shaderError,\n defineShader: (\n builder: ShaderBuilder,\n parameters: ShaderControlsBuilderState,\n ) => {\n const { rank, properties } = this;\n const referencedProperties: number[] = [];\n const controlsReferencedProperties = parameters.referencedProperties;\n const processedCode = parameters.parseResult.code;\n for (\n let i = 0, numProperties = properties.length;\n i < numProperties;\n ++i\n ) {\n const property = properties[i];\n const functionName = `prop_${property.identifier}`;\n if (\n !controlsReferencedProperties.includes(property.identifier) &&\n !processedCode.match(new RegExp(`\\\\b${functionName}\\\\b`))\n ) {\n continue;\n }\n referencedProperties.push(i);\n }\n this.defineProperties(builder, referencedProperties);\n builder.addUniform(\"highp vec3\", \"uColor\");\n builder.addUniform(\"highp uint\", \"uSelectedIndex\");\n builder.addVarying(\"highp vec4\", \"vColor\");\n // Transform from model coordinates to the rendered subspace.\n builder.addUniform(\"highp vec3\", \"uSubspaceMatrix\", rank);\n // Transform from the rendered subspace of the model coordinate space to clip coordinates.\n builder.addUniform(\"highp mat4\", \"uModelViewProjection\");\n\n // Specifies center vector and per-dimension scale in model coordinates used for\n // clipping.\n builder.addUniform(\"highp float\", \"uModelClipBounds\", rank * 2);\n builder.addUniform(\"highp uint\", \"uPickID\");\n builder.addVarying(\"highp uint\", \"vPickID\", \"flat\");\n\n builder.addVertexCode(glsl_COLORMAPS);\n\n builder.addVertexCode(`\nvec3 defaultColor() { return uColor; }\nhighp uint getPickBaseOffset() { return uint(gl_InstanceID) * ${this.pickIdsPerInstance}u; }\n`);\n\n builder.addFragmentCode(`\nvoid emitAnnotation(vec4 color) {\n emit(color, vPickID);\n}\n`);\n\n const glsl_getSubspaceClipCoefficient = `\nfloat getSubspaceClipCoefficient(float modelPoint[${this.rank}]) {\n float coefficient = 1.0;\n for (int i = 0; i < ${rank}; ++i) {\n float d = abs(modelPoint[i] - uModelClipBounds[i]) * uModelClipBounds[${rank} + i];\n coefficient *= max(0.0, 1.0 - d);\n }\n return coefficient;\n}\n`;\n builder.addVertexCode(glsl_getSubspaceClipCoefficient);\n builder.addFragmentCode(glsl_getSubspaceClipCoefficient);\n builder.addVertexCode(`\nvec3 projectModelVectorToSubspace(float modelPoint[${this.rank}]) {\n vec3 result = vec3(0.0, 0.0, 0.0);\n for (int i = 0; i < ${rank}; ++i) {\n result += uSubspaceMatrix[i] * modelPoint[i];\n }\n return result;\n}\n\nfloat getMaxEndpointSubspaceClipCoefficient(float modelPointA[${this.rank}], float modelPointB[${this.rank}]) {\n float coefficient = 1.0;\n for (int i = 0; i < ${rank}; ++i) {\n float dA = abs(modelPointA[i] - uModelClipBounds[i]) * uModelClipBounds[${rank} + i];\n float dB = abs(modelPointB[i] - uModelClipBounds[i]) * uModelClipBounds[${rank} + i];\n coefficient *= max(0.0, 1.0 - min(dA, dB));\n }\n return coefficient;\n}\n\nfloat getMaxSubspaceClipCoefficient(float modelPointA[${this.rank}], float modelPointB[${this.rank}]) {\n float coefficient = 1.0;\n for (int i = 0; i < ${rank}; ++i) {\n float a = modelPointA[i];\n float b = modelPointB[i];\n float c = uModelClipBounds[i];\n float x = clamp(c, min(a, b), max(a, b));\n float d = abs(x - c) * uModelClipBounds[${rank} + i];\n coefficient *= max(0.0, 1.0 - d);\n }\n return coefficient;\n}\n\n`);\n addControlsToBuilder(parameters, builder);\n builder.addVertexCode(`\nconst bool PROJECTION_VIEW = ${!this.targetIsSliceView};\nbool ng_discardValue;\n#define discard ng_discard()\nvoid ng_discard() {\n ng_discardValue = true;\n}\nvoid setLineColor(vec4 startColor, vec4 endColor);\nvoid setLineWidth(float width);\n\nvoid setEndpointMarkerColor(vec4 startColor, vec4 endColor);\nvoid setEndpointMarkerBorderColor(vec4 startColor, vec4 endColor);\nvoid setEndpointMarkerSize(float startSize, float endSize);\nvoid setEndpointMarkerBorderWidth(float startSize, float endSize);\n\nvoid setPointMarkerColor(vec4 color);\nvoid setPointMarkerColor(vec3 color) { setPointMarkerColor(vec4(color, 1.0)); }\nvoid setPointMarkerBorderColor(vec4 color);\nvoid setPointMarkerSize(float size);\nvoid setPointMarkerBorderWidth(float size);\nvoid setPointMarkerBorderColor(vec3 color) { setPointMarkerBorderColor(vec4(color, 1.0)); }\n\nvoid setEllipsoidFillColor(vec4 color);\n\nvoid setBoundingBoxBorderColor(vec4 color);\nvoid setBoundingBoxBorderWidth(float size);\nvoid setBoundingBoxFillColor(vec4 color);\n\nvoid setEndpointMarkerColor(vec3 startColor, vec3 endColor) {\n setEndpointMarkerColor(vec4(startColor, 1.0), vec4(endColor, 1.0));\n}\nvoid setEndpointMarkerBorderColor(vec3 startColor, vec3 endColor) {\n setEndpointMarkerBorderColor(vec4(startColor, 1.0), vec4(endColor, 1.0));\n}\nvoid setEndpointMarkerColor(vec3 color) { setEndpointMarkerColor(color, color); }\nvoid setEndpointMarkerColor(vec4 color) { setEndpointMarkerColor(color, color); }\nvoid setEndpointMarkerBorderColor(vec3 color) { setEndpointMarkerBorderColor(color, color); }\nvoid setEndpointMarkerBorderColor(vec4 color) { setEndpointMarkerBorderColor(color, color); }\nvoid setEndpointMarkerSize(float size) { setEndpointMarkerSize(size, size); }\nvoid setEndpointMarkerBorderWidth(float size) { setEndpointMarkerBorderWidth(size, size); }\nvoid setLineColor(vec4 color) { setLineColor(color, color); }\nvoid setLineColor(vec3 color) { setLineColor(vec4(color, 1.0)); }\nvoid setLineColor(vec3 startColor, vec3 endColor) { setLineColor(vec4(startColor, 1.0), vec4(endColor, 1.0)); }\nvoid setColor(vec4 color) {\n setPointMarkerColor(color);\n setLineColor(color);\n setEndpointMarkerColor(color);\n setBoundingBoxBorderColor(color);\n setEllipsoidFillColor(vec4(color.rgb, color.a * (PROJECTION_VIEW ? 1.0 : 0.5)));\n}\nvoid setEllipsoidFillColor(vec3 color) { setEllipsoidFillColor(vec4(color, 1.0)); }\n\nvoid setBoundingBoxFillColor(vec3 color) { setBoundingBoxFillColor(vec4(color, 1.0)); }\nvoid setBoundingBoxBorderColor(vec3 color) { setBoundingBoxBorderColor(vec4(color, 1.0)); }\n\nvoid setColor(vec3 color) { setColor(vec4(color, 1.0)); }\nvoid userMain();\n`);\n for (const [\n annotationType,\n renderHandler,\n ] of annotationTypeRenderHandlers) {\n if (annotationType === this.annotationType) continue;\n renderHandler.defineShaderNoOpSetters(builder);\n }\n defineShader(builder);\n builder.addVertexCode(\n \"\\n#define main userMain\\n\" +\n shaderCodeWithLineDirective(parameters.parseResult.code) +\n \"\\n#undef main\\n\",\n );\n },\n });\n }\n\n setPartIndex(builder: ShaderBuilder, ...partIndexExpressions: string[]) {\n let s = `\nvoid setPartIndex(${partIndexExpressions\n .map((_, i) => `highp uint partIndex${i}`)\n .join()}) {\n highp uint pickID = uPickID;\n highp uint pickBaseOffset = getPickBaseOffset();\n${partIndexExpressions\n .map((_, i) => `highp uint pickOffset${i} = pickBaseOffset + partIndex${i};`)\n .join(\"\\n\")}\n`;\n if (partIndexExpressions.length === 0) {\n s += `\n highp uint pickOffset0 = pickBaseOffset;\n`;\n }\n s += `\n vPickID = pickID + pickOffset0;\n highp uint selectedIndex = uSelectedIndex;\nif (selectedIndex == pickBaseOffset${partIndexExpressions\n .map((_, i) => ` || selectedIndex == pickOffset${i}`)\n .join(\"\")}) {\n vColor = vec4(mix(vColor.rgb, vec3(1.0, 1.0, 1.0), 0.75), vColor.a);\n }\n}\n`;\n builder.addVertexCode(s);\n return `setPartIndex(${partIndexExpressions.join()})`;\n }\n\n get invokeUserMain() {\n return `\nng_discardValue = false;\nuserMain();\nif (ng_discardValue) {\n gl_Position = vec4(2.0, 0.0, 0.0, 1.0);\n return;\n}\n`;\n }\n\n getCrossSectionFadeFactor() {\n if (this.targetIsSliceView) {\n return \"(clamp(1.0 - 2.0 * abs(0.5 - gl_FragCoord.z), 0.0, 1.0))\";\n }\n return \"(1.0)\";\n }\n\n enable(\n shaderGetter: AnnotationShaderGetter,\n context: AnnotationRenderContext,\n callback: (shader: ShaderProgram) => void,\n ) {\n const { shader, parameters } = shaderGetter(context.renderContext.emitter);\n if (shader === null) return;\n shader.bind();\n const { gl } = this;\n const { renderContext } = context;\n const { annotationLayer } = context;\n setControlsInShader(\n gl,\n shader,\n this.shaderControlState,\n parameters.parseResult.controls,\n );\n gl.uniform3fv(shader.uniform(\"uSubspaceMatrix\"), context.subspaceMatrix);\n gl.uniform1fv(shader.uniform(\"uModelClipBounds\"), context.modelClipBounds);\n gl.uniformMatrix4fv(\n shader.uniform(\"uModelViewProjection\"),\n false,\n context.modelViewProjectionMatrix,\n );\n if (renderContext.emitPickID) {\n gl.uniform1ui(shader.uniform(\"uPickID\"), context.basePickId);\n }\n if (renderContext.emitColor) {\n const color = annotationLayer.state.displayState.color.value;\n gl.uniform3f(shader.uniform(\"uColor\"), color[0], color[1], color[2]);\n gl.uniform1ui(shader.uniform(\"uSelectedIndex\"), context.selectedIndex);\n }\n\n const binder = shader.vertexShaderInputBinders.properties;\n binder.enable(1);\n gl.bindBuffer(WebGL2RenderingContext.ARRAY_BUFFER, context.buffer.buffer);\n binder.bind(/*stride=*/ context.count, context.bufferOffset);\n callback(shader);\n binder.disable();\n }\n\n abstract draw(context: AnnotationRenderContext): void;\n\n private histogramShaders = new Map<\n AnnotationPropertySpec[\"type\"],\n ShaderProgram\n >();\n\n private getHistogramShader(\n propertyType: AnnotationPropertySpec[\"type\"],\n ): ShaderProgram {\n const { histogramShaders } = this;\n let shader = histogramShaders.get(propertyType);\n if (shader === undefined) {\n const { gl } = this;\n shader = gl.memoize.get(\n JSON.stringify({ t: \"propertyHistogramGenerator\", propertyType }),\n () => {\n const builder = new ShaderBuilder(gl);\n this.defineHistogramShader(builder, propertyType);\n return builder.build();\n },\n );\n histogramShaders.set(propertyType, shader);\n }\n return shader;\n }\n\n private defineHistogramShader(\n builder: ShaderBuilder,\n propertyType: AnnotationPropertySpec[\"type\"],\n ) {\n const handler = annotationPropertyTypeRenderHandlers[propertyType];\n // TODO(jbms): If rank-dependent properties are added, this will need to change to support\n // histograms.\n handler.defineShader(builder, \"histogram\", /*rank=*/ 0);\n builder.addOutputBuffer(\"vec4\", \"out_histogram\", 0);\n const invlerpName = \"invlerpForHistogram\";\n const dataType = propertyTypeDataType[propertyType]!;\n builder.addVertexCode(\n defineInvlerpShaderFunction(\n builder,\n invlerpName,\n dataType,\n /*clamp=*/ false,\n ),\n );\n builder.setVertexMain(`\nfloat x = invlerpForHistogram(prop_histogram());\nif (x < 0.0) x = 0.0;\nelse if (x > 1.0) x = 1.0;\nelse x = (1.0 + x * 253.0) / 255.0;\ngl_Position = vec4(2.0 * (x * 255.0 + 0.5) / 256.0 - 1.0, 0.0, 0.0, 1.0);\ngl_PointSize = 1.0;\n`);\n builder.setFragmentMain(\"out_histogram = vec4(1.0, 1.0, 1.0, 1.0);\");\n }\n\n computeHistograms(context: AnnotationRenderContext, frameNumber: number) {\n const { histogramSpecifications } = this.shaderControlState;\n const histogramProperties = histogramSpecifications.properties.value;\n const numHistograms = histogramProperties.length;\n const { properties } = this;\n const numProperties = properties.length;\n const { propertyOffsets } = this;\n const { propertyGroupBytes, propertyGroupCumulativeBytes } = this;\n const { gl } = this;\n gl.enable(WebGL2RenderingContext.BLEND);\n gl.disable(WebGL2RenderingContext.SCISSOR_TEST);\n gl.disable(WebGL2RenderingContext.DEPTH_TEST);\n gl.blendFunc(WebGL2RenderingContext.ONE, WebGL2RenderingContext.ONE);\n const outputFramebuffers = histogramSpecifications.getFramebuffers(gl);\n const oldFrameNumber = histogramSpecifications.frameNumber;\n histogramSpecifications.frameNumber = frameNumber;\n gl.bindBuffer(WebGL2RenderingContext.ARRAY_BUFFER, context.buffer.buffer);\n for (\n let histogramIndex = 0;\n histogramIndex < numHistograms;\n ++histogramIndex\n ) {\n const propertyIdentifier = histogramProperties[histogramIndex];\n for (\n let propertyIndex = 0;\n propertyIndex < numProperties;\n ++propertyIndex\n ) {\n const property = properties[propertyIndex];\n if (property.identifier !== propertyIdentifier) continue;\n const propertyType = property.type;\n const dataType = propertyTypeDataType[propertyType]!;\n const shader = this.getHistogramShader(propertyType);\n shader.bind();\n const binder = shader.vertexShaderInputBinders.prop_histogram;\n binder.enable(0);\n const { group, offset: propertyOffset } =\n propertyOffsets[propertyIndex];\n enableLerpShaderFunction(\n shader,\n \"invlerpForHistogram\",\n dataType,\n histogramSpecifications.bounds.value[histogramIndex],\n );\n binder.bind(\n /*stride=*/ propertyGroupBytes[group],\n /*offset=*/ context.bufferOffset +\n propertyOffset +\n propertyGroupCumulativeBytes[group] * context.count,\n );\n outputFramebuffers[histogramIndex].bind(256, 1);\n if (frameNumber !== oldFrameNumber) {\n gl.clearColor(0, 0, 0, 0);\n gl.clear(WebGL2RenderingContext.COLOR_BUFFER_BIT);\n }\n gl.drawArrays(WebGL2RenderingContext.POINTS, 0, context.count);\n if (DEBUG_HISTOGRAMS) {\n const tempBuffer = new Float32Array(256 * 4);\n gl.readPixels(\n 0,\n 0,\n 256,\n 1,\n WebGL2RenderingContext.RGBA,\n WebGL2RenderingContext.FLOAT,\n tempBuffer,\n );\n const tempBuffer2 = new Float32Array(256);\n for (let j = 0; j < 256; ++j) {\n tempBuffer2[j] = tempBuffer[j * 4];\n }\n console.log(\"histogram\", tempBuffer2.join(\" \"));\n }\n binder.disable();\n break;\n }\n }\n gl.disable(WebGL2RenderingContext.BLEND);\n }\n}\n\ninterface AnnotationRenderHelperConstructor {\n new (\n gl: GL,\n annotationType: AnnotationType,\n rank: number,\n properties: readonly Readonly[],\n shaderControlState: ShaderControlState,\n fallbackShaderParameters: WatchableValueInterface,\n shaderError: WatchableShaderError,\n ): AnnotationRenderHelper;\n}\n\ninterface AnnotationTypeRenderHandler {\n defineShaderNoOpSetters: (builder: ShaderBuilder) => void;\n perspectiveViewRenderHelper: AnnotationRenderHelperConstructor;\n sliceViewRenderHelper: AnnotationRenderHelperConstructor;\n pickIdsPerInstance: number;\n getRepresentativePoint(\n out: Float32Array,\n annotation: T,\n partIndex: number,\n ): void;\n updateViaRepresentativePoint(\n oldAnnotation: T,\n position: Float32Array,\n partIndex: number,\n ): T;\n snapPosition(\n position: Float32Array,\n data: ArrayBuffer,\n offset: number,\n partIndex: number,\n ): void;\n}\n\nconst annotationTypeRenderHandlers = new Map<\n AnnotationType,\n AnnotationTypeRenderHandler\n>();\n\nexport function registerAnnotationTypeRenderHandler(\n type: AnnotationType,\n handler: AnnotationTypeRenderHandler,\n) {\n annotationTypeRenderHandlers.set(type, handler);\n}\n\nexport function getAnnotationTypeRenderHandler(\n type: AnnotationType,\n): AnnotationTypeRenderHandler {\n return annotationTypeRenderHandlers.get(type)!;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ChunkSourceParametersConstructor,\n LayerChunkProgressInfo,\n} from \"#src/chunk_manager/base.js\";\nimport {\n CHUNK_LAYER_STATISTICS_RPC_ID,\n CHUNK_MANAGER_RPC_ID,\n CHUNK_QUEUE_MANAGER_RPC_ID,\n CHUNK_SOURCE_INVALIDATE_RPC_ID,\n ChunkState,\n REQUEST_CHUNK_STATISTICS_RPC_ID,\n} from \"#src/chunk_manager/base.js\";\nimport { SharedWatchableValue } from \"#src/shared_watchable_value.js\";\nimport { TrackableBoolean } from \"#src/trackable_boolean.js\";\nimport { TrackableValue } from \"#src/trackable_value.js\";\nimport type { CancellationToken } from \"#src/util/cancellation.js\";\nimport { CANCELED } from \"#src/util/cancellation.js\";\nimport type { Borrowed } from \"#src/util/disposable.js\";\nimport { stableStringify } from \"#src/util/json.js\";\nimport { StringMemoize } from \"#src/util/memoize.js\";\nimport { getObjectId } from \"#src/util/object_id.js\";\nimport { NullarySignal } from \"#src/util/signal.js\";\nimport type { GL } from \"#src/webgl/context.js\";\nimport type { RPC, RPCPromise } from \"#src/worker_rpc.js\";\nimport {\n registerPromiseRPC,\n registerRPC,\n registerSharedObjectOwner,\n SharedObject,\n} from \"#src/worker_rpc.js\";\n\nconst DEBUG_CHUNK_UPDATES = false;\n\nexport class Chunk {\n state = ChunkState.SYSTEM_MEMORY;\n constructor(public source: ChunkSource) {}\n\n get gl() {\n return this.source.gl;\n }\n\n copyToGPU(_gl: GL) {\n this.state = ChunkState.GPU_MEMORY;\n }\n\n freeGPUMemory(_gl: GL) {\n this.state = ChunkState.SYSTEM_MEMORY;\n }\n}\n\nfunction validateLimitValue(x: any) {\n if (typeof x !== \"number\" || x < 0) {\n throw new Error(\n `Expected non-negative number as limit, but received: ${JSON.stringify(\n x,\n )}`,\n );\n }\n return x;\n}\n\nexport class CapacitySpecification {\n sizeLimit: TrackableValue;\n itemLimit: TrackableValue;\n constructor({\n defaultItemLimit = Number.POSITIVE_INFINITY,\n defaultSizeLimit = Number.POSITIVE_INFINITY,\n } = {}) {\n this.sizeLimit = new TrackableValue(\n defaultSizeLimit,\n validateLimitValue,\n );\n this.itemLimit = new TrackableValue(\n defaultItemLimit,\n validateLimitValue,\n );\n }\n}\n\nexport interface FrameNumberCounter {\n frameNumber: number;\n changed: NullarySignal;\n}\n\n@registerSharedObjectOwner(CHUNK_QUEUE_MANAGER_RPC_ID)\nexport class ChunkQueueManager extends SharedObject {\n visibleChunksChanged = new NullarySignal();\n pendingChunkUpdates: any = null;\n pendingChunkUpdatesTail: any = null;\n\n /**\n * If non-null, deadline in milliseconds since epoch after which chunk copies to the GPU may not\n * start (until the next frame).\n */\n chunkUpdateDeadline: number | null = null;\n\n chunkUpdateDelay = 30;\n\n enablePrefetch = new TrackableBoolean(true, true);\n\n constructor(\n rpc: RPC,\n public gl: GL,\n public frameNumberCounter: FrameNumberCounter,\n public capacities: {\n gpuMemory: CapacitySpecification;\n systemMemory: CapacitySpecification;\n download: CapacitySpecification;\n compute: CapacitySpecification;\n },\n ) {\n super();\n\n const makeCapacityCounterparts = (capacity: CapacitySpecification) => {\n return {\n itemLimit: this.registerDisposer(\n SharedWatchableValue.makeFromExisting(rpc, capacity.itemLimit),\n ).rpcId,\n sizeLimit: this.registerDisposer(\n SharedWatchableValue.makeFromExisting(rpc, capacity.sizeLimit),\n ).rpcId,\n };\n };\n\n this.initializeCounterpart(rpc, {\n gpuMemoryCapacity: makeCapacityCounterparts(capacities.gpuMemory),\n systemMemoryCapacity: makeCapacityCounterparts(capacities.systemMemory),\n downloadCapacity: makeCapacityCounterparts(capacities.download),\n computeCapacity: makeCapacityCounterparts(capacities.compute),\n enablePrefetch: this.registerDisposer(\n SharedWatchableValue.makeFromExisting(rpc, this.enablePrefetch),\n ).rpcId,\n });\n }\n\n scheduleChunkUpdate() {\n const deadline = this.chunkUpdateDeadline;\n let delay: number;\n if (deadline === null || Date.now() < deadline) {\n delay = 0;\n } else {\n delay = this.chunkUpdateDelay;\n }\n setTimeout(this.processPendingChunkUpdates.bind(this), delay);\n }\n processPendingChunkUpdates(flush = false) {\n let deadline = this.chunkUpdateDeadline;\n if (!flush && deadline === null) {\n deadline = Date.now() + 30;\n }\n let visibleChunksChanged = false;\n let numUpdates = 0;\n while (true) {\n if (!flush && Date.now() > deadline!) {\n // No time to perform chunk update now, we will wait some more.\n this.chunkUpdateDeadline = null;\n setTimeout(\n () => this.processPendingChunkUpdates(),\n this.chunkUpdateDelay,\n );\n break;\n }\n const update = this.pendingChunkUpdates;\n if (update == null) break;\n try {\n if (this.applyChunkUpdate(update)) {\n visibleChunksChanged = true;\n }\n } finally {\n ++numUpdates;\n const nextUpdate = (this.pendingChunkUpdates = update.nextUpdate);\n if (nextUpdate == null) {\n this.pendingChunkUpdatesTail = null;\n break;\n }\n }\n }\n if (visibleChunksChanged) {\n this.visibleChunksChanged.dispatch();\n }\n return numUpdates;\n }\n\n private handleFetch_(source: ChunkSource, update: any) {\n const { resolve, reject, cancellationToken } = update.promise;\n if ((cancellationToken).isCanceled) {\n reject(CANCELED);\n return;\n }\n\n const key = update.key;\n const chunk = source.chunks.get(key);\n if (!chunk) {\n reject(\n new Error(\n `No chunk found at ${key} for source ${source.constructor.name}`,\n ),\n );\n return;\n }\n\n const data = (chunk).data;\n if (!data) {\n reject(\n new Error(\n `At ${key} for source ${source.constructor.name}: chunk has no data`,\n ),\n );\n return;\n }\n\n resolve({ value: data });\n }\n\n applyChunkUpdate(update: any) {\n let visibleChunksChanged = false;\n const { rpc } = this;\n const source = rpc!.get(update.source);\n if (source === undefined) {\n // Source was removed while chunk update was enqueued.\n return;\n }\n if (DEBUG_CHUNK_UPDATES) {\n console.log(\n `${Date.now()} Chunk.update processed: ${source.rpcId} ` +\n `${update.id} ${update.state}`,\n );\n }\n if (update.promise !== undefined) {\n this.handleFetch_(source, update);\n } else if (update.id === undefined) {\n // Invalidate source.\n for (const chunkKey of source.chunks.keys()) {\n source.deleteChunk(chunkKey);\n }\n visibleChunksChanged = true;\n } else {\n const newState: number = update.state;\n if (newState === ChunkState.EXPIRED) {\n // FIXME: maybe use freeList for chunks here\n source.deleteChunk(update.id);\n } else {\n let chunk: Chunk;\n const key = update.id;\n if (update.new) {\n chunk = source.getChunk(update);\n source.addChunk(key, chunk);\n } else {\n chunk = source.chunks.get(key)!;\n }\n const oldState = chunk.state;\n if (newState !== oldState) {\n switch (newState) {\n case ChunkState.GPU_MEMORY:\n chunk.copyToGPU(this.gl);\n if (chunk.constructor.name !== \"ManifestChunk\") {\n visibleChunksChanged = true;\n }\n break;\n case ChunkState.SYSTEM_MEMORY:\n if (oldState === ChunkState.GPU_MEMORY) {\n chunk.freeGPUMemory(this.gl);\n }\n break;\n default:\n throw new Error(\n `INTERNAL ERROR: Invalid chunk state: ${ChunkState[newState]}`,\n );\n }\n }\n if (newState <= ChunkState.SYSTEM_MEMORY) {\n const { chunkRequesters } = source;\n if (chunkRequesters !== undefined) {\n const requesters = chunkRequesters.get(key);\n if (requesters !== undefined) {\n for (const requester of requesters) {\n requester(chunk);\n }\n }\n }\n }\n }\n }\n return visibleChunksChanged;\n }\n\n flushPendingChunkUpdates(): number {\n return this.processPendingChunkUpdates(true);\n }\n\n async getStatistics(): Promise> {\n const rpc = this.rpc!;\n const rawData = await rpc.promiseInvoke>(\n REQUEST_CHUNK_STATISTICS_RPC_ID,\n { queue: this.rpcId },\n );\n const data = new Map();\n for (const [id, statistics] of rawData) {\n const source = rpc.get(id) as ChunkSource | undefined;\n if (source === undefined) continue;\n data.set(source, statistics);\n }\n return data;\n }\n}\n\nfunction updateChunk(rpc: RPC, x: any) {\n const source: ChunkSource = rpc.get(x.source);\n if (DEBUG_CHUNK_UPDATES) {\n console.log(\n `${Date.now()} Chunk.update received: ` +\n `${source.rpcId} ${x.id} ${x.state} with chunkDataSize ${x.chunkDataSize}`,\n );\n }\n const queueManager = source.chunkManager.chunkQueueManager;\n if (source.immediateChunkUpdates) {\n if (queueManager.applyChunkUpdate(x)) {\n queueManager.visibleChunksChanged.dispatch();\n }\n return;\n }\n\n const pendingTail = queueManager.pendingChunkUpdatesTail;\n if (pendingTail == null) {\n queueManager.pendingChunkUpdates = x;\n queueManager.pendingChunkUpdatesTail = x;\n queueManager.scheduleChunkUpdate();\n } else {\n pendingTail.nextUpdate = x;\n queueManager.pendingChunkUpdatesTail = x;\n }\n}\n\nregisterRPC(\"Chunk.update\", function (x) {\n updateChunk(this, x);\n});\n\nregisterPromiseRPC(\n \"Chunk.retrieve\",\n function (x, cancellationToken): RPCPromise {\n return new Promise<{ value: any }>((resolve, reject) => {\n x.promise = { resolve, reject, cancellationToken };\n updateChunk(this, x);\n });\n },\n);\n\nregisterRPC(CHUNK_LAYER_STATISTICS_RPC_ID, function (x) {\n const chunkManager = this.get(x.id) as ChunkManager;\n for (const stats of chunkManager.prevStatisticsLayers) {\n stats.numVisibleChunksNeeded = 0;\n stats.numVisibleChunksAvailable = 0;\n stats.numPrefetchChunksNeeded = 0;\n stats.numPrefetchChunksAvailable = 0;\n }\n chunkManager.prevStatisticsLayers.length = 0;\n for (const layerUpdate of x.layers) {\n const layer = this.get(layerUpdate.id) as ChunkRenderLayerFrontend;\n if (layer === undefined) continue;\n const stats = layer.layerChunkProgressInfo;\n stats.numVisibleChunksAvailable = layerUpdate.numVisibleChunksAvailable;\n stats.numVisibleChunksNeeded = layerUpdate.numVisibleChunksNeeded;\n stats.numPrefetchChunksAvailable = layerUpdate.numPrefetchChunksAvailable;\n stats.numPrefetchChunksNeeded = layerUpdate.numPrefetchChunksNeeded;\n chunkManager.prevStatisticsLayers.push(stats);\n }\n chunkManager.layerChunkStatisticsUpdated.dispatch();\n});\n\nexport type GettableChunkSource = SharedObject & { OPTIONS: object; key: any };\n\nexport interface ChunkSourceConstructor<\n T extends GettableChunkSource = GettableChunkSource,\n> {\n new (...args: any[]): T;\n encodeOptions(options: T[\"OPTIONS\"]): any;\n}\n\n@registerSharedObjectOwner(CHUNK_MANAGER_RPC_ID)\nexport class ChunkManager extends SharedObject {\n memoize = new StringMemoize();\n\n prevStatisticsLayers: LayerChunkProgressInfo[] = [];\n layerChunkStatisticsUpdated = new NullarySignal();\n\n get gl() {\n return this.chunkQueueManager.gl;\n }\n\n constructor(public chunkQueueManager: ChunkQueueManager) {\n super();\n this.registerDisposer(chunkQueueManager.addRef());\n this.initializeCounterpart(chunkQueueManager.rpc!, {\n chunkQueueManager: chunkQueueManager.rpcId,\n });\n }\n\n getChunkSource(\n constructorFunction: ChunkSourceConstructor,\n options: T[\"OPTIONS\"],\n ): T {\n const keyObject = constructorFunction.encodeOptions(options);\n keyObject.constructorId = getObjectId(constructorFunction);\n const key = stableStringify(keyObject);\n return this.memoize.get(key, () => {\n const newSource = new constructorFunction(this, options);\n newSource.initializeCounterpart(this.rpc!, {});\n newSource.key = keyObject;\n return newSource;\n });\n }\n}\n\nexport interface ChunkRequesterState {\n (chunk: Chunk): void;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging\nexport class ChunkSource extends SharedObject {\n OPTIONS: object;\n chunks = new Map();\n\n chunkRequesters: Map | undefined;\n\n /**\n * If set to true, chunk updates will be applied to this source immediately, rather than queueing\n * them. Sources that dynamically update chunks and need to ensure a consistent order of\n * processing relative to other messages between the frontend and worker should set this to true.\n */\n immediateChunkUpdates = false;\n\n constructor(\n public chunkManager: Borrowed,\n _options: object = {},\n ) {\n super();\n }\n\n initializeCounterpart(rpc: RPC, options: any) {\n options.chunkManager = this.chunkManager.rpcId;\n super.initializeCounterpart(rpc, options);\n }\n\n get gl() {\n return this.chunkManager.chunkQueueManager.gl;\n }\n\n deleteChunk(key: string) {\n const chunk = this.chunks.get(key)!;\n if (chunk.state === ChunkState.GPU_MEMORY) {\n chunk.freeGPUMemory(this.gl);\n }\n this.chunks.delete(key);\n }\n\n addChunk(key: string, chunk: Chunk) {\n this.chunks.set(key, chunk);\n }\n\n /**\n * Default implementation for use with backendOnly chunk sources.\n */\n getChunk(_x: any): Chunk {\n throw new Error(\"Not implemented.\");\n }\n\n /**\n * Invalidates the chunk cache. Operates asynchronously.\n */\n invalidateCache(): void {\n this.rpc!.invoke(CHUNK_SOURCE_INVALIDATE_RPC_ID, { id: this.rpcId });\n }\n\n static encodeOptions(_options: object): { [key: string]: any } {\n return {};\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging\nexport interface ChunkSource {\n key: any;\n}\n\nexport function WithParameters<\n Parameters,\n TBase extends ChunkSourceConstructor,\n>(\n Base: TBase,\n parametersConstructor: ChunkSourceParametersConstructor,\n) {\n type WithParametersOptions = InstanceType[\"OPTIONS\"] & {\n parameters: Parameters;\n };\n @registerSharedObjectOwner(parametersConstructor.RPC_ID)\n class C extends Base {\n OPTIONS: WithParametersOptions;\n parameters: Parameters;\n constructor(...args: any[]) {\n super(...args);\n const options: WithParametersOptions = args[1];\n this.parameters = options.parameters;\n }\n initializeCounterpart(rpc: RPC, options: any) {\n options.parameters = this.parameters;\n super.initializeCounterpart(rpc, options);\n }\n static encodeOptions(options: WithParametersOptions) {\n return Object.assign(\n { parameters: options.parameters },\n Base.encodeOptions(options),\n );\n }\n }\n return C;\n}\n\nexport class ChunkRenderLayerFrontend extends SharedObject {\n constructor(public layerChunkProgressInfo: LayerChunkProgressInfo) {\n super();\n }\n}\n\nexport type ChunkStatistics = Map;\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { VisibleSegmentEquivalencePolicy } from \"#src/segmentation_graph/segment_id.js\";\nimport type { SharedDisjointUint64Sets } from \"#src/shared_disjoint_sets.js\";\nimport type { SharedWatchableValue } from \"#src/shared_watchable_value.js\";\nimport type { Uint64OrderedSet } from \"#src/uint64_ordered_set.js\";\nimport type { Uint64Set } from \"#src/uint64_set.js\";\nimport type { RefCounted } from \"#src/util/disposable.js\";\nimport type { Uint64 } from \"#src/util/uint64.js\";\n\nexport interface VisibleSegmentsState {\n visibleSegments: Uint64Set;\n selectedSegments: Uint64OrderedSet;\n segmentEquivalences: SharedDisjointUint64Sets;\n\n // Specifies a temporary/alternative set of segments/equivalences to use for display purposes,\n // used for previewing a merge/split.\n temporaryVisibleSegments: Uint64Set;\n temporarySegmentEquivalences: SharedDisjointUint64Sets;\n useTemporaryVisibleSegments: SharedWatchableValue;\n useTemporarySegmentEquivalences: SharedWatchableValue;\n}\n\nexport const VISIBLE_SEGMENTS_STATE_PROPERTIES = [\n \"visibleSegments\",\n \"segmentEquivalences\",\n \"temporaryVisibleSegments\",\n \"temporarySegmentEquivalences\",\n \"useTemporaryVisibleSegments\",\n \"useTemporarySegmentEquivalences\",\n] as const;\n\nexport function onVisibleSegmentsStateChanged(\n context: RefCounted,\n state: VisibleSegmentsState,\n callback: () => void,\n) {\n context.registerDisposer(state.visibleSegments.changed.add(callback));\n context.registerDisposer(state.segmentEquivalences.changed.add(callback));\n}\n\nexport function onTemporaryVisibleSegmentsStateChanged(\n context: RefCounted,\n state: VisibleSegmentsState,\n callback: () => void,\n) {\n context.registerDisposer(\n state.temporaryVisibleSegments.changed.add(callback),\n );\n context.registerDisposer(\n state.temporarySegmentEquivalences.changed.add(callback),\n );\n context.registerDisposer(\n state.useTemporaryVisibleSegments.changed.add(callback),\n );\n context.registerDisposer(\n state.useTemporarySegmentEquivalences.changed.add(callback),\n );\n}\n\n/**\n * Returns a string key for identifying a uint64 object id. This is faster than\n * Uint64.prototype.toString().\n */\nexport function getObjectKey(objectId: Uint64): string {\n return `${objectId.low},${objectId.high}`;\n}\n\nfunction isHighBitSegment(segmentId: Uint64): boolean {\n return segmentId.high >>> 31 ? true : false;\n}\n\nexport function getVisibleSegments(state: VisibleSegmentsState) {\n return state.useTemporaryVisibleSegments.value\n ? state.temporaryVisibleSegments\n : state.visibleSegments;\n}\n\nexport function getSegmentEquivalences(state: VisibleSegmentsState) {\n return state.useTemporarySegmentEquivalences.value\n ? state.temporarySegmentEquivalences\n : state.segmentEquivalences;\n}\n\nexport function forEachVisibleSegment(\n state: VisibleSegmentsState,\n callback: (objectId: Uint64, rootObjectId: Uint64) => void,\n) {\n const visibleSegments = getVisibleSegments(state);\n const segmentEquivalences = getSegmentEquivalences(state);\n const equivalencePolicy =\n segmentEquivalences.disjointSets.visibleSegmentEquivalencePolicy.value;\n for (const rootObjectId of visibleSegments.unsafeKeys()) {\n if (\n equivalencePolicy &\n VisibleSegmentEquivalencePolicy.NONREPRESENTATIVE_EXCLUDED\n ) {\n const rootObjectId2 = segmentEquivalences.get(rootObjectId);\n callback(rootObjectId, rootObjectId2);\n } else {\n // TODO(jbms): Remove this check if logic is added to ensure that it always holds.\n if (!segmentEquivalences.disjointSets.isMinElement(rootObjectId)) {\n continue;\n }\n for (const objectId of segmentEquivalences.setElements(rootObjectId)) {\n if (\n equivalencePolicy &\n VisibleSegmentEquivalencePolicy.REPRESENTATIVE_EXCLUDED &&\n equivalencePolicy &\n VisibleSegmentEquivalencePolicy.MAX_REPRESENTATIVE &&\n isHighBitSegment(objectId)\n ) {\n continue;\n }\n callback(objectId, rootObjectId);\n }\n }\n }\n}\n\nexport interface IndexedSegmentProperty {\n id: string;\n type: \"string\";\n description: string | undefined;\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TrackableValue } from \"#src/trackable_value.js\";\nimport { makeVerifyNumberInInterval } from \"#src/util/json.js\";\nimport { NullarySignal } from \"#src/util/signal.js\";\nimport { VisibilityPriorityAggregator } from \"#src/visibility_priority/frontend.js\";\n\nexport const numRenderScaleHistogramBins = 40;\nexport const renderScaleHistogramBinSize = 0.5;\nexport const renderScaleHistogramOrigin = -4;\n\nexport function getRenderScaleHistogramOffset(\n renderScale: number,\n origin: number = renderScaleHistogramOrigin,\n): number {\n return (Math.log2(renderScale) - origin) / renderScaleHistogramBinSize;\n}\n\nexport function getRenderScaleFromHistogramOffset(\n offset: number,\n origin: number = renderScaleHistogramOrigin,\n): number {\n return 2 ** (offset * renderScaleHistogramBinSize + origin);\n}\n\nexport function trackableRenderScaleTarget(\n initialValue: number,\n scaleOrigin: number = 2 ** renderScaleHistogramOrigin,\n scaleMax?: number,\n) {\n if (scaleMax === undefined) {\n scaleMax =\n 2 **\n Math.round(\n renderScaleHistogramBinSize * numRenderScaleHistogramBins +\n renderScaleHistogramOrigin,\n ) -\n 1;\n }\n const verifyNumberInInterval = makeVerifyNumberInInterval(\n scaleOrigin,\n scaleMax,\n );\n return new TrackableValue(initialValue, verifyNumberInInterval);\n}\n\nexport class RenderScaleHistogram {\n visibility = new VisibilityPriorityAggregator();\n changed = new NullarySignal();\n logScaleOrigin: number;\n\n constructor(origin: number = renderScaleHistogramOrigin) {\n this.logScaleOrigin = origin;\n }\n\n /**\n * Frame number corresponding to the current histogram.\n */\n frameNumber = -1;\n\n /**\n * Maps from spatial scale (nanometers) to histogram row index in the range\n * `[0, spatialScales.size)`.\n */\n spatialScales = new Map();\n\n /**\n * Current number of rows allocated for the histogram.\n */\n numHistogramRows = 1;\n\n /**\n * Initially allocate one row.\n */\n value = new Uint32Array(\n numRenderScaleHistogramBins * this.numHistogramRows * 2,\n );\n\n /**\n * Number of chunks that are indication only (not present in the data).\n */\n fakeChunkCount = 0;\n\n begin(frameNumber: number) {\n if (frameNumber !== this.frameNumber) {\n this.value.fill(0);\n this.frameNumber = frameNumber;\n this.spatialScales.clear();\n this.fakeChunkCount = 0;\n this.changed.dispatch();\n }\n }\n\n /**\n * Adds a count to the histogram.\n *\n * @param spatialScale Spatial resolution of data in nanometers.\n * @param renderScale Rendered scale of data in screen pixels.\n * @param presentCount Number of present chunks.\n * @param notPresentCount Number of desired but not-present chunks.\n * @param renderOnly If true, indicates that the added bar is for display only, and is not linked\n * to actual chunk loading stats. Defaults to false.\n */\n add(\n spatialScale: number,\n renderScale: number,\n presentCount: number,\n notPresentCount: number,\n renderOnly = false,\n ) {\n let { spatialScales, numHistogramRows, value } = this;\n let spatialScaleIndex = spatialScales.get(spatialScale);\n if (spatialScaleIndex === undefined) {\n spatialScaleIndex = spatialScales.size;\n spatialScales.set(spatialScale, spatialScaleIndex);\n }\n if (spatialScaleIndex >= numHistogramRows) {\n this.numHistogramRows = numHistogramRows *= 2;\n const newValue = new Uint32Array(\n numHistogramRows * numRenderScaleHistogramBins * 2,\n );\n newValue.set(value);\n this.value = value = newValue;\n }\n const index =\n spatialScaleIndex * numRenderScaleHistogramBins * 2 +\n Math.min(\n Math.max(\n 0,\n Math.round(\n getRenderScaleHistogramOffset(renderScale, this.logScaleOrigin),\n ),\n ),\n numRenderScaleHistogramBins - 1,\n );\n value[index] += presentCount;\n value[index + numRenderScaleHistogramBins] += notPresentCount;\n if (renderOnly) {\n this.fakeChunkCount = this.fakeChunkCount + notPresentCount;\n }\n }\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ChunkManager } from \"#src/chunk_manager/frontend.js\";\nimport { ChunkRenderLayerFrontend } from \"#src/chunk_manager/frontend.js\";\nimport type { CoordinateSpace } from \"#src/coordinate_transform.js\";\nimport type { VisibleLayerInfo } from \"#src/layer/index.js\";\nimport type {\n ChunkTransformParameters,\n RenderLayerTransformOrError,\n} from \"#src/render_coordinate_transform.js\";\nimport type { RenderScaleHistogram } from \"#src/render_scale_statistics.js\";\nimport { trackableRenderScaleTarget } from \"#src/render_scale_statistics.js\";\nimport type {\n ThreeDimensionalReadyRenderContext,\n ThreeDimensionalRenderContext,\n} from \"#src/renderlayer.js\";\nimport { RenderLayer, VisibilityTrackedRenderLayer } from \"#src/renderlayer.js\";\nimport { SharedWatchableValue } from \"#src/shared_watchable_value.js\";\nimport type {\n SliceViewBase,\n SliceViewProjectionParameters,\n SliceViewSourceOptions,\n TransformedSource,\n} from \"#src/sliceview/base.js\";\nimport {\n filterVisibleSources,\n SLICEVIEW_RENDERLAYER_RPC_ID,\n} from \"#src/sliceview/base.js\";\nimport type {\n MultiscaleSliceViewChunkSource,\n SliceView,\n SliceViewChunkSource,\n SliceViewSingleResolutionSource,\n} from \"#src/sliceview/frontend.js\";\nimport type { SliceViewPanel } from \"#src/sliceview/panel.js\";\nimport type { WatchableValueInterface } from \"#src/trackable_value.js\";\nimport { constantWatchableValue } from \"#src/trackable_value.js\";\nimport type { Borrowed } from \"#src/util/disposable.js\";\nimport { HistogramSpecifications } from \"#src/webgl/empirical_cdf.js\";\nimport type { ShaderModule } from \"#src/webgl/shader.js\";\nimport type { RpcId, SharedObject } from \"#src/worker_rpc.js\";\n\nexport interface SliceViewRenderLayerOptions {\n /**\n * Specifies the transform from the \"model\" coordinate space (specified by the multiscale source)\n * to the \"render layer\" coordinate space.\n */\n transform: WatchableValueInterface;\n renderScaleTarget?: WatchableValueInterface;\n renderScaleHistogram?: RenderScaleHistogram;\n\n /**\n * Specifies the position within the \"local\" coordinate space.\n */\n localPosition: WatchableValueInterface;\n dataHistogramSpecifications?: HistogramSpecifications;\n\n rpcTransfer?: { [index: string]: number | string | null };\n}\n\nexport interface VisibleSourceInfo {\n source: Borrowed;\n refCount: number;\n chunkTransform: ChunkTransformParameters;\n}\n\nexport interface SliceViewRenderContext {\n sliceView: SliceView;\n projectionParameters: SliceViewProjectionParameters;\n wireFrame: boolean;\n}\n\nexport abstract class SliceViewRenderLayer<\n Source extends SliceViewChunkSource = SliceViewChunkSource,\n SourceOptions extends SliceViewSourceOptions = SliceViewSourceOptions,\n> extends RenderLayer {\n rpcId: RpcId | null = null;\n rpcTransfer: { [index: string]: number | string | null } = {};\n\n localPosition: WatchableValueInterface;\n channelCoordinateSpace: WatchableValueInterface;\n transform: WatchableValueInterface;\n\n renderScaleTarget: WatchableValueInterface;\n renderScaleHistogram?: RenderScaleHistogram;\n\n // This is only used by `ImageRenderLayer` currently, but is defined here because\n // `sliceview/frontend.ts` is responsible for providing the texture buffers used for accumulating\n // histograms.\n dataHistogramSpecifications: HistogramSpecifications;\n\n getDataHistogramCount() {\n return this.dataHistogramSpecifications.visibleHistograms;\n }\n\n /**\n * Currently visible sources for this render layer.\n */\n private visibleSources = new Map<\n Borrowed,\n VisibleSourceInfo\n >();\n\n /**\n * Cached list of sources in `visibleSources`, ordered by voxel size.\n *\n * Truncated to zero length when `visibleSources` changes to indicate that it is invalid.\n */\n private visibleSourcesList_: VisibleSourceInfo[] = [];\n\n getSources(\n options: SliceViewSourceOptions,\n ): SliceViewSingleResolutionSource[][] {\n return this.multiscaleSource.getSources(options as any);\n }\n\n addSource(\n source: Borrowed,\n chunkTransform: ChunkTransformParameters,\n ) {\n const { visibleSources } = this;\n const info = visibleSources.get(source);\n if (info !== undefined) {\n ++info.refCount;\n info.chunkTransform = chunkTransform;\n } else {\n visibleSources.set(source, { source, refCount: 1, chunkTransform });\n this.visibleSourcesList_.length = 0;\n }\n }\n\n removeSource(source: Borrowed) {\n const { visibleSources } = this;\n const info = visibleSources.get(source)!;\n if (info.refCount !== 1) {\n --info.refCount;\n } else {\n visibleSources.delete(source);\n this.visibleSourcesList_.length = 0;\n }\n }\n\n get visibleSourcesList() {\n const { visibleSources, visibleSourcesList_ } = this;\n if (visibleSourcesList_.length === 0 && visibleSources.size !== 0) {\n for (const info of visibleSources.values()) {\n visibleSourcesList_.push(info);\n }\n // Sort by volume scaling factor.\n visibleSourcesList_.sort((a, b) => {\n return (\n Math.abs(a.chunkTransform.chunkToLayerTransformDet) -\n Math.abs(b.chunkTransform.chunkToLayerTransformDet)\n );\n });\n }\n return visibleSourcesList_;\n }\n\n constructor(\n public chunkManager: ChunkManager,\n public multiscaleSource: MultiscaleSliceViewChunkSource<\n Source,\n SourceOptions\n >,\n options: SliceViewRenderLayerOptions,\n ) {\n super();\n\n const { renderScaleTarget = trackableRenderScaleTarget(1) } = options;\n this.renderScaleTarget = renderScaleTarget;\n this.renderScaleHistogram = options.renderScaleHistogram;\n this.transform = options.transform;\n this.localPosition = options.localPosition;\n this.rpcTransfer = options.rpcTransfer || {};\n this.dataHistogramSpecifications = this.registerDisposer(\n options.dataHistogramSpecifications ??\n new HistogramSpecifications(\n constantWatchableValue([]),\n constantWatchableValue([]),\n constantWatchableValue([]),\n ),\n );\n this.registerDisposer(\n this.dataHistogramSpecifications.visibility.changed.add(\n this.redrawNeeded.dispatch,\n ),\n );\n }\n\n RPC_TYPE_ID: string;\n\n initializeCounterpart() {\n const sharedObject = this.registerDisposer(\n new ChunkRenderLayerFrontend(this.layerChunkProgressInfo),\n );\n const rpc = this.chunkManager.rpc!;\n sharedObject.RPC_TYPE_ID = this.RPC_TYPE_ID;\n sharedObject.initializeCounterpart(rpc, {\n localPosition: this.registerDisposer(\n SharedWatchableValue.makeFromExisting(rpc, this.localPosition),\n ).rpcId,\n renderScaleTarget: this.registerDisposer(\n SharedWatchableValue.makeFromExisting(rpc, this.renderScaleTarget),\n ).rpcId,\n ...this.rpcTransfer,\n });\n this.rpcId = sharedObject.rpcId;\n }\n\n get gl() {\n return this.chunkManager.chunkQueueManager.gl;\n }\n\n setGLBlendMode(gl: WebGL2RenderingContext, renderLayerNum: number): void {\n // Default blend mode for non-blend-mode-aware layers\n if (renderLayerNum > 0) {\n gl.enable(WebGL2RenderingContext.BLEND);\n gl.blendFunc(\n WebGL2RenderingContext.SRC_ALPHA,\n WebGL2RenderingContext.ONE_MINUS_SRC_ALPHA,\n );\n } else {\n gl.disable(WebGL2RenderingContext.BLEND);\n }\n }\n\n abstract draw(renderContext: SliceViewRenderContext): void;\n\n filterVisibleSources(\n sliceView: SliceViewBase,\n sources: readonly TransformedSource[],\n ): Iterable {\n return filterVisibleSources(sliceView, this, sources);\n }\n}\n\nSliceViewRenderLayer.prototype.RPC_TYPE_ID = SLICEVIEW_RENDERLAYER_RPC_ID;\n\nexport interface SliceViewPanelReadyRenderContext\n extends ThreeDimensionalReadyRenderContext {\n sliceView: SliceView;\n}\n\nexport interface SliceViewPanelRenderContext\n extends SliceViewPanelReadyRenderContext,\n ThreeDimensionalRenderContext {\n emitter: ShaderModule;\n\n /**\n * Specifies whether the emitted color value will be used.\n */\n emitColor: boolean;\n\n /**\n * Specifies whether the emitted pick ID will be used.\n */\n emitPickID: boolean;\n}\n\nexport class SliceViewPanelRenderLayer<\n AttachmentState = unknown,\n> extends VisibilityTrackedRenderLayer {\n draw(\n renderContext: SliceViewPanelRenderContext,\n attachment: VisibleLayerInfo,\n ) {\n renderContext;\n attachment;\n // Must be overridden by subclasses.\n }\n\n isReady(\n renderContext: SliceViewPanelReadyRenderContext,\n attachment: VisibleLayerInfo,\n ) {\n renderContext;\n attachment;\n return true;\n }\n\n backend: SharedObject | undefined;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { debounce } from \"lodash-es\";\nimport { ChunkState } from \"#src/chunk_manager/base.js\";\nimport type {\n ChunkManager,\n ChunkRequesterState,\n} from \"#src/chunk_manager/frontend.js\";\nimport { Chunk, ChunkSource } from \"#src/chunk_manager/frontend.js\";\nimport { applyRenderViewportToProjectionMatrix } from \"#src/display_context.js\";\nimport type { LayerManager } from \"#src/layer/index.js\";\nimport type {\n DisplayDimensionRenderInfo,\n NavigationState,\n} from \"#src/navigation_state.js\";\nimport { updateProjectionParametersFromInverseViewAndProjection } from \"#src/projection_parameters.js\";\nimport type {\n ChunkDisplayTransformParameters,\n ChunkTransformParameters,\n RenderLayerTransformOrError,\n} from \"#src/render_coordinate_transform.js\";\nimport {\n getChunkDisplayTransformParameters,\n getChunkTransformParameters,\n getLayerDisplayDimensionMapping,\n} from \"#src/render_coordinate_transform.js\";\nimport {\n DerivedProjectionParameters,\n SharedProjectionParameters,\n} from \"#src/renderlayer.js\";\nimport type {\n SliceViewChunkSource as SliceViewChunkSourceInterface,\n SliceViewChunkSpecification,\n SliceViewSourceOptions,\n TransformedSource,\n VisibleLayerSources,\n} from \"#src/sliceview/base.js\";\nimport {\n forEachPlaneIntersectingVolumetricChunk,\n getNormalizedChunkLayout,\n SLICEVIEW_ADD_VISIBLE_LAYER_RPC_ID,\n SLICEVIEW_REMOVE_VISIBLE_LAYER_RPC_ID,\n SLICEVIEW_REQUEST_CHUNK_RPC_ID,\n SLICEVIEW_RPC_ID,\n SliceViewBase,\n SliceViewProjectionParameters,\n} from \"#src/sliceview/base.js\";\nimport { ChunkLayout } from \"#src/sliceview/chunk_layout.js\";\nimport { SliceViewRenderLayer } from \"#src/sliceview/renderlayer.js\";\nimport type { WatchableValueInterface } from \"#src/trackable_value.js\";\nimport type { CancellationToken } from \"#src/util/cancellation.js\";\nimport { uncancelableToken } from \"#src/util/cancellation.js\";\nimport type { Borrowed, Disposer, Owned } from \"#src/util/disposable.js\";\nimport { invokeDisposers, RefCounted } from \"#src/util/disposable.js\";\nimport type { vec4 } from \"#src/util/geom.js\";\nimport { kOneVec, kZeroVec4, mat4, vec3 } from \"#src/util/geom.js\";\nimport { MessageList, MessageSeverity } from \"#src/util/message_list.js\";\nimport { getObjectId } from \"#src/util/object_id.js\";\nimport { NullarySignal } from \"#src/util/signal.js\";\nimport { withSharedVisibility } from \"#src/visibility_priority/frontend.js\";\nimport type { GL } from \"#src/webgl/context.js\";\nimport type { HistogramSpecifications } from \"#src/webgl/empirical_cdf.js\";\nimport { TextureHistogramGenerator } from \"#src/webgl/empirical_cdf.js\";\nimport type { TextureBuffer } from \"#src/webgl/offscreen.js\";\nimport {\n DepthTextureBuffer,\n FramebufferConfiguration,\n makeTextureBuffers,\n} from \"#src/webgl/offscreen.js\";\nimport type { ShaderModule, ShaderProgram } from \"#src/webgl/shader.js\";\nimport { ShaderBuilder } from \"#src/webgl/shader.js\";\nimport { getSquareCornersBuffer } from \"#src/webgl/square_corners_buffer.js\";\nimport type { RPC } from \"#src/worker_rpc.js\";\nimport { registerSharedObjectOwner } from \"#src/worker_rpc.js\";\n\nexport type GenericChunkKey = string;\n\nclass FrontendSliceViewBase extends SliceViewBase<\n SliceViewChunkSource,\n SliceViewRenderLayer,\n FrontendTransformedSource\n> {}\nconst Base = withSharedVisibility(FrontendSliceViewBase);\n\nexport interface FrontendTransformedSource<\n RLayer extends SliceViewRenderLayer = SliceViewRenderLayer,\n Source extends SliceViewChunkSource = SliceViewChunkSource,\n> extends TransformedSource {\n chunkTransform: ChunkTransformParameters;\n chunkDisplayTransform: ChunkDisplayTransformParameters;\n}\n\ninterface FrontendVisibleLayerSources\n extends VisibleLayerSources<\n SliceViewRenderLayer,\n SliceViewChunkSource,\n FrontendTransformedSource\n > {\n transformGeneration: number;\n lastSeenGeneration: number;\n disposers: Disposer[];\n messages: MessageList;\n}\n\nfunction serializeTransformedSource(\n tsource: TransformedSource,\n) {\n return {\n source: tsource.source.addCounterpartRef(),\n effectiveVoxelSize: tsource.effectiveVoxelSize,\n layerRank: tsource.layerRank,\n nonDisplayLowerClipBound: tsource.nonDisplayLowerClipBound,\n nonDisplayUpperClipBound: tsource.nonDisplayUpperClipBound,\n lowerClipBound: tsource.lowerClipBound,\n upperClipBound: tsource.upperClipBound,\n lowerClipDisplayBound: tsource.lowerClipDisplayBound,\n upperClipDisplayBound: tsource.upperClipDisplayBound,\n chunkDisplayDimensionIndices: tsource.chunkDisplayDimensionIndices,\n lowerChunkDisplayBound: tsource.lowerChunkDisplayBound,\n upperChunkDisplayBound: tsource.upperChunkDisplayBound,\n fixedLayerToChunkTransform: tsource.fixedLayerToChunkTransform,\n combinedGlobalLocalToChunkTransform:\n tsource.combinedGlobalLocalToChunkTransform,\n chunkLayout: tsource.chunkLayout.toObject(),\n };\n}\n\nexport function serializeAllTransformedSources(\n allSources: TransformedSource[][],\n) {\n return allSources.map((scales) => scales.map(serializeTransformedSource));\n}\n\nfunction disposeTransformedSources(\n layer: SliceViewRenderLayer,\n allSources: TransformedSource[][],\n) {\n for (const scales of allSources) {\n for (const { source } of scales) {\n layer.removeSource(source);\n source.dispose();\n }\n }\n}\n\n@registerSharedObjectOwner(SLICEVIEW_RPC_ID)\nexport class SliceView extends Base {\n gl = this.chunkManager.gl;\n viewChanged = new NullarySignal();\n rpc: RPC;\n rpcId: number;\n\n renderingStale = true;\n\n visibleChunksStale = true;\n\n visibleLayerList = new Array();\n\n visibleLayers: Map;\n\n offscreenFramebuffer = this.registerDisposer(\n new FramebufferConfiguration(this.gl, {\n colorBuffers: makeTextureBuffers(this.gl, 1),\n depthBuffer: new DepthTextureBuffer(this.gl),\n }),\n );\n histogramInputTextures: TextureBuffer[] = [];\n offscreenFramebuffersWithHistograms = [this.offscreenFramebuffer];\n\n get displayDimensionRenderInfo() {\n return this.navigationState.displayDimensionRenderInfo;\n }\n\n private histogramGenerator = TextureHistogramGenerator.get(this.gl);\n\n computeHistograms(\n count: number,\n histogramSpecifications: HistogramSpecifications,\n ) {\n this.histogramGenerator.compute(\n count,\n this.offscreenFramebuffer.depthBuffer!.texture,\n this.histogramInputTextures,\n histogramSpecifications,\n this.chunkManager.chunkQueueManager.frameNumberCounter.frameNumber,\n );\n }\n\n projectionParameters: Owned<\n DerivedProjectionParameters\n >;\n\n sharedProjectionParameters: Owned<\n SharedProjectionParameters\n >;\n\n flushBackendProjectionParameters() {\n this.sharedProjectionParameters.flush();\n }\n\n constructor(\n public chunkManager: ChunkManager,\n public layerManager: LayerManager,\n public navigationState: Owned,\n public wireFrame: WatchableValueInterface,\n ) {\n super(\n new DerivedProjectionParameters({\n parametersConstructor: SliceViewProjectionParameters,\n navigationState,\n update: (out, navigationState) => {\n const { invViewMatrix, centerDataPosition } = out;\n navigationState.toMat4(invViewMatrix);\n const { canonicalVoxelFactors, voxelPhysicalScales } =\n out.displayDimensionRenderInfo;\n for (let i = 0; i < 3; ++i) {\n centerDataPosition[i] = invViewMatrix[12 + i];\n }\n const {\n logicalWidth,\n logicalHeight,\n projectionMat,\n viewportNormalInGlobalCoordinates,\n viewportNormalInCanonicalCoordinates,\n } = out;\n const { relativeDepthRange } = navigationState;\n mat4.ortho(\n projectionMat,\n -logicalWidth / 2,\n logicalWidth / 2,\n logicalHeight / 2,\n -logicalHeight / 2,\n -relativeDepthRange,\n relativeDepthRange,\n );\n applyRenderViewportToProjectionMatrix(out, projectionMat);\n updateProjectionParametersFromInverseViewAndProjection(out);\n const { viewMatrix } = out;\n for (let i = 0; i < 3; ++i) {\n const x = (viewportNormalInGlobalCoordinates[i] =\n viewMatrix[i * 4 + 2]);\n viewportNormalInCanonicalCoordinates[i] =\n x / canonicalVoxelFactors[i];\n }\n vec3.normalize(\n viewportNormalInGlobalCoordinates,\n viewportNormalInGlobalCoordinates,\n );\n vec3.normalize(\n viewportNormalInCanonicalCoordinates,\n viewportNormalInCanonicalCoordinates,\n );\n\n let newPixelSize = 0;\n for (let i = 0; i < 3; ++i) {\n const s = voxelPhysicalScales[i];\n const x = invViewMatrix[i];\n newPixelSize += (s * x) ** 2;\n }\n newPixelSize = Math.sqrt(newPixelSize);\n out.pixelSize = newPixelSize;\n },\n }),\n );\n this.registerDisposer(navigationState);\n this.registerDisposer(this.projectionParameters);\n this.registerDisposer(\n this.projectionParameters.changed.add((oldValue, newValue) => {\n if (\n oldValue.displayDimensionRenderInfo !==\n newValue.displayDimensionRenderInfo\n ) {\n this.updateVisibleLayers();\n }\n }),\n );\n const rpc = this.chunkManager.rpc!;\n const sharedProjectionParameters = (this.sharedProjectionParameters =\n this.registerDisposer(\n new SharedProjectionParameters(rpc, this.projectionParameters),\n ));\n this.initializeCounterpart(rpc, {\n chunkManager: chunkManager.rpcId,\n projectionParameters: sharedProjectionParameters.rpcId,\n });\n this.registerDisposer(\n layerManager.layersChanged.add(() => {\n this.updateVisibleLayers();\n }),\n );\n\n this.wireFrame.changed.add(this.viewChanged.dispatch);\n\n this.viewChanged.add(() => {\n this.renderingStale = true;\n });\n this.registerDisposer(\n chunkManager.chunkQueueManager.visibleChunksChanged.add(\n this.viewChanged.dispatch,\n ),\n );\n this.updateVisibleLayers();\n }\n\n forEachVisibleChunk(\n tsource: FrontendTransformedSource,\n chunkLayout: ChunkLayout,\n callback: (key: string) => void,\n ) {\n forEachPlaneIntersectingVolumetricChunk(\n this.projectionParameters.value,\n tsource.renderLayer.localPosition.value,\n tsource,\n chunkLayout,\n () => {\n callback(tsource.curPositionInChunks.join());\n },\n );\n }\n\n isReady() {\n if (!this.navigationState.valid) {\n return false;\n }\n this.updateVisibleLayers.flush();\n this.updateVisibleSources();\n let numValidChunks = 0;\n let totalChunks = 0;\n for (const { visibleSources } of this.visibleLayers.values()) {\n for (const tsource of visibleSources) {\n const chunkLayout = getNormalizedChunkLayout(\n this.projectionParameters.value,\n tsource.chunkLayout,\n );\n const { source } = tsource;\n const { chunks } = source;\n this.forEachVisibleChunk(tsource, chunkLayout, (key) => {\n const chunk = chunks.get(key);\n ++totalChunks;\n if (chunk && chunk.state === ChunkState.GPU_MEMORY) {\n ++numValidChunks;\n }\n });\n }\n }\n return numValidChunks === totalChunks;\n }\n\n private updateVisibleLayers = this.registerCancellable(\n debounce(() => {\n this.updateVisibleLayersNow();\n }, 0),\n );\n\n invalidateVisibleSources() {\n super.invalidateVisibleSources();\n this.viewChanged.dispatch();\n }\n\n private bindVisibleRenderLayer(\n renderLayer: SliceViewRenderLayer,\n disposers: Disposer[],\n ) {\n disposers.push(\n renderLayer.localPosition.changed.add(() =>\n this.invalidateVisibleChunks(),\n ),\n );\n disposers.push(renderLayer.redrawNeeded.add(this.viewChanged.dispatch));\n disposers.push(renderLayer.transform.changed.add(this.updateVisibleLayers));\n disposers.push(\n renderLayer.renderScaleTarget.changed.add(() =>\n this.invalidateVisibleSources(),\n ),\n );\n const { renderScaleHistogram } = renderLayer;\n if (renderScaleHistogram !== undefined) {\n disposers.push(renderScaleHistogram.visibility.add(this.visibility));\n }\n disposers.push(\n renderLayer.dataHistogramSpecifications.producerVisibility.add(\n this.visibility,\n ),\n );\n }\n\n private updateVisibleLayersNow() {\n if (this.wasDisposed) {\n return false;\n }\n if (!this.navigationState.valid) return false;\n // Used to determine which layers are no longer visible.\n const curUpdateGeneration = Date.now();\n const { visibleLayers, visibleLayerList } = this;\n const { displayDimensionRenderInfo } = this.projectionParameters.value;\n const rpc = this.rpc!;\n const rpcMessage: any = { id: this.rpcId };\n let changed = false;\n visibleLayerList.length = 0;\n for (const renderLayer of this.layerManager.readyRenderLayers()) {\n if (renderLayer instanceof SliceViewRenderLayer) {\n visibleLayerList.push(renderLayer);\n let layerInfo = visibleLayers.get(renderLayer);\n if (layerInfo === undefined) {\n const disposers: Disposer[] = [];\n const messages = new MessageList();\n layerInfo = {\n messages,\n allSources: this.getTransformedSources(renderLayer, messages),\n transformGeneration: renderLayer.transform.changed.count,\n visibleSources: [],\n disposers,\n lastSeenGeneration: curUpdateGeneration,\n displayDimensionRenderInfo,\n };\n disposers.push(renderLayer.messages.addChild(layerInfo.messages));\n visibleLayers.set(renderLayer.addRef(), layerInfo);\n this.bindVisibleRenderLayer(renderLayer, disposers);\n } else {\n layerInfo.lastSeenGeneration = curUpdateGeneration;\n const curTransformGeneration = renderLayer.transform.changed.count;\n if (\n layerInfo.transformGeneration === curTransformGeneration &&\n layerInfo.displayDimensionRenderInfo === displayDimensionRenderInfo\n ) {\n continue;\n }\n const allSources = layerInfo.allSources;\n layerInfo.allSources = this.getTransformedSources(\n renderLayer,\n layerInfo.messages,\n );\n disposeTransformedSources(renderLayer, allSources);\n layerInfo.visibleSources.length = 0;\n layerInfo.displayDimensionRenderInfo = displayDimensionRenderInfo;\n layerInfo.transformGeneration = curTransformGeneration;\n }\n rpcMessage.layerId = renderLayer.rpcId;\n rpcMessage.sources = serializeAllTransformedSources(\n layerInfo.allSources,\n );\n rpcMessage.displayDimensionRenderInfo = displayDimensionRenderInfo;\n this.flushBackendProjectionParameters();\n rpc.invoke(SLICEVIEW_ADD_VISIBLE_LAYER_RPC_ID, rpcMessage);\n changed = true;\n }\n }\n for (const [renderLayer, layerInfo] of visibleLayers) {\n if (layerInfo.lastSeenGeneration === curUpdateGeneration) continue;\n rpcMessage.layerId = renderLayer.rpcId;\n rpc.invoke(SLICEVIEW_REMOVE_VISIBLE_LAYER_RPC_ID, rpcMessage);\n visibleLayers.delete(renderLayer);\n disposeTransformedSources(renderLayer, layerInfo.allSources);\n invokeDisposers(layerInfo.disposers);\n renderLayer.dispose();\n changed = true;\n }\n if (changed) {\n this.visibleSourcesStale = true;\n }\n // Unconditionally call viewChanged, because layers may have been reordered even if the set of\n // sources is the same.\n this.viewChanged.dispatch();\n return changed;\n }\n\n invalidateVisibleChunks() {\n super.invalidateVisibleChunks();\n this.viewChanged.dispatch();\n }\n\n get valid() {\n return this.navigationState.valid;\n }\n\n private getOffscreenFramebufferWithHistograms(count: number) {\n const { offscreenFramebuffersWithHistograms } = this;\n let framebuffer = offscreenFramebuffersWithHistograms[count];\n if (framebuffer === undefined) {\n const { gl, histogramInputTextures, offscreenFramebuffer } = this;\n if (histogramInputTextures.length < count) {\n histogramInputTextures.push(\n ...makeTextureBuffers(\n gl,\n count - histogramInputTextures.length,\n WebGL2RenderingContext.R8,\n WebGL2RenderingContext.RED,\n ),\n );\n }\n const colorBuffers = [offscreenFramebuffer.colorBuffers[0].addRef()];\n for (let i = 0; i < count; ++i) {\n colorBuffers.push(histogramInputTextures[i].addRef());\n }\n framebuffer = this.registerDisposer(\n new FramebufferConfiguration(gl, {\n colorBuffers,\n depthBuffer: offscreenFramebuffer.depthBuffer!.addRef(),\n }),\n );\n offscreenFramebuffersWithHistograms[count] = framebuffer;\n }\n return framebuffer;\n }\n\n updateRendering() {\n const projectionParameters = this.projectionParameters.value;\n const { width, height } = projectionParameters;\n if (!this.renderingStale || !this.valid || width === 0 || height === 0) {\n return;\n }\n this.renderingStale = false;\n this.updateVisibleLayers.flush();\n this.updateVisibleSources();\n\n const { gl, offscreenFramebuffer } = this;\n\n offscreenFramebuffer.bind(width, height);\n gl.disable(gl.SCISSOR_TEST);\n\n gl.clearColor(0, 0, 0, 0);\n gl.colorMask(true, true, true, true);\n gl.clear(WebGL2RenderingContext.COLOR_BUFFER_BIT);\n let renderLayerNum = 0;\n const wireFrame = this.wireFrame.value;\n const renderContext = { sliceView: this, projectionParameters, wireFrame };\n for (const renderLayer of this.visibleLayerList) {\n const histogramCount = wireFrame\n ? 0\n : renderLayer.getDataHistogramCount();\n const framebuffer =\n this.getOffscreenFramebufferWithHistograms(histogramCount);\n framebuffer.bind(width, height);\n for (let i = 0; i < histogramCount; ++i) {\n gl.clearBufferfv(WebGL2RenderingContext.COLOR, 1 + i, kZeroVec4);\n }\n gl.enable(WebGL2RenderingContext.DEPTH_TEST);\n gl.depthFunc(WebGL2RenderingContext.LESS);\n gl.clearDepth(1);\n gl.clear(WebGL2RenderingContext.DEPTH_BUFFER_BIT);\n renderLayer.setGLBlendMode(gl, renderLayerNum);\n renderLayer.draw(renderContext);\n ++renderLayerNum;\n }\n gl.disable(WebGL2RenderingContext.BLEND);\n gl.disable(WebGL2RenderingContext.DEPTH_TEST);\n offscreenFramebuffer.unbind();\n }\n\n disposed() {\n for (const [renderLayer, layerInfo] of this.visibleLayers) {\n disposeTransformedSources(renderLayer, layerInfo.allSources);\n invokeDisposers(layerInfo.disposers);\n renderLayer.dispose();\n }\n this.visibleLayers.clear();\n this.visibleLayerList.length = 0;\n }\n\n getTransformedSources(\n layer: SliceViewRenderLayer,\n messages: MessageList,\n ): FrontendTransformedSource[][] {\n const transformedSources = getVolumetricTransformedSources(\n this.projectionParameters.value.displayDimensionRenderInfo,\n layer.transform.value,\n (options) => layer.getSources(options),\n messages,\n layer,\n );\n for (const scales of transformedSources) {\n for (const tsource of scales) {\n layer.addSource(tsource.source, tsource.chunkTransform);\n }\n }\n return transformedSources;\n }\n}\n\nexport interface SliceViewChunkSourceOptions<\n Spec extends SliceViewChunkSpecification = SliceViewChunkSpecification,\n> {\n spec: Spec;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging\nexport abstract class SliceViewChunkSource<\n Spec extends SliceViewChunkSpecification = SliceViewChunkSpecification,\n ChunkType extends SliceViewChunk = SliceViewChunk,\n >\n extends ChunkSource\n implements SliceViewChunkSourceInterface\n{\n chunks: Map;\n\n OPTIONS: SliceViewChunkSourceOptions;\n\n spec: Spec;\n\n constructor(\n chunkManager: ChunkManager,\n options: SliceViewChunkSourceOptions,\n ) {\n super(chunkManager, options);\n this.spec = options.spec;\n }\n\n static encodeSpec(spec: SliceViewChunkSpecification) {\n return {\n chunkDataSize: Array.from(spec.chunkDataSize),\n lowerVoxelBound: Array.from(spec.lowerVoxelBound),\n upperVoxelBound: Array.from(spec.upperVoxelBound),\n };\n }\n\n static encodeOptions(options: SliceViewChunkSourceOptions): any {\n const encoding = ChunkSource.encodeOptions(options);\n encoding.spec = SliceViewChunkSource.encodeSpec(options.spec);\n return encoding;\n }\n\n initializeCounterpart(rpc: RPC, options: any) {\n options.spec = this.spec;\n super.initializeCounterpart(rpc, options);\n }\n\n // Requests a chunk by its grid position, and returns the result of `transform(chunk)`, where\n // `transform` is guaranteed to be called while the chunk is present in system memory.\n //\n // The `transform` function is used in place of simply returning the chunk, because it is not\n // possible to guarantee that the chunk remains in system memory by the time the promise resolves.\n async fetchChunk(\n chunkGridPosition: Float32Array,\n transform: (chunk: Chunk) => T,\n cancellationToken: CancellationToken = uncancelableToken,\n ): Promise {\n const key = chunkGridPosition.join();\n const existingChunk = this.chunks.get(key);\n if (\n existingChunk !== undefined &&\n existingChunk.state <= ChunkState.SYSTEM_MEMORY\n ) {\n return transform(existingChunk);\n }\n this.addRef();\n let { chunkRequesters } = this;\n if (chunkRequesters === undefined) {\n chunkRequesters = this.chunkRequesters = new Map();\n }\n let requester: ChunkRequesterState;\n let entry = chunkRequesters!.get(key);\n if (entry === undefined) {\n entry = [];\n chunkRequesters!.set(key, entry);\n }\n const promise = new Promise((resolve) => {\n requester = (chunk) => resolve(transform(chunk));\n entry!.push(requester);\n });\n try {\n await this.rpc!.promiseInvoke(\n SLICEVIEW_REQUEST_CHUNK_RPC_ID,\n { source: this.rpcId, chunkGridPosition },\n cancellationToken,\n );\n return await promise;\n } finally {\n const entryIndex = entry.indexOf(requester!);\n entry.splice(entryIndex, 1);\n if (entry.length === 0) {\n chunkRequesters!.delete(key);\n }\n if (chunkRequesters.size === 0) {\n this.chunkRequesters = undefined;\n }\n this.dispose();\n }\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging\nexport interface SliceViewChunkSource {\n // TODO(jbms): Move this declaration to the class definition above and declare abstract once\n // TypeScript supports mixins with abstact classes.\n getChunk(x: any): any;\n}\n\nexport class SliceViewChunk extends Chunk {\n chunkGridPosition: vec3;\n source: SliceViewChunkSource;\n\n constructor(source: SliceViewChunkSource, x: any) {\n super(source);\n this.chunkGridPosition = x.chunkGridPosition;\n this.state = ChunkState.SYSTEM_MEMORY;\n }\n}\n\n/**\n * Helper for rendering a SliceView that has been pre-rendered to a texture.\n */\nexport class SliceViewRenderHelper extends RefCounted {\n private copyVertexPositionsBuffer = getSquareCornersBuffer(this.gl);\n private shader: ShaderProgram;\n\n private textureCoordinateAdjustment = new Float32Array(4);\n\n constructor(\n public gl: GL,\n emitter: ShaderModule,\n ) {\n super();\n const builder = new ShaderBuilder(gl);\n builder.addVarying(\"vec2\", \"vTexCoord\");\n builder.addUniform(\"sampler2D\", \"uSampler\");\n builder.addInitializer((shader) => {\n gl.uniform1i(shader.uniform(\"uSampler\"), 0);\n });\n builder.addUniform(\"vec4\", \"uColorFactor\");\n builder.addUniform(\"vec4\", \"uBackgroundColor\");\n builder.addUniform(\"mat4\", \"uProjectionMatrix\");\n builder.addUniform(\"vec4\", \"uTextureCoordinateAdjustment\");\n builder.require(emitter);\n builder.setFragmentMain(`\nvec4 sampledColor = texture(uSampler, vTexCoord);\nif (sampledColor.a == 0.0) {\n sampledColor = uBackgroundColor;\n}\nemit(sampledColor * uColorFactor, 0u);\n`);\n builder.addAttribute(\"vec4\", \"aVertexPosition\");\n builder.setVertexMain(`\nvTexCoord = uTextureCoordinateAdjustment.xy + 0.5 * (aVertexPosition.xy + 1.0) * uTextureCoordinateAdjustment.zw;\ngl_Position = uProjectionMatrix * aVertexPosition;\n`);\n this.shader = this.registerDisposer(builder.build());\n }\n\n draw(\n texture: WebGLTexture | null,\n projectionMatrix: mat4,\n colorFactor: vec4,\n backgroundColor: vec4,\n xStart: number,\n yStart: number,\n xEnd: number,\n yEnd: number,\n ) {\n const { gl, shader, textureCoordinateAdjustment } = this;\n textureCoordinateAdjustment[0] = xStart;\n textureCoordinateAdjustment[1] = yStart;\n textureCoordinateAdjustment[2] = xEnd - xStart;\n textureCoordinateAdjustment[3] = yEnd - yStart;\n shader.bind();\n gl.activeTexture(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.disable(WebGL2RenderingContext.BLEND);\n gl.uniformMatrix4fv(\n shader.uniform(\"uProjectionMatrix\"),\n false,\n projectionMatrix,\n );\n gl.uniform4fv(shader.uniform(\"uColorFactor\"), colorFactor);\n gl.uniform4fv(shader.uniform(\"uBackgroundColor\"), backgroundColor);\n gl.uniform4fv(\n shader.uniform(\"uTextureCoordinateAdjustment\"),\n textureCoordinateAdjustment,\n );\n\n const aVertexPosition = shader.attribute(\"aVertexPosition\");\n this.copyVertexPositionsBuffer.bindToVertexAttrib(\n aVertexPosition,\n /*components=*/ 2,\n );\n\n gl.drawArrays(gl.TRIANGLE_FAN, 0, 4);\n\n gl.disableVertexAttribArray(aVertexPosition);\n gl.bindTexture(gl.TEXTURE_2D, null);\n }\n\n static get(gl: GL, emitter: ShaderModule) {\n return gl.memoize.get(\n `sliceview/SliceViewRenderHelper:${getObjectId(emitter)}`,\n () => new SliceViewRenderHelper(gl, emitter),\n );\n }\n}\n\nexport interface SliceViewSingleResolutionSource<\n Source extends SliceViewChunkSource = SliceViewChunkSource,\n> {\n chunkSource: Source;\n\n /**\n * (rank + 1)*(rank + 1) homogeneous transformation matrix from the \"chunk\" coordinate space to\n * the MultiscaleSliceViewChunkSource space.\n */\n chunkToMultiscaleTransform: Float32Array;\n\n /**\n * Lower clipping bound in voxels within the \"chunk\" coordinate space. If not specified, defaults\n * to `chunkSource.spec.lowerVoxelBound`. Non-integer values are supported.\n *\n * Both lowerClipBound and upperClipBound are applied during rendering but do not affect which\n * chunks/voxels are actually retrieved. That is determined by lowerVoxelBound and\n * upperVoxelBound of `chunkSource.spec`.\n */\n lowerClipBound?: Float32Array;\n\n /**\n * Upper clipping bound in voxels within the \"chunk\" coordinate space. If not specified, defaults\n * to `chunkSource.spec.upperVoxelBound`.\n */\n upperClipBound?: Float32Array;\n}\n\nexport abstract class MultiscaleSliceViewChunkSource<\n Source extends SliceViewChunkSource = SliceViewChunkSource,\n SourceOptions extends SliceViewSourceOptions = SliceViewSourceOptions,\n> {\n abstract get rank(): number;\n\n /**\n * @return Chunk sources for each scale, ordered by increasing minVoxelSize. Outer array indexes\n * over alternative chunk orientations. The inner array indexes over scale.\n *\n * Every chunk source must have rank equal to `this.rank`.\n */\n abstract getSources(\n options: SourceOptions,\n ): SliceViewSingleResolutionSource[][];\n\n constructor(public chunkManager: Borrowed) {}\n}\n\nexport function getVolumetricTransformedSources(\n displayDimensionRenderInfo: DisplayDimensionRenderInfo,\n transform: RenderLayerTransformOrError,\n getSources: (\n options: SliceViewSourceOptions,\n ) => SliceViewSingleResolutionSource[][],\n messages: MessageList,\n layer: any,\n): FrontendTransformedSource[][] {\n messages.clearMessages();\n const returnError = (message: string) => {\n messages.addMessage({\n severity: MessageSeverity.error,\n message,\n });\n return [];\n };\n if (transform.error !== undefined) {\n return returnError(transform.error);\n }\n const layerRank = transform.rank;\n const chunkRank = transform.unpaddedRank;\n const { displayDimensionIndices, displayRank, canonicalVoxelFactors } =\n displayDimensionRenderInfo;\n const layerDisplayDimensionMapping = getLayerDisplayDimensionMapping(\n transform,\n displayDimensionIndices,\n );\n\n const { displayToLayerDimensionIndices } = layerDisplayDimensionMapping;\n const multiscaleToViewTransform = new Float32Array(displayRank * chunkRank);\n const { modelToRenderLayerTransform } = transform;\n for (let displayDim = 0; displayDim < displayRank; ++displayDim) {\n const layerDim = displayToLayerDimensionIndices[displayDim];\n if (layerDim === -1) continue;\n const factor = canonicalVoxelFactors[displayDim];\n for (let chunkDim = 0; chunkDim < chunkRank; ++chunkDim) {\n multiscaleToViewTransform[displayRank * chunkDim + displayDim] =\n modelToRenderLayerTransform[(layerRank + 1) * chunkDim + layerDim] *\n factor;\n }\n }\n const allSources = getSources({\n displayRank: displayRank,\n multiscaleToViewTransform: multiscaleToViewTransform,\n modelChannelDimensionIndices: transform.channelToRenderLayerDimensions,\n });\n const { voxelPhysicalScales: globalScales } = displayDimensionRenderInfo;\n try {\n const getTransformedSource = (\n singleResolutionSource: SliceViewSingleResolutionSource,\n ): FrontendTransformedSource => {\n const { chunkSource: source } = singleResolutionSource;\n const { spec } = source;\n const {\n lowerClipBound = spec.lowerVoxelBound,\n upperClipBound = spec.upperVoxelBound,\n } = singleResolutionSource;\n const chunkTransform = getChunkTransformParameters(\n transform,\n singleResolutionSource.chunkToMultiscaleTransform,\n );\n const { chunkDataSize } = spec;\n const { channelToChunkDimensionIndices } = chunkTransform;\n const nonDisplayLowerClipBound = new Float32Array(chunkRank);\n const nonDisplayUpperClipBound = new Float32Array(chunkRank);\n nonDisplayLowerClipBound.set(lowerClipBound);\n nonDisplayUpperClipBound.set(upperClipBound);\n const channelRank = channelToChunkDimensionIndices.length;\n const { channelSpaceShape } = transform;\n for (let channelDim = 0; channelDim < channelRank; ++channelDim) {\n const chunkDim = channelToChunkDimensionIndices[channelDim];\n if (chunkDim === -1) continue;\n const size = channelSpaceShape[channelDim];\n if (chunkDataSize[chunkDim] !== size) {\n throw new Error(\n \"Channel dimension \" +\n transform.layerDimensionNames[\n transform.channelToRenderLayerDimensions[channelDim]\n ] +\n ` has extent ${size} but corresponding chunk dimension has extent ` +\n `${chunkDataSize[chunkDim]}`,\n );\n }\n nonDisplayLowerClipBound[chunkDim] = Number.NEGATIVE_INFINITY;\n nonDisplayUpperClipBound[chunkDim] = Number.POSITIVE_INFINITY;\n }\n const chunkDisplayTransform = getChunkDisplayTransformParameters(\n chunkTransform,\n layerDisplayDimensionMapping,\n );\n // Compute `chunkDisplaySize`, and `{lower,upper}ChunkDisplayBound`.\n const lowerChunkDisplayBound = vec3.create();\n const upperChunkDisplayBound = vec3.create();\n const lowerClipDisplayBound = vec3.create();\n const upperClipDisplayBound = vec3.create();\n // Size of chunk in \"display\" coordinate space.\n const chunkDisplaySize = vec3.create();\n const { numChunkDisplayDims, chunkDisplayDimensionIndices } =\n chunkDisplayTransform;\n const {\n combinedGlobalLocalToChunkTransform,\n layerRank,\n combinedGlobalLocalRank,\n } = chunkTransform;\n const fixedLayerToChunkTransform = new Float32Array(\n combinedGlobalLocalToChunkTransform,\n );\n for (\n let chunkDisplayDimIndex = 0;\n chunkDisplayDimIndex < numChunkDisplayDims;\n ++chunkDisplayDimIndex\n ) {\n const chunkDim = chunkDisplayDimensionIndices[chunkDisplayDimIndex];\n for (let i = 0; i <= combinedGlobalLocalRank; ++i) {\n fixedLayerToChunkTransform[chunkDim + i * layerRank] = 0;\n }\n if (chunkDim < chunkRank) {\n chunkDisplaySize[chunkDisplayDimIndex] = spec.chunkDataSize[chunkDim];\n lowerChunkDisplayBound[chunkDisplayDimIndex] =\n spec.lowerChunkBound[chunkDim];\n upperChunkDisplayBound[chunkDisplayDimIndex] =\n spec.upperChunkBound[chunkDim];\n lowerClipDisplayBound[chunkDisplayDimIndex] =\n lowerClipBound[chunkDim];\n upperClipDisplayBound[chunkDisplayDimIndex] =\n upperClipBound[chunkDim];\n nonDisplayLowerClipBound[chunkDim] = Number.NEGATIVE_INFINITY;\n nonDisplayUpperClipBound[chunkDim] = Number.POSITIVE_INFINITY;\n } else {\n chunkDisplaySize[chunkDisplayDimIndex] = 1;\n lowerChunkDisplayBound[chunkDisplayDimIndex] = 0;\n upperChunkDisplayBound[chunkDisplayDimIndex] = 1;\n lowerClipDisplayBound[chunkDisplayDimIndex] = 0;\n upperClipDisplayBound[chunkDisplayDimIndex] = 1;\n }\n }\n chunkDisplaySize.fill(1, numChunkDisplayDims);\n lowerChunkDisplayBound.fill(0, numChunkDisplayDims);\n upperChunkDisplayBound.fill(1, numChunkDisplayDims);\n lowerClipDisplayBound.fill(0, numChunkDisplayDims);\n upperClipDisplayBound.fill(1, numChunkDisplayDims);\n const chunkLayout = new ChunkLayout(\n chunkDisplaySize,\n chunkDisplayTransform.displaySubspaceModelMatrix,\n numChunkDisplayDims,\n );\n // This is an approximation of the voxel size (exact only for permutation/scaling\n // transforms). It would be better to model the voxel as an ellipsiod and find the\n // lengths of the axes.\n const effectiveVoxelSize = chunkLayout.localSpatialVectorToGlobal(\n vec3.create(),\n /*baseVoxelSize=*/ kOneVec,\n );\n for (let i = 0; i < displayRank; ++i) {\n effectiveVoxelSize[i] = Math.abs(\n effectiveVoxelSize[i] * globalScales[i],\n );\n }\n effectiveVoxelSize.fill(1, displayRank);\n return {\n layerRank,\n lowerClipBound,\n upperClipBound,\n nonDisplayLowerClipBound,\n nonDisplayUpperClipBound,\n renderLayer: layer,\n source,\n lowerChunkDisplayBound,\n upperChunkDisplayBound,\n lowerClipDisplayBound,\n upperClipDisplayBound,\n effectiveVoxelSize,\n chunkLayout,\n chunkDisplayDimensionIndices,\n fixedLayerToChunkTransform,\n curPositionInChunks: new Float32Array(chunkRank),\n combinedGlobalLocalToChunkTransform:\n chunkTransform.combinedGlobalLocalToChunkTransform,\n fixedPositionWithinChunk: new Uint32Array(chunkRank),\n chunkTransform,\n chunkDisplayTransform,\n };\n };\n return allSources.map((scales) =>\n scales.map((s) => getTransformedSource(s)),\n );\n } catch (e) {\n // Ensure references are released in the case of an exception.\n for (const scales of allSources) {\n for (const { chunkSource: source } of scales) {\n source.dispose();\n }\n }\n const { globalDimensionNames } = displayDimensionRenderInfo;\n const dimensionDesc = Array.from(\n displayDimensionRenderInfo.displayDimensionIndices.filter(\n (i) => i !== -1,\n ),\n (i) => globalDimensionNames[i],\n ).join(\",\\u00a0\");\n const message = `Cannot render (${dimensionDesc}) cross section: ${e.message}`;\n return returnError(message);\n }\n}\n","/**\n * @license\n * Copyright 2018 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { AnnotationGeometryChunkSpecification } from \"#src/annotation/base.js\";\nimport {\n ANNOTATION_COMMIT_UPDATE_RESULT_RPC_ID,\n ANNOTATION_COMMIT_UPDATE_RPC_ID,\n ANNOTATION_GEOMETRY_CHUNK_SOURCE_RPC_ID,\n ANNOTATION_METADATA_CHUNK_SOURCE_RPC_ID,\n ANNOTATION_REFERENCE_ADD_RPC_ID,\n ANNOTATION_REFERENCE_DELETE_RPC_ID,\n ANNOTATION_SUBSET_GEOMETRY_CHUNK_SOURCE_RPC_ID,\n} from \"#src/annotation/base.js\";\nimport type {\n Annotation,\n AnnotationId,\n AnnotationPropertySerializer,\n AnnotationPropertySpec,\n AnnotationSourceSignals,\n SerializedAnnotations,\n} from \"#src/annotation/index.js\";\nimport {\n AnnotationReference,\n AnnotationType,\n annotationTypeHandlers,\n annotationTypes,\n fixAnnotationAfterStructuredCloning,\n makeAnnotationId,\n makeAnnotationPropertySerializers,\n} from \"#src/annotation/index.js\";\nimport { getAnnotationTypeRenderHandler } from \"#src/annotation/type_handler.js\";\nimport type { ChunkManager } from \"#src/chunk_manager/frontend.js\";\nimport { Chunk, ChunkSource } from \"#src/chunk_manager/frontend.js\";\nimport { getObjectKey } from \"#src/segmentation_display_state/base.js\";\nimport type { SliceViewSourceOptions } from \"#src/sliceview/base.js\";\nimport type {\n MultiscaleSliceViewChunkSource,\n SliceViewChunkSourceOptions,\n SliceViewSingleResolutionSource,\n} from \"#src/sliceview/frontend.js\";\nimport {\n SliceViewChunk,\n SliceViewChunkSource,\n} from \"#src/sliceview/frontend.js\";\nimport { StatusMessage } from \"#src/status.js\";\nimport { WatchableValue } from \"#src/trackable_value.js\";\nimport type { Borrowed, Owned } from \"#src/util/disposable.js\";\nimport { ENDIANNESS, Endianness } from \"#src/util/endian.js\";\nimport * as matrix from \"#src/util/matrix.js\";\nimport type { Signal } from \"#src/util/signal.js\";\nimport { NullarySignal } from \"#src/util/signal.js\";\nimport type { Buffer } from \"#src/webgl/buffer.js\";\nimport type { GL } from \"#src/webgl/context.js\";\nimport type { RPC } from \"#src/worker_rpc.js\";\nimport {\n registerRPC,\n registerSharedObjectOwner,\n SharedObject,\n} from \"#src/worker_rpc.js\";\n\nexport interface AnnotationGeometryChunkSourceOptions\n extends SliceViewChunkSourceOptions {\n spec: AnnotationGeometryChunkSpecification;\n parent: Borrowed;\n}\n\nexport function computeNumPickIds(\n serializedAnnotations: SerializedAnnotations,\n) {\n let numPickIds = 0;\n const { typeToIds } = serializedAnnotations;\n for (const annotationType of annotationTypes) {\n numPickIds +=\n getAnnotationTypeRenderHandler(annotationType).pickIdsPerInstance *\n typeToIds[annotationType].length;\n }\n return numPickIds;\n}\n\nexport class AnnotationGeometryData {\n buffer: Buffer | undefined;\n bufferValid = false;\n serializedAnnotations: SerializedAnnotations;\n numPickIds = 0;\n\n constructor(x: SerializedAnnotations) {\n this.serializedAnnotations = {\n data: x.data,\n typeToIds: x.typeToIds,\n typeToOffset: x.typeToOffset,\n typeToIdMaps: x.typeToIdMaps,\n };\n }\n freeGPUMemory(gl: GL) {\n gl;\n const { buffer } = this;\n if (buffer !== undefined) {\n buffer.dispose();\n this.bufferValid = false;\n this.buffer = undefined;\n }\n }\n}\n\nexport class AnnotationSubsetGeometryChunk extends Chunk {\n source: AnnotationSubsetGeometryChunkSource;\n // undefined indicates chunk not found\n data: AnnotationGeometryData | undefined;\n constructor(source: AnnotationSubsetGeometryChunkSource, x: any) {\n super(source);\n if (x.data !== undefined) {\n this.data = new AnnotationGeometryData(x);\n }\n }\n\n freeGPUMemory(gl: GL) {\n super.freeGPUMemory(gl);\n const { data } = this;\n if (data !== undefined) {\n data.freeGPUMemory(gl);\n }\n }\n\n dispose() {\n this.data = undefined;\n }\n}\n\nexport class AnnotationGeometryChunk extends SliceViewChunk {\n source: AnnotationGeometryChunkSource;\n // undefined indicates chunk not found\n data: AnnotationGeometryData | undefined;\n\n constructor(source: AnnotationGeometryChunkSource, x: any) {\n super(source, x);\n if (x.data !== undefined) {\n this.data = new AnnotationGeometryData(x);\n }\n }\n\n freeGPUMemory(gl: GL) {\n super.freeGPUMemory(gl);\n const { data } = this;\n if (data !== undefined) {\n data.freeGPUMemory(gl);\n }\n }\n\n dispose() {\n this.data = undefined;\n }\n}\n\n@registerSharedObjectOwner(ANNOTATION_GEOMETRY_CHUNK_SOURCE_RPC_ID)\nexport class AnnotationGeometryChunkSource extends SliceViewChunkSource<\n AnnotationGeometryChunkSpecification,\n AnnotationGeometryChunk\n> {\n OPTIONS: AnnotationGeometryChunkSourceOptions;\n parent: Borrowed;\n immediateChunkUpdates = true;\n\n /**\n * Transforms positions in the MultiscaleAnnotationSource coordinate space to grid cell\n * coordinates. Equal to the inverse of `this.spec.chunkToMultiscaleTransform`, with rows divided\n * by `this.spec.chunkDataSize`.\n */\n multiscaleToChunkTransform: Float32Array;\n\n constructor(\n chunkManager: Borrowed,\n options: AnnotationGeometryChunkSourceOptions,\n ) {\n super(chunkManager, options);\n const parent = (this.parent = options.parent);\n parent.spatiallyIndexedSources.add(this);\n const { rank, chunkDataSize } = this.spec;\n const multiscaleToChunkTransform = (this.multiscaleToChunkTransform =\n new Float32Array((rank + 1) ** 2));\n matrix.inverse(\n multiscaleToChunkTransform,\n rank + 1,\n this.spec.chunkToMultiscaleTransform,\n rank + 1,\n rank + 1,\n );\n for (let i = 0; i < rank; ++i) {\n for (let j = 0; j < rank + 1; ++j) {\n multiscaleToChunkTransform[(rank + 1) * j + i] /= chunkDataSize[i];\n }\n }\n }\n\n disposed() {\n this.parent.spatiallyIndexedSources.delete(this);\n super.disposed();\n }\n\n initializeCounterpart(rpc: RPC, options: any) {\n options.parent = this.parent.rpcId;\n super.initializeCounterpart(rpc, options);\n }\n\n addChunk(key: string, chunk: AnnotationGeometryChunk) {\n super.addChunk(key, chunk);\n // TODO: process local deletions\n }\n\n getChunk(x: any) {\n return new AnnotationGeometryChunk(this, x);\n }\n}\n\n@registerSharedObjectOwner(ANNOTATION_SUBSET_GEOMETRY_CHUNK_SOURCE_RPC_ID)\nexport class AnnotationSubsetGeometryChunkSource extends ChunkSource {\n immediateChunkUpdates = true;\n chunks: Map;\n\n constructor(\n chunkManager: Borrowed,\n public parent: Borrowed,\n public relationshipIndex: number,\n ) {\n super(chunkManager, {});\n }\n\n addChunk(key: string, chunk: AnnotationSubsetGeometryChunk) {\n super.addChunk(key, chunk);\n // TODO: process local deletions\n }\n\n getChunk(x: any): AnnotationSubsetGeometryChunk {\n return new AnnotationSubsetGeometryChunk(this, x);\n }\n}\n\nexport class AnnotationMetadataChunk extends Chunk {\n annotation: Annotation | null;\n constructor(source: Borrowed, x: any) {\n super(source);\n this.annotation = fixAnnotationAfterStructuredCloning(x.annotation);\n }\n}\n\n@registerSharedObjectOwner(ANNOTATION_METADATA_CHUNK_SOURCE_RPC_ID)\nexport class AnnotationMetadataChunkSource extends ChunkSource {\n chunks: Map;\n constructor(\n chunkManager: Borrowed,\n public parent: Borrowed,\n ) {\n super(chunkManager);\n }\n getChunk(x: any): AnnotationMetadataChunk {\n return new AnnotationMetadataChunk(this, x);\n }\n addChunk(key: string, chunk: AnnotationMetadataChunk) {\n super.addChunk(key, chunk);\n const { references } = this.parent;\n const reference = references.get(key);\n if (reference !== undefined) {\n reference.value = chunk.annotation;\n reference.changed.dispatch();\n }\n }\n deleteChunk(key: string) {\n const { references } = this.parent;\n const reference = references.get(key);\n if (reference !== undefined) {\n reference.value = undefined;\n reference.changed.dispatch();\n }\n }\n}\n\nfunction copyOtherAnnotations(\n serializedAnnotations: SerializedAnnotations,\n propertySerializers: AnnotationPropertySerializer[],\n excludedType: AnnotationType,\n excludedTypeAdjustment: number,\n): Uint8Array {\n const newData = new Uint8Array(\n serializedAnnotations.data.length + excludedTypeAdjustment,\n );\n // Copy all other annotation types\n for (const otherType of annotationTypes) {\n if (otherType === excludedType) continue;\n const otherTypeOffset = serializedAnnotations.typeToOffset![otherType];\n let newTypeOffset = otherTypeOffset;\n if (otherType > excludedType) {\n newTypeOffset += excludedTypeAdjustment;\n serializedAnnotations.typeToOffset![otherType] = newTypeOffset;\n }\n newData.set(\n serializedAnnotations.data.subarray(\n otherTypeOffset,\n otherTypeOffset +\n serializedAnnotations.typeToIds[otherType].length *\n propertySerializers[otherType].serializedBytes,\n ),\n newTypeOffset,\n );\n }\n return newData;\n}\n\nfunction copyAnnotationSlice(\n serializedAnnotations: SerializedAnnotations,\n propertySerializers: AnnotationPropertySerializer[],\n type: AnnotationType,\n dest: Uint8Array,\n sourceBeginIndex: number,\n sourceEndIndex: number,\n destBeginIndex: number,\n destCount: number,\n) {\n const typeOffset = serializedAnnotations.typeToOffset[type];\n let sourceGroupOffset = typeOffset;\n let destGroupOffset = typeOffset;\n const { propertyGroupBytes } = propertySerializers[type];\n const numGroups = propertyGroupBytes.length;\n const count = serializedAnnotations.typeToIds[type].length;\n for (let groupIndex = 0; groupIndex < numGroups; ++groupIndex) {\n const groupBytes = propertyGroupBytes[groupIndex];\n dest.set(\n serializedAnnotations.data.subarray(\n sourceGroupOffset + sourceBeginIndex * groupBytes,\n sourceGroupOffset + sourceEndIndex * groupBytes,\n ),\n destGroupOffset + destBeginIndex * groupBytes,\n );\n sourceGroupOffset += groupBytes * count;\n destGroupOffset += groupBytes * destCount;\n }\n}\n\nexport function updateAnnotation(\n chunk: AnnotationGeometryData,\n annotation: Annotation,\n propertySerializers: AnnotationPropertySerializer[],\n) {\n // Find insertion point.\n const type = annotation.type;\n const { rank } = propertySerializers[type];\n const { serializedAnnotations } = chunk;\n const ids = serializedAnnotations.typeToIds[type];\n const idMap = serializedAnnotations.typeToIdMaps[type];\n const handler = annotationTypeHandlers[type];\n const numBytes = propertySerializers[type].serializedBytes;\n let index = idMap.get(annotation.id);\n if (index === undefined) {\n // Doesn't already exist.\n index = idMap.size;\n idMap.set(annotation.id, index);\n const newData = copyOtherAnnotations(\n serializedAnnotations,\n propertySerializers,\n type,\n numBytes,\n );\n copyAnnotationSlice(\n serializedAnnotations,\n propertySerializers,\n type,\n newData,\n /*sourceBeginIndex=*/ 0,\n /*sourceEndIndex=*/ index,\n /*destBeginIndex=*/ 0,\n /*destCount=*/ index + 1,\n );\n ids.push(annotation.id);\n serializedAnnotations.data = newData;\n }\n const bufferOffset = serializedAnnotations.typeToOffset![type];\n const dv = new DataView(\n serializedAnnotations.data.buffer,\n serializedAnnotations.data.byteOffset,\n serializedAnnotations.data.byteLength,\n );\n const isLittleEndian = ENDIANNESS === Endianness.LITTLE;\n const propertySerializer = propertySerializers[type];\n handler.serialize(\n dv,\n bufferOffset + propertySerializer.propertyGroupBytes[0] * index,\n isLittleEndian,\n rank,\n annotation,\n );\n propertySerializer.serialize(\n dv,\n bufferOffset,\n index,\n ids.length,\n isLittleEndian,\n annotation.properties,\n );\n chunk.bufferValid = false;\n}\n\nexport function deleteAnnotation(\n chunk: AnnotationGeometryData,\n type: AnnotationType,\n id: AnnotationId,\n propertySerializers: AnnotationPropertySerializer[],\n): boolean {\n const { serializedAnnotations } = chunk;\n const idMap = serializedAnnotations.typeToIdMaps[type];\n const index = idMap.get(id);\n if (index === undefined) {\n return false;\n }\n const ids = serializedAnnotations.typeToIds[type];\n const numBytes = propertySerializers[type].serializedBytes;\n const newData = copyOtherAnnotations(\n serializedAnnotations,\n propertySerializers,\n type,\n -numBytes,\n );\n copyAnnotationSlice(\n serializedAnnotations,\n propertySerializers,\n type,\n newData,\n /*sourceBeginIndex=*/ 0,\n /*sourceEndIndex=*/ index,\n /*destBeginIndex=*/ 0,\n /*destCount=*/ ids.length - 1,\n );\n copyAnnotationSlice(\n serializedAnnotations,\n propertySerializers,\n type,\n newData,\n /*sourceBeginIndex=*/ index + 1,\n /*sourceEndIndex=*/ ids.length,\n /*destBeginIndex=*/ index,\n /*destCount=*/ ids.length - 1,\n );\n ids.splice(index, 1);\n idMap.delete(id);\n for (let i = index, count = ids.length; i < count; ++i) {\n idMap.set(ids[i], i);\n }\n serializedAnnotations.data = newData;\n chunk.bufferValid = false;\n return true;\n}\n\ninterface LocalUpdateUndoState {\n /**\n * If commitInProgress === undefined, this must be undefined. Otherwise, it specifies a commit\n * that has been requested and which will be initiated as soon as the in-progress request\n * completes.\n */\n pendingCommit: Annotation | null | undefined;\n\n reference: Owned;\n\n /**\n * The state of the annotation prior to any local modifications.\n */\n existingAnnotation: Annotation | undefined;\n\n /**\n * If not undefined, a commit has been sent to the backend, and we are waiting for the result.\n */\n commitInProgress: Annotation | null | undefined;\n type: AnnotationType;\n}\n\nexport function makeTemporaryChunk() {\n const typeToIds: string[][] = [];\n const typeToOffset: number[] = [];\n const typeToIdMaps: Map[] = [];\n for (const annotationType of annotationTypes) {\n typeToIds[annotationType] = [];\n typeToOffset[annotationType] = 0;\n typeToIdMaps[annotationType] = new Map();\n }\n return new AnnotationGeometryChunk(\n (undefined),\n {\n data: new Uint8Array(0),\n numPickIds: 0,\n typeToOffset,\n typeToIds,\n typeToIdMaps,\n },\n );\n}\n\nexport class MultiscaleAnnotationSource\n extends SharedObject\n implements\n MultiscaleSliceViewChunkSource,\n AnnotationSourceSignals\n{\n OPTIONS: object;\n key: any;\n metadataChunkSource = this.registerDisposer(\n new AnnotationMetadataChunkSource(this.chunkManager, this),\n );\n segmentFilteredSources: Owned[];\n spatiallyIndexedSources = new Set>();\n rank: number;\n readonly relationships: readonly string[];\n readonly properties: WatchableValue<\n readonly Readonly[]\n >;\n readonly annotationPropertySerializers: AnnotationPropertySerializer[];\n constructor(\n public chunkManager: Borrowed,\n options: {\n rank: number;\n relationships: readonly string[];\n properties: Readonly[];\n },\n ) {\n super();\n this.rank = options.rank;\n this.properties = new WatchableValue(options.properties);\n this.annotationPropertySerializers = makeAnnotationPropertySerializers(\n this.rank,\n this.properties.value,\n );\n const segmentFilteredSources: Owned[] =\n (this.segmentFilteredSources = []);\n const { relationships } = options;\n this.relationships = relationships;\n for (let i = 0, count = relationships.length; i < count; ++i) {\n segmentFilteredSources.push(\n this.registerDisposer(\n new AnnotationSubsetGeometryChunkSource(chunkManager, this, i),\n ),\n );\n }\n }\n\n hasNonSerializedProperties() {\n return this.relationships.length > 0;\n }\n\n getSources(\n _options: SliceViewSourceOptions,\n ): SliceViewSingleResolutionSource[][] {\n throw new Error(\"not implemented\");\n }\n\n temporary = makeTemporaryChunk();\n\n references = new Map>();\n\n localUpdates = new Map();\n\n initializeCounterpart(rpc: RPC, options: any) {\n this.metadataChunkSource.initializeCounterpart(rpc, {});\n for (const source of this.segmentFilteredSources) {\n source.initializeCounterpart(rpc, {});\n }\n options.segmentFilteredSource = this.segmentFilteredSources.map((x) =>\n x.addCounterpartRef(),\n );\n options.metadataChunkSource = this.metadataChunkSource.addCounterpartRef();\n options.chunkManager = this.chunkManager.rpcId;\n super.initializeCounterpart(rpc, options);\n }\n\n add(annotation: Annotation, commit = true): AnnotationReference {\n annotation.id = makeAnnotationId();\n const reference = new AnnotationReference(annotation.id);\n reference.value = annotation;\n this.references.set(reference.id, reference);\n reference.registerDisposer(() => {\n this.references.delete(reference.id);\n });\n this.applyLocalUpdate(\n reference,\n /*existing=*/ false,\n /*commit=*/ commit,\n /*newAnnotation=*/ annotation,\n );\n return reference;\n }\n\n private applyLocalUpdate(\n reference: Borrowed,\n existing: boolean,\n commit: boolean,\n newAnnotation: Annotation | null,\n ): void {\n const { localUpdates } = this;\n const { id } = reference;\n let localUpdate = this.localUpdates.get(id);\n const annotation = reference.value;\n if (annotation == null) {\n throw new Error(\"Cannot create local update from null annotation\");\n }\n if (localUpdate === undefined) {\n localUpdate = {\n type: annotation.type,\n reference: reference.addRef(),\n existingAnnotation: existing ? annotation : undefined,\n pendingCommit: undefined,\n commitInProgress: undefined,\n };\n localUpdates.set(id, localUpdate);\n this.forEachPossibleChunk(annotation, (chunk) => {\n const { data } = chunk;\n if (data === undefined) return;\n const annotationType = annotation.type;\n deleteAnnotation(\n data,\n annotationType,\n id,\n this.annotationPropertySerializers,\n );\n });\n if (newAnnotation !== null) {\n // Add to temporary chunk.\n updateAnnotation(\n this.temporary.data!,\n newAnnotation,\n this.annotationPropertySerializers,\n );\n }\n } else {\n if (newAnnotation === null) {\n // Annotation has a local update already, so we need to delete it from the temporary chunk.\n deleteAnnotation(\n this.temporary.data!,\n annotation.type,\n annotation.id,\n this.annotationPropertySerializers,\n );\n } else {\n // Modify existing entry in temporary chunk.\n updateAnnotation(\n this.temporary.data!,\n newAnnotation,\n this.annotationPropertySerializers,\n );\n }\n reference.value = newAnnotation;\n }\n if (commit) {\n if (localUpdate.commitInProgress !== undefined) {\n localUpdate.pendingCommit = newAnnotation;\n } else {\n if (\n newAnnotation === null &&\n localUpdate.existingAnnotation === undefined\n ) {\n // Local update, which we would now like to delete, has never been committed.\n // Therefore we can just delete it locally.\n localUpdates.delete(id);\n localUpdate.reference.dispose();\n return;\n }\n this.sendCommitRequest(localUpdate, newAnnotation);\n }\n }\n this.notifyChanged(reference.id, newAnnotation || undefined);\n }\n\n private sendCommitRequest(\n localUpdate: LocalUpdateUndoState,\n newAnnotation: Annotation | null,\n ) {\n this.updateCommitsInProgress(1);\n localUpdate.commitInProgress = newAnnotation;\n this.rpc!.invoke(ANNOTATION_COMMIT_UPDATE_RPC_ID, {\n id: this.rpcId,\n annotationId: localUpdate.existingAnnotation && localUpdate.reference.id,\n newAnnotation,\n });\n }\n\n delete(reference: Borrowed) {\n this.applyLocalUpdate(\n reference,\n /*existing=*/ true,\n /*commit=*/ true,\n /*newAnnotation=*/ null,\n );\n }\n\n update(reference: AnnotationReference, newAnnotation: Annotation) {\n this.applyLocalUpdate(\n reference,\n /*existing=*/ true,\n /*commit=*/ false,\n /*newAnnotation=*/ newAnnotation,\n );\n }\n\n private notifyChanged(id: AnnotationId, annotation: Annotation | undefined) {\n const reference = this.references.get(id);\n const chunk = this.metadataChunkSource.chunks.get(id);\n if (chunk !== undefined) {\n chunk.annotation = annotation || null;\n }\n if (reference !== undefined) {\n reference.value = annotation || null;\n reference.changed.dispatch();\n }\n this.chunkManager.chunkQueueManager.visibleChunksChanged.dispatch();\n }\n\n /**\n * Must be called after `add` or `update` to commit the result.\n */\n commit(reference: Borrowed) {\n this.applyLocalUpdate(\n reference,\n /*existing=*/ true,\n /*commit=*/ true,\n reference.value!,\n );\n }\n\n getReference(id: AnnotationId): Owned {\n let existing = this.references.get(id);\n if (existing !== undefined) {\n return existing.addRef();\n }\n existing = new AnnotationReference(id);\n this.references.set(id, existing);\n this.rpc!.invoke(ANNOTATION_REFERENCE_ADD_RPC_ID, {\n id: this.rpcId,\n annotation: id,\n });\n existing.registerDisposer(() => {\n this.references.delete(id);\n this.rpc!.invoke(ANNOTATION_REFERENCE_DELETE_RPC_ID, {\n id: this.rpcId,\n annotation: id,\n });\n });\n const chunk = this.metadataChunkSource.chunks.get(id);\n if (chunk !== undefined) {\n existing.value = chunk.annotation;\n }\n return existing;\n }\n\n private forEachPossibleChunk(\n annotation: Annotation,\n callback: (\n chunk: AnnotationGeometryChunk | AnnotationSubsetGeometryChunk,\n ) => void,\n ) {\n annotation;\n const { relatedSegments } = annotation;\n if (relatedSegments !== undefined) {\n const numRelationships = relatedSegments.length;\n const { segmentFilteredSources } = this;\n for (let i = 0; i < numRelationships; ++i) {\n const segments = relatedSegments[i];\n if (segments === undefined) return;\n const source = segmentFilteredSources[i];\n for (const segment of segments) {\n const chunk = source.chunks.get(getObjectKey(segment));\n if (chunk === undefined) {\n continue;\n }\n callback(chunk);\n }\n }\n }\n const { rank } = this;\n const tempLower = new Float32Array(rank);\n const tempUpper = new Float32Array(rank);\n const tempChunk = new Float32Array(rank);\n for (const source of this.spatiallyIndexedSources) {\n switch (annotation.type) {\n case AnnotationType.POINT:\n matrix.transformPoint(\n tempLower,\n source.multiscaleToChunkTransform,\n rank + 1,\n annotation.point,\n rank,\n );\n tempUpper.set(tempLower);\n break;\n case AnnotationType.LINE:\n case AnnotationType.AXIS_ALIGNED_BOUNDING_BOX:\n matrix.transformPoint(\n tempLower,\n source.multiscaleToChunkTransform,\n rank + 1,\n annotation.pointA,\n rank,\n );\n matrix.transformPoint(\n tempUpper,\n source.multiscaleToChunkTransform,\n rank + 1,\n annotation.pointB,\n rank,\n );\n break;\n case AnnotationType.ELLIPSOID:\n matrix.transformPoint(\n tempLower,\n source.multiscaleToChunkTransform,\n rank + 1,\n annotation.center,\n rank,\n );\n matrix.transformVector(\n tempUpper,\n source.multiscaleToChunkTransform,\n rank + 1,\n annotation.radii,\n rank,\n );\n for (let i = 0; i < rank; ++i) {\n const c = tempLower[i];\n const r = tempUpper[i];\n tempLower[i] = c - r;\n tempUpper[i] = c + r;\n }\n break;\n }\n let totalChunks = 1;\n for (let i = 0; i < rank; ++i) {\n const a = tempLower[i];\n const b = tempUpper[i];\n const lower = Math.min(a, b);\n const upper = Math.max(a, b);\n // In the case that the point lies directly on a boundary, ensure it is included in both\n // chunks, since we don't know how the datasource handles this case.\n tempLower[i] = Math.ceil(lower - 1);\n tempUpper[i] = Math.floor(upper + 1);\n totalChunks *= tempUpper[i] - tempLower[i];\n }\n const { chunks } = source;\n for (let chunkIndex = 0; chunkIndex < totalChunks; ++chunkIndex) {\n let remainder = chunkIndex;\n for (let i = 0; i < rank; ++i) {\n const lower = tempLower[i];\n const upper = tempUpper[i];\n const size = upper - lower;\n const x = (tempChunk[i] = remainder % size);\n remainder = (remainder - x) / size;\n }\n const chunk = chunks.get(tempChunk.join());\n if (chunk !== undefined) {\n callback(chunk);\n }\n }\n }\n }\n\n static encodeOptions(_options: object): { [key: string]: any } {\n return {};\n }\n\n handleSuccessfulUpdate(id: AnnotationId, newAnnotation: Annotation | null) {\n const localUpdate = this.localUpdates.get(id);\n if (\n localUpdate === undefined ||\n localUpdate.commitInProgress === undefined\n ) {\n throw new Error(\"Received invalid successful update notification\");\n }\n this.updateCommitsInProgress(-1);\n if (\n newAnnotation !== null &&\n localUpdate.reference.id !== newAnnotation.id\n ) {\n if (localUpdate.commitInProgress === null) {\n throw new Error(\"Received invalid successful update notification\");\n }\n localUpdate.reference.id = newAnnotation.id;\n this.references.delete(id);\n this.references.set(newAnnotation.id, localUpdate.reference);\n this.localUpdates.delete(id);\n this.localUpdates.set(newAnnotation.id, localUpdate);\n if (localUpdate.reference.value !== null) {\n localUpdate.reference.value!.id = newAnnotation.id;\n deleteAnnotation(\n this.temporary.data!,\n localUpdate.type,\n id,\n this.annotationPropertySerializers,\n );\n updateAnnotation(\n this.temporary.data!,\n localUpdate.reference.value!,\n this.annotationPropertySerializers,\n );\n }\n localUpdate.reference.changed.dispatch();\n }\n localUpdate.existingAnnotation = newAnnotation || undefined;\n localUpdate.commitInProgress = undefined;\n let { pendingCommit } = localUpdate;\n localUpdate.pendingCommit = undefined;\n if (newAnnotation === null) {\n pendingCommit = undefined;\n }\n if (pendingCommit !== undefined) {\n if (pendingCommit !== null) {\n pendingCommit.id = newAnnotation!.id;\n }\n this.sendCommitRequest(localUpdate, pendingCommit);\n } else {\n this.revertLocalUpdate(localUpdate);\n }\n }\n\n private numCommitsInProgress = 0;\n\n private commitStatus: StatusMessage | undefined;\n\n disposed() {\n const { commitStatus } = this;\n if (commitStatus !== undefined) {\n commitStatus.dispose();\n }\n }\n\n private updateCommitsInProgress(amount: number) {\n this.numCommitsInProgress += amount;\n if (this.numCommitsInProgress === 0) {\n if (this.commitStatus !== undefined) {\n this.commitStatus.dispose();\n this.commitStatus = undefined;\n }\n } else if (this.commitStatus === undefined) {\n const status = (this.commitStatus = new StatusMessage(/*delay=*/ true));\n status.setText(\"Commiting annotations\");\n }\n }\n\n handleFailedUpdate(id: AnnotationId, message: string) {\n const localUpdate = this.localUpdates.get(id);\n if (\n localUpdate === undefined ||\n localUpdate.commitInProgress === undefined\n ) {\n throw new Error(\"Received invalid update notification\");\n }\n const status = new StatusMessage();\n status.setErrorMessage(`Error commiting annotation update: ${message}`);\n this.revertLocalUpdate(localUpdate);\n this.updateCommitsInProgress(-1);\n }\n\n private revertLocalUpdate(localUpdate: LocalUpdateUndoState) {\n deleteAnnotation(\n this.temporary.data!,\n localUpdate.type,\n localUpdate.reference.id,\n this.annotationPropertySerializers,\n );\n const { existingAnnotation } = localUpdate;\n if (existingAnnotation !== undefined) {\n this.forEachPossibleChunk(existingAnnotation, (chunk) => {\n const { data } = chunk;\n if (data === undefined) return;\n updateAnnotation(\n data,\n existingAnnotation,\n this.annotationPropertySerializers,\n );\n });\n }\n const { reference } = localUpdate;\n const { id } = reference;\n\n reference.value = existingAnnotation || null;\n reference.changed.dispatch();\n\n reference.dispose();\n\n this.localUpdates.delete(id);\n }\n\n // FIXME\n changed = new NullarySignal();\n *[Symbol.iterator](): Iterator {}\n readonly = false;\n childAdded: Signal<(annotation: Annotation) => void>;\n childUpdated: Signal<(annotation: Annotation) => void>;\n childCommitted: Signal<(annotationId: string) => void>;\n childDeleted: Signal<(annotationId: string) => void>;\n}\n\nregisterRPC(ANNOTATION_COMMIT_UPDATE_RESULT_RPC_ID, function (x) {\n const source = this.get(x.id);\n const annotationId: AnnotationId = x.annotationId;\n const error: string | undefined = x.error;\n if (error !== undefined) {\n source.handleFailedUpdate(annotationId, error);\n } else {\n const newAnnotation: Annotation | null =\n fixAnnotationAfterStructuredCloning(x.newAnnotation);\n source.handleSuccessfulUpdate(annotationId, newAnnotation);\n }\n});\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { defaultStringCompare } from \"#src/util/string.js\";\n\nexport interface Completion {\n value: string;\n}\n\nexport interface CompletionWithDescription extends Completion {\n description?: string;\n}\n\nexport interface BasicCompletionResult {\n completions: C[];\n offset: number;\n}\n\nexport const emptyCompletionResult = {\n offset: 0,\n completions: [],\n};\n\nexport function applyCompletionOffset(\n offset: number,\n completionResult: T,\n) {\n completionResult.offset += offset;\n return completionResult;\n}\n\nexport function getPrefixMatches(prefix: string, options: Iterable) {\n const result: Completion[] = [];\n for (const option of options) {\n if (option.startsWith(prefix)) {\n result.push({ value: option });\n }\n }\n result.sort((a, b) => defaultStringCompare(a.value, b.value));\n return result;\n}\n\nexport function getPrefixMatchesWithDescriptions(\n prefix: string,\n options: Iterable,\n getValue: (x: T) => string,\n getDescription: (x: T) => string | undefined,\n) {\n const result: CompletionWithDescription[] = [];\n for (const option of options) {\n const key = getValue(option);\n if (key.startsWith(prefix)) {\n result.push({ value: key, description: getDescription(option) });\n }\n }\n result.sort((a, b) => defaultStringCompare(a.value, b.value));\n return result;\n}\n\nexport async function completeQueryStringParameters(\n queryString: string,\n keyCompleter: (value: string) => Promise>,\n valueCompleter: (\n key: string,\n value: string,\n ) => Promise>,\n): Promise> {\n if (queryString.startsWith(\"{\")) return emptyCompletionResult;\n const m = queryString.match(/^(?:(.*)[&;])?([^&;]*)$/);\n const part = m![2];\n const offset = queryString.length - part.length;\n const equalsIndex = part.indexOf(\"=\");\n if (equalsIndex === -1) {\n const completions = await keyCompleter(part);\n return {\n offset: completions.offset + offset,\n completions: completions.completions.map((x) => ({\n ...x,\n value: `${x.value}=`,\n })),\n };\n }\n return applyCompletionOffset(\n offset + equalsIndex + 1,\n await valueCompleter(\n part.substring(0, equalsIndex),\n part.substring(equalsIndex + 1),\n ),\n );\n}\n\nexport interface QueryStringCompletionTableEntry<\n C extends Completion = Completion,\n> {\n readonly key: C;\n readonly values: readonly C[];\n}\n\nexport type QueryStringCompletionTable =\n readonly QueryStringCompletionTableEntry[];\n\nexport async function completeQueryStringParametersFromTable<\n C extends Completion,\n>(queryString: string, table: QueryStringCompletionTable) {\n return completeQueryStringParameters(\n queryString,\n async (key) => {\n const results: C[] = [];\n for (const entry of table) {\n const keyEntry = entry.key;\n if (keyEntry.value.startsWith(key)) results.push(keyEntry);\n }\n return { offset: 0, completions: results };\n },\n async (key, value) => {\n for (const entry of table) {\n if (entry.key.value !== key) continue;\n return {\n offset: 0,\n completions: entry.values.filter((x) => x.value.startsWith(value)),\n };\n }\n return emptyCompletionResult;\n },\n );\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { MultiscaleAnnotationSource } from \"#src/annotation/frontend_source.js\";\nimport type { AnnotationSource } from \"#src/annotation/index.js\";\nimport type { ChunkManager } from \"#src/chunk_manager/frontend.js\";\nimport type {\n CoordinateSpace,\n CoordinateSpaceTransform,\n CoordinateTransformSpecification,\n} from \"#src/coordinate_transform.js\";\nimport {\n emptyValidCoordinateSpace,\n makeCoordinateSpace,\n makeIdentityTransform,\n} from \"#src/coordinate_transform.js\";\nimport type { CredentialsManager } from \"#src/credentials_provider/index.js\";\nimport type { MeshSource, MultiscaleMeshSource } from \"#src/mesh/frontend.js\";\nimport type { SegmentPropertyMap } from \"#src/segmentation_display_state/property_map.js\";\nimport type { SegmentationGraphSource } from \"#src/segmentation_graph/source.js\";\nimport type { SingleMeshSource } from \"#src/single_mesh/frontend.js\";\nimport type { SkeletonSource } from \"#src/skeleton/frontend.js\";\nimport type { MultiscaleVolumeChunkSource } from \"#src/sliceview/volume/frontend.js\";\nimport type { WatchableValueInterface } from \"#src/trackable_value.js\";\nimport type { CancellationToken } from \"#src/util/cancellation.js\";\nimport { uncancelableToken } from \"#src/util/cancellation.js\";\nimport type {\n BasicCompletionResult,\n CompletionWithDescription,\n} from \"#src/util/completion.js\";\nimport {\n applyCompletionOffset,\n getPrefixMatchesWithDescriptions,\n} from \"#src/util/completion.js\";\nimport type { Owned } from \"#src/util/disposable.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport { createIdentity } from \"#src/util/matrix.js\";\nimport type { Trackable } from \"#src/util/trackable.js\";\n\nexport type CompletionResult = BasicCompletionResult;\n\nexport class RedirectError extends Error {\n constructor(public redirectTarget: string) {\n super(`Redirected to: ${redirectTarget}`);\n }\n}\n\n/**\n * Returns the length of the prefix of path that corresponds to the \"group\", according to the\n * specified separator.\n *\n * If the separator is not specified, gueses whether it is '/' or ':'.\n */\nexport function findSourceGroupBasedOnSeparator(\n path: string,\n separator?: string,\n) {\n if (separator === undefined) {\n // Try to guess whether '/' or ':' is the separator.\n if (path.indexOf(\"/\") === -1) {\n separator = \":\";\n } else {\n separator = \"/\";\n }\n }\n const index = path.lastIndexOf(separator);\n if (index === -1) {\n return 0;\n }\n return index + 1;\n}\n\n/**\n * Returns the last \"component\" of path, according to the specified separator.\n * If the separator is not specified, gueses whether it is '/' or ':'.\n */\nexport function suggestLayerNameBasedOnSeparator(\n path: string,\n separator?: string,\n) {\n const groupIndex = findSourceGroupBasedOnSeparator(path, separator);\n return path.substring(groupIndex);\n}\n\nexport interface GetDataSourceOptionsBase {\n chunkManager: ChunkManager;\n cancellationToken?: CancellationToken;\n url: string;\n transform: CoordinateTransformSpecification | undefined;\n globalCoordinateSpace: WatchableValueInterface;\n state?: any;\n}\n\nexport interface GetDataSourceOptions extends GetDataSourceOptionsBase {\n registry: DataSourceProviderRegistry;\n providerUrl: string;\n cancellationToken: CancellationToken;\n providerProtocol: string;\n credentialsManager: CredentialsManager;\n}\n\nexport interface ConvertLegacyUrlOptionsBase {\n url: string;\n type: \"mesh\" | \"skeletons\" | \"single_mesh\";\n}\n\nexport interface ConvertLegacyUrlOptions extends ConvertLegacyUrlOptionsBase {\n registry: DataSourceProviderRegistry;\n providerUrl: string;\n providerProtocol: string;\n}\n\nexport interface NormalizeUrlOptionsBase {\n url: string;\n}\n\nexport interface NormalizeUrlOptions extends NormalizeUrlOptionsBase {\n registry: DataSourceProviderRegistry;\n providerUrl: string;\n providerProtocol: string;\n}\n\nexport enum LocalDataSource {\n annotations = 0,\n equivalences = 1,\n}\n\nexport interface DataSubsource {\n volume?: MultiscaleVolumeChunkSource;\n mesh?: MeshSource | MultiscaleMeshSource | SkeletonSource;\n annotation?: MultiscaleAnnotationSource;\n staticAnnotations?: AnnotationSource;\n local?: LocalDataSource;\n singleMesh?: SingleMeshSource;\n segmentPropertyMap?: SegmentPropertyMap;\n segmentationGraph?: SegmentationGraphSource;\n}\n\nexport interface CompleteUrlOptionsBase {\n url: string;\n cancellationToken?: CancellationToken;\n chunkManager: ChunkManager;\n}\n\nexport interface CompleteUrlOptions extends CompleteUrlOptionsBase {\n registry: DataSourceProviderRegistry;\n providerUrl: string;\n cancellationToken: CancellationToken;\n credentialsManager: CredentialsManager;\n}\n\nexport interface DataSubsourceEntry {\n /**\n * Unique identifier (within the group) for this subsource. Stored in the JSON state\n * representation to indicate which subsources are enabled. The empty string `\"\"` should be used\n * for the first/primary subsource.\n */\n id: string;\n\n subsource: DataSubsource;\n\n /**\n * Homoegeneous transformation from the subsource to the model subspace corresponding to\n * `modelSubspceDimensionIndices`. The rank is equal to the length of\n * `modelSubspaceDimensionIndices`. If this is greater than the subsource rank, the subsource\n * coordinate space is implicitly padded at the end with additional dummy dimensions with a range\n * of `[0, 1]`. If unspecified, defaults to the identity transform.\n */\n subsourceToModelSubspaceTransform?: Float32Array;\n\n /**\n * Specifies the model dimensions corresponding to this subsource. If unspecified, defaults to\n * `[0, ..., modelSpace.rank)`.\n */\n modelSubspaceDimensionIndices?: number[];\n\n /**\n * Specifies whether this associated data source is enabled by default.\n */\n default: boolean;\n}\n\nexport interface DataSource {\n subsources: DataSubsourceEntry[];\n modelTransform: CoordinateSpaceTransform;\n canChangeModelSpaceRank?: boolean;\n state?: Trackable;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging\nexport interface DataSourceProvider {\n /**\n * Returns a suggested layer name for the given volume source.\n */\n suggestLayerName?(path: string): string;\n\n /**\n * Returns the length of the prefix of path that is its 'group'. This is used for suggesting a\n * default URL for adding a new layer.\n */\n findSourceGroup?(path: string): number;\n}\n\nexport interface DataSubsourceSpecification {\n enabled?: boolean;\n}\n\nexport interface DataSourceSpecification {\n url: string;\n transform: CoordinateTransformSpecification | undefined;\n enableDefaultSubsources: boolean;\n subsources: Map;\n state?: any;\n}\n\nexport function makeEmptyDataSourceSpecification(): DataSourceSpecification {\n return {\n url: \"\",\n transform: undefined,\n enableDefaultSubsources: true,\n subsources: new Map(),\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging\nexport abstract class DataSourceProvider extends RefCounted {\n abstract description?: string;\n\n abstract get(options: GetDataSourceOptions): Promise;\n\n normalizeUrl(options: NormalizeUrlOptions): string {\n return options.url;\n }\n\n convertLegacyUrl(options: ConvertLegacyUrlOptions): string {\n return options.url;\n }\n\n async completeUrl(options: CompleteUrlOptions): Promise {\n options;\n throw null;\n }\n}\n\nexport const localAnnotationsUrl = \"local://annotations\";\nexport const localEquivalencesUrl = \"local://equivalences\";\n\nclass LocalDataSourceProvider extends DataSourceProvider {\n get description() {\n return \"Local in-memory\";\n }\n\n async get(options: GetDataSourceOptions): Promise {\n switch (options.url) {\n case localAnnotationsUrl: {\n const { transform } = options;\n let modelTransform: CoordinateSpaceTransform;\n if (transform === undefined) {\n const baseSpace = options.globalCoordinateSpace.value;\n const { rank, names, scales, units } = baseSpace;\n const inputSpace = makeCoordinateSpace({\n rank,\n scales,\n units,\n names: names.map((_, i) => `${i}`),\n });\n const outputSpace = makeCoordinateSpace({\n rank,\n scales,\n units,\n names,\n });\n modelTransform = {\n rank,\n sourceRank: rank,\n inputSpace,\n outputSpace,\n transform: createIdentity(Float64Array, rank + 1),\n };\n } else {\n modelTransform = makeIdentityTransform(emptyValidCoordinateSpace);\n }\n return {\n modelTransform,\n canChangeModelSpaceRank: true,\n subsources: [\n {\n id: \"default\",\n default: true,\n subsource: {\n local: LocalDataSource.annotations,\n },\n },\n ],\n };\n }\n case localEquivalencesUrl: {\n return {\n modelTransform: makeIdentityTransform(emptyValidCoordinateSpace),\n canChangeModelSpaceRank: false,\n subsources: [\n {\n id: \"default\",\n default: true,\n subsource: {\n local: LocalDataSource.equivalences,\n },\n },\n ],\n };\n }\n }\n throw new Error(\"Invalid local data source URL\");\n }\n\n async completeUrl(options: CompleteUrlOptions) {\n return {\n offset: 0,\n completions: getPrefixMatchesWithDescriptions(\n options.providerUrl,\n [\n {\n value: \"annotations\",\n description: \"Annotations stored in the JSON state\",\n },\n {\n value: \"equivalences\",\n description:\n \"Segmentation equivalence graph stored in the JSON state\",\n },\n ],\n (x) => x.value,\n (x) => x.description,\n ),\n };\n }\n}\n\nconst protocolPattern = /^(?:([a-zA-Z][a-zA-Z0-9-+_]*):\\/\\/)?(.*)$/;\n\nexport class DataSourceProviderRegistry extends RefCounted {\n constructor(public credentialsManager: CredentialsManager) {\n super();\n }\n dataSources = new Map>([\n [\"local\", new LocalDataSourceProvider()],\n ]);\n\n register(name: string, dataSource: Owned) {\n this.dataSources.set(name, this.registerDisposer(dataSource));\n }\n\n getProvider(url: string): [DataSourceProvider, string, string] {\n const m = url.match(protocolPattern);\n if (m === null || m[1] === undefined) {\n throw new Error(\n `Data source URL must have the form \"://\".`,\n );\n }\n const [, providerProtocol, providerUrl] = m;\n const factory = this.dataSources.get(providerProtocol);\n if (factory === undefined) {\n throw new Error(\n `Unsupported data source: ${JSON.stringify(providerProtocol)}.`,\n );\n }\n return [factory, providerUrl, providerProtocol];\n }\n\n async get(options: GetDataSourceOptionsBase): Promise {\n const redirectLog = new Set();\n const { cancellationToken = uncancelableToken } = options;\n let url: string = options.url;\n while (true) {\n const [provider, providerUrl, providerProtocol] = this.getProvider(\n options.url,\n );\n redirectLog.add(options.url);\n try {\n return provider.get({\n ...options,\n url,\n providerProtocol,\n providerUrl,\n registry: this,\n cancellationToken,\n credentialsManager: this.credentialsManager,\n });\n } catch (e) {\n if (e instanceof RedirectError) {\n const redirect = e.redirectTarget;\n if (redirectLog.has(redirect)) {\n throw Error(\n `Layer source redirection contains loop: ${JSON.stringify(\n Array.from(redirectLog),\n )}`,\n );\n }\n if (redirectLog.size >= 10) {\n throw Error(\n `Too many layer source redirections: ${JSON.stringify(\n Array.from(redirectLog),\n )}`,\n );\n }\n url = redirect;\n continue;\n }\n throw e;\n }\n }\n }\n\n convertLegacyUrl(options: ConvertLegacyUrlOptionsBase): string {\n try {\n const [provider, providerUrl, providerProtocol] = this.getProvider(\n options.url,\n );\n return provider.convertLegacyUrl({\n ...options,\n providerUrl,\n providerProtocol,\n registry: this,\n });\n } catch {\n return options.url;\n }\n }\n\n normalizeUrl(options: NormalizeUrlOptionsBase): string {\n try {\n const [provider, providerUrl, providerProtocol] = this.getProvider(\n options.url,\n );\n return provider.normalizeUrl({\n ...options,\n providerUrl,\n providerProtocol,\n registry: this,\n });\n } catch {\n return options.url;\n }\n }\n\n async completeUrl(\n options: CompleteUrlOptionsBase,\n ): Promise {\n // Check if url matches a protocol. Note that protocolPattern always matches.\n const { url, cancellationToken = uncancelableToken } = options;\n const protocolMatch = url.match(protocolPattern)!;\n const protocol = protocolMatch[1];\n if (protocol === undefined) {\n return Promise.resolve({\n offset: 0,\n completions: getPrefixMatchesWithDescriptions(\n url,\n this.dataSources,\n ([name]) => `${name}://`,\n ([, factory]) => factory.description,\n ),\n });\n }\n const factory = this.dataSources.get(protocol);\n if (factory !== undefined) {\n const completions = await factory.completeUrl({\n registry: this,\n url,\n providerUrl: protocolMatch[2],\n chunkManager: options.chunkManager,\n cancellationToken,\n credentialsManager: this.credentialsManager,\n });\n return applyCompletionOffset(protocol.length + 3, completions);\n }\n throw null;\n }\n\n suggestLayerName(url: string) {\n let [dataSource, path] = this.getProvider(url);\n if (path.endsWith(\"/\")) {\n path = path.substring(0, path.length - 1);\n }\n const suggestor = dataSource.suggestLayerName;\n if (suggestor !== undefined) {\n return suggestor(path);\n }\n return suggestLayerNameBasedOnSeparator(path);\n }\n\n findSourceGroup(url: string) {\n const [dataSource, path, dataSourceName] = this.getProvider(url);\n const helper =\n dataSource.findSourceGroup || findSourceGroupBasedOnSeparator;\n return helper(path) + dataSourceName.length + 3;\n }\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n CoordinateSpace,\n CoordinateTransformSpecification,\n} from \"#src/coordinate_transform.js\";\nimport {\n coordinateTransformSpecificationFromJson,\n coordinateTransformSpecificationToJson,\n makeCoordinateSpace,\n makeIdentityTransform,\n WatchableCoordinateSpaceTransform,\n} from \"#src/coordinate_transform.js\";\nimport type {\n DataSource,\n DataSourceSpecification,\n DataSubsourceEntry,\n DataSubsourceSpecification,\n} from \"#src/datasource/index.js\";\nimport { makeEmptyDataSourceSpecification } from \"#src/datasource/index.js\";\nimport type { UserLayer } from \"#src/layer/index.js\";\nimport { getWatchableRenderLayerTransform } from \"#src/render_coordinate_transform.js\";\nimport type { RenderLayer } from \"#src/renderlayer.js\";\nimport type { WatchableValueInterface } from \"#src/trackable_value.js\";\nimport { arraysEqual } from \"#src/util/array.js\";\nimport { CancellationTokenSource } from \"#src/util/cancellation.js\";\nimport type { Borrowed, Owned } from \"#src/util/disposable.js\";\nimport { disposableOnce, RefCounted } from \"#src/util/disposable.js\";\nimport {\n verifyBoolean,\n verifyObject,\n verifyObjectAsMap,\n verifyObjectProperty,\n verifyOptionalObjectProperty,\n verifyString,\n} from \"#src/util/json.js\";\nimport * as matrix from \"#src/util/matrix.js\";\nimport { MessageList, MessageSeverity } from \"#src/util/message_list.js\";\nimport { NullarySignal } from \"#src/util/signal.js\";\n\nexport function parseDataSubsourceSpecificationFromJson(\n json: unknown,\n): DataSubsourceSpecification {\n if (typeof json === \"boolean\") {\n return { enabled: json };\n }\n verifyObject(json);\n return {\n enabled: verifyOptionalObjectProperty(json, \"enabled\", verifyBoolean),\n };\n}\n\nexport function layerDataSourceSpecificationFromJson(\n obj: unknown,\n legacyTransform: CoordinateTransformSpecification | undefined = undefined,\n): DataSourceSpecification {\n if (typeof obj === \"string\") {\n return {\n url: obj,\n transform: legacyTransform,\n enableDefaultSubsources: true,\n subsources: new Map(),\n };\n }\n verifyObject(obj);\n return {\n url: verifyObjectProperty(obj, \"url\", verifyString),\n transform:\n verifyObjectProperty(\n obj,\n \"transform\",\n coordinateTransformSpecificationFromJson,\n ) || legacyTransform,\n enableDefaultSubsources: verifyOptionalObjectProperty(\n obj,\n \"enableDefaultSubsources\",\n verifyBoolean,\n true,\n ),\n subsources: verifyOptionalObjectProperty(\n obj,\n \"subsources\",\n (subsourcesObj) =>\n verifyObjectAsMap(\n subsourcesObj,\n parseDataSubsourceSpecificationFromJson,\n ),\n new Map(),\n ),\n state: verifyOptionalObjectProperty(obj, \"state\", verifyObject),\n };\n}\n\nfunction dataSubsourceSpecificationToJson(spec: DataSubsourceSpecification) {\n return spec.enabled;\n}\n\nexport function layerDataSourceSpecificationToJson(\n spec: DataSourceSpecification,\n) {\n const transform = coordinateTransformSpecificationToJson(spec.transform);\n const subsourcesJson: any = {};\n let emptySubsources = true;\n for (const [id, subsource] of spec.subsources) {\n const j = dataSubsourceSpecificationToJson(subsource);\n if (j !== undefined) {\n subsourcesJson[id] = j;\n emptySubsources = false;\n }\n }\n if (\n transform === undefined &&\n emptySubsources &&\n spec.enableDefaultSubsources === true &&\n spec.state === undefined\n ) {\n return spec.url;\n }\n return {\n url: spec.url,\n transform,\n subsources: emptySubsources ? undefined : subsourcesJson,\n enableDefaultSubsources:\n spec.enableDefaultSubsources === true ? undefined : false,\n state: spec.state,\n };\n}\n\nexport class LoadedDataSubsource {\n subsourceToModelSubspaceTransform: Float32Array;\n modelSubspaceDimensionIndices: number[];\n enabled: boolean;\n activated: RefCounted | undefined = undefined;\n guardValues: any[] = [];\n messages = new MessageList();\n isActiveChanged = new NullarySignal();\n constructor(\n public loadedDataSource: LoadedLayerDataSource,\n public subsourceEntry: DataSubsourceEntry,\n public subsourceSpec: DataSubsourceSpecification | undefined,\n public subsourceIndex: number,\n enableDefaultSubsources: boolean,\n ) {\n let enabled: boolean;\n if (subsourceSpec === undefined || subsourceSpec.enabled === undefined) {\n enabled = subsourceEntry.default && enableDefaultSubsources;\n } else {\n enabled = subsourceSpec.enabled;\n }\n const modelRank = loadedDataSource.dataSource.modelTransform.sourceRank;\n let { modelSubspaceDimensionIndices } = subsourceEntry;\n if (modelSubspaceDimensionIndices === undefined) {\n modelSubspaceDimensionIndices = new Array(modelRank);\n for (let i = 0; i < modelRank; ++i) {\n modelSubspaceDimensionIndices[i] = i;\n }\n }\n const {\n subsourceToModelSubspaceTransform = matrix.createIdentity(\n Float32Array,\n modelSubspaceDimensionIndices.length + 1,\n ),\n } = subsourceEntry;\n this.enabled = enabled;\n this.subsourceToModelSubspaceTransform = subsourceToModelSubspaceTransform;\n this.modelSubspaceDimensionIndices = modelSubspaceDimensionIndices;\n this.isActiveChanged.add(\n loadedDataSource.activatedSubsourcesChanged.dispatch,\n );\n }\n\n activate(callback: (refCounted: RefCounted) => void, ...guardValues: any[]) {\n this.messages.clearMessages();\n if (this.activated !== undefined) {\n if (arraysEqual(guardValues, this.guardValues)) return;\n this.activated.dispose();\n }\n this.guardValues = guardValues;\n const activated = (this.activated = new RefCounted());\n callback(activated);\n this.isActiveChanged.dispatch();\n }\n\n deactivate(error: string) {\n this.messages.clearMessages();\n this.messages.addMessage({\n severity: MessageSeverity.error,\n message: error,\n });\n const { activated } = this;\n if (activated === undefined) return;\n this.activated = undefined;\n activated.dispose();\n this.isActiveChanged.dispatch();\n }\n\n addRenderLayer(renderLayer: Owned) {\n const activated = this.activated!;\n activated.registerDisposer(\n this.loadedDataSource.layer.addRenderLayer(renderLayer),\n );\n activated.registerDisposer(this.messages.addChild(renderLayer.messages));\n }\n\n getRenderLayerTransform(\n channelCoordinateSpace?: WatchableValueInterface,\n ) {\n const activated = this.activated!;\n const { layer, transform } = this.loadedDataSource;\n return activated.registerDisposer(\n getWatchableRenderLayerTransform(\n layer.manager.root.coordinateSpace,\n layer.localPosition.coordinateSpace,\n transform,\n this,\n channelCoordinateSpace,\n ),\n );\n }\n}\n\nexport class LoadedLayerDataSource extends RefCounted {\n error = undefined;\n enabledSubsourcesChanged = new NullarySignal();\n activatedSubsourcesChanged = new NullarySignal();\n messages = new MessageList();\n transform: WatchableCoordinateSpaceTransform;\n subsources: LoadedDataSubsource[];\n enableDefaultSubsources: boolean;\n get enabledSubsources() {\n return this.subsources.filter((x) => x.enabled);\n }\n get layer() {\n return this.layerDataSource.layer;\n }\n constructor(\n public layerDataSource: LayerDataSource,\n public dataSource: DataSource,\n spec: DataSourceSpecification,\n ) {\n super();\n if (dataSource.canChangeModelSpaceRank) {\n this.transform = new WatchableCoordinateSpaceTransform(\n makeIdentityTransform(\n makeCoordinateSpace({\n rank: 0,\n scales: new Float64Array(0),\n units: [],\n names: [],\n }),\n ),\n true,\n );\n this.transform.value = dataSource.modelTransform;\n } else {\n this.transform = new WatchableCoordinateSpaceTransform(\n dataSource.modelTransform,\n );\n }\n if (spec.transform !== undefined) {\n this.transform.spec = spec.transform;\n }\n const subsourceSpecs = spec.subsources;\n this.enableDefaultSubsources = spec.enableDefaultSubsources;\n this.subsources = dataSource.subsources.map(\n (subsourceEntry, subsourceIndex): LoadedDataSubsource =>\n new LoadedDataSubsource(\n this,\n subsourceEntry,\n subsourceSpecs.get(subsourceEntry.id),\n subsourceIndex,\n this.enableDefaultSubsources,\n ),\n );\n }\n\n disposed() {\n for (const subsource of this.subsources) {\n const { activated } = subsource;\n if (activated !== undefined) {\n subsource.activated = undefined;\n activated.dispose();\n }\n }\n }\n}\n\nexport type LayerDataSourceLoadState =\n | {\n error: Error;\n }\n | LoadedLayerDataSource\n | undefined;\n\nexport class LayerDataSource extends RefCounted {\n changed = new NullarySignal();\n messages = new MessageList();\n private loadState_: LayerDataSourceLoadState = undefined;\n private spec_: DataSourceSpecification;\n private specGeneration = -1;\n private refCounted_: RefCounted | undefined = undefined;\n\n constructor(\n public layer: Borrowed,\n spec: DataSourceSpecification | undefined = undefined,\n ) {\n super();\n this.registerDisposer(this.changed.add(layer.dataSourcesChanged.dispatch));\n this.registerDisposer(layer.messages.addChild(this.messages));\n if (spec === undefined) {\n this.spec_ = makeEmptyDataSourceSpecification();\n } else {\n this.spec = spec;\n }\n }\n\n get spec() {\n const { loadState } = this;\n if (loadState !== undefined && loadState.error === undefined) {\n const generation = this.changed.count;\n if (generation !== this.specGeneration) {\n this.specGeneration = generation;\n this.spec_ = {\n url: this.spec.url,\n transform: loadState.transform.spec,\n enableDefaultSubsources: loadState.enableDefaultSubsources,\n subsources: new Map(\n Array.from(loadState.subsources, (loadedSubsource) => {\n const defaultEnabledValue =\n loadState.enableDefaultSubsources &&\n loadedSubsource.subsourceEntry.default;\n return [\n loadedSubsource.subsourceEntry.id,\n {\n enabled:\n loadedSubsource.enabled !== defaultEnabledValue\n ? loadedSubsource.enabled\n : undefined,\n },\n ];\n }),\n ),\n state: this.spec.state,\n };\n }\n }\n return this.spec_;\n }\n\n get loadState() {\n return this.loadState_;\n }\n\n set spec(spec: DataSourceSpecification) {\n const { layer } = this;\n this.messages.clearMessages();\n if (spec.url.length === 0) {\n if (layer.dataSources.length !== 1) {\n const index = layer.dataSources.indexOf(this);\n if (index !== -1) {\n layer.dataSources.splice(index, 1);\n layer.dataSourcesChanged.dispatch();\n this.dispose();\n return;\n }\n }\n this.spec_ = spec;\n if (this.refCounted_ !== undefined) {\n this.refCounted_.dispose();\n this.refCounted_ = undefined;\n this.loadState_ = undefined;\n this.changed.dispatch();\n }\n return;\n }\n const refCounted = new RefCounted();\n const retainer = refCounted.registerDisposer(\n disposableOnce(layer.markLoading()),\n );\n if (this.refCounted_ !== undefined) {\n this.refCounted_.dispose();\n this.loadState_ = undefined;\n }\n this.refCounted_ = refCounted;\n this.spec_ = spec;\n const chunkManager = layer.manager.chunkManager;\n const registry = layer.manager.dataSourceProviderRegistry;\n const cancellationToken = new CancellationTokenSource();\n this.messages.addMessage({\n severity: MessageSeverity.info,\n message: \"Loading data source\",\n });\n registry\n .get({\n chunkManager,\n url: spec.url,\n cancellationToken,\n globalCoordinateSpace: layer.manager.root.coordinateSpace,\n transform: spec.transform,\n state: spec.state,\n })\n .then((source: DataSource) => {\n if (refCounted.wasDisposed) return;\n this.messages.clearMessages();\n const loaded = refCounted.registerDisposer(\n new LoadedLayerDataSource(this, source, spec),\n );\n loaded.registerDisposer(\n layer.addCoordinateSpace(loaded.transform.outputSpace),\n );\n loaded.registerDisposer(\n loaded.transform.changed.add(this.changed.dispatch),\n );\n this.loadState_ = loaded;\n loaded.registerDisposer(\n loaded.enabledSubsourcesChanged.add(this.changed.dispatch),\n );\n this.changed.dispatch();\n if (source.state) {\n refCounted.registerDisposer(\n source.state.changed.add(() => {\n this.spec.state = source.state?.toJSON();\n layer.specificationChanged.dispatch();\n }),\n );\n }\n retainer();\n })\n .catch((error: Error) => {\n if (this.wasDisposed) return;\n this.loadState_ = { error };\n this.messages.clearMessages();\n this.messages.addMessage({\n severity: MessageSeverity.error,\n message: error.message,\n });\n this.changed.dispatch();\n });\n refCounted.registerDisposer(() => {\n cancellationToken.cancel();\n });\n this.changed.dispatch();\n }\n\n disposed() {\n const refCounted = this.refCounted_;\n if (refCounted !== undefined) {\n refCounted.dispose();\n }\n }\n\n toJSON() {\n const { loadState } = this;\n if (loadState === undefined || loadState.error !== undefined) {\n return layerDataSourceSpecificationToJson(this.spec);\n }\n return layerDataSourceSpecificationToJson({\n url: this.spec.url,\n transform: loadState.transform.spec,\n enableDefaultSubsources: loadState.enableDefaultSubsources,\n subsources: new Map(\n Array.from(loadState.subsources, (loadedSubsource) => {\n const defaultEnabledValue =\n loadState.enableDefaultSubsources &&\n loadedSubsource.subsourceEntry.default;\n return [\n loadedSubsource.subsourceEntry.id,\n {\n enabled:\n loadedSubsource.enabled !== defaultEnabledValue\n ? loadedSubsource.enabled\n : undefined,\n },\n ];\n }),\n ),\n state: this.spec.state,\n });\n }\n}\n","/**\n * @license\n * Copyright 2021 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { WatchableValueInterface } from \"#src/trackable_value.js\";\nimport {\n verifyBoolean,\n verifyFiniteFloat,\n verifyObject,\n verifyOptionalObjectProperty,\n verifyPositiveInt,\n} from \"#src/util/json.js\";\nimport { Signal } from \"#src/util/signal.js\";\nimport type { Trackable } from \"#src/util/trackable.js\";\n\nexport type Side = \"left\" | \"right\" | \"top\" | \"bottom\";\n\nexport const DEFAULT_SIDE_PANEL_WIDTH = 300;\nexport const DEFAULT_MIN_SIDE_PANEL_WIDTH = 100;\n\nexport interface SidePanelLocation {\n // Side on which the panel is located.\n side: Side;\n\n // Horizontal position as ordinal.\n col: number;\n\n // Vertical position as ordinal.\n row: number;\n\n // Fraction of full size along flex direction.\n flex: number;\n\n // Cross-direction size in pixels.\n size: number;\n\n // Minimum width in pixels.\n minSize: number;\n\n // Whether the panel is visible.\n visible: boolean;\n}\n\nexport const DEFAULT_SIDE_PANEL_LOCATION: SidePanelLocation = {\n side: \"right\",\n col: 0,\n row: Infinity,\n flex: 1,\n size: DEFAULT_SIDE_PANEL_WIDTH,\n minSize: DEFAULT_MIN_SIDE_PANEL_WIDTH,\n visible: false,\n};\n\nexport class TrackableSidePanelLocation implements Trackable {\n // Indicates that the JSON representation changed. Note that some changes are just due to\n // normalization and don't affect the actual layout.\n changed = new Signal();\n\n // Indicates that the layout actually changed.\n locationChanged = new Signal();\n\n readonly watchableVisible: WatchableValueInterface;\n\n constructor(\n public defaultValue: SidePanelLocation = DEFAULT_SIDE_PANEL_LOCATION,\n public value = defaultValue,\n ) {\n this.locationChanged.add(this.changed.dispatch);\n const self = this;\n this.watchableVisible = {\n get value() {\n return self.visible;\n },\n set value(value: boolean) {\n self.visible = value;\n },\n changed: self.locationChanged,\n };\n }\n\n toJSON(defaultValue = this.defaultValue) {\n const obj: any = {};\n const { value } = this;\n for (const key in value) {\n if (\n value[key as keyof SidePanelLocation] ===\n defaultValue[key as keyof SidePanelLocation]\n ) {\n continue;\n }\n obj[key] = value[key as keyof SidePanelLocation];\n }\n return obj;\n }\n\n get visible() {\n return this.value.visible;\n }\n\n set visible(visible: boolean) {\n const { value } = this;\n if (value.visible !== visible) {\n this.value = { ...value, visible };\n this.locationChanged.dispatch();\n }\n }\n\n reset() {\n if (this.value !== this.defaultValue) {\n this.value = this.defaultValue;\n this.locationChanged.dispatch();\n }\n }\n\n restoreState(obj: unknown, defaultLocation = this.defaultValue) {\n if (obj === undefined) return;\n verifyObject(obj);\n const location: SidePanelLocation = {\n side: verifyOptionalObjectProperty(\n obj,\n \"side\",\n (x) => {\n if (x !== \"left\" && x !== \"right\" && x !== \"top\" && x !== \"bottom\") {\n throw new Error(\n `Expected \"left\", \"right\", \"top\", or \"bottom\", but received: ${JSON.stringify(\n x,\n )}`,\n );\n }\n return x;\n },\n defaultLocation.side,\n ),\n col: verifyOptionalObjectProperty(\n obj,\n \"col\",\n verifyFiniteFloat,\n defaultLocation.col,\n ),\n row: verifyOptionalObjectProperty(\n obj,\n \"row\",\n verifyFiniteFloat,\n defaultLocation.row,\n ),\n flex: verifyOptionalObjectProperty(\n obj,\n \"flex\",\n verifyFiniteFloat,\n defaultLocation.flex,\n ),\n size: verifyOptionalObjectProperty(\n obj,\n \"size\",\n verifyPositiveInt,\n defaultLocation.size,\n ),\n visible: verifyOptionalObjectProperty(\n obj,\n \"visible\",\n verifyBoolean,\n defaultLocation.visible,\n ),\n // minSize cannot be modified.\n minSize: defaultLocation.minSize,\n };\n this.value = location;\n this.locationChanged.dispatch();\n }\n}\n","/**\n * @license\n * Copyright 2021 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { UserLayer } from \"#src/layer/index.js\";\nimport { WatchableValue } from \"#src/trackable_value.js\";\nimport type { SidePanelLocation } from \"#src/ui/side_panel_location.js\";\nimport {\n DEFAULT_SIDE_PANEL_LOCATION,\n TrackableSidePanelLocation,\n} from \"#src/ui/side_panel_location.js\";\nimport { arraysEqual } from \"#src/util/array.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport {\n parseArray,\n verifyObject,\n verifyOptionalObjectProperty,\n verifyString,\n verifyStringArray,\n} from \"#src/util/json.js\";\nimport { Signal } from \"#src/util/signal.js\";\n\nconst TAB_JSON_KEY = \"tab\";\nconst TABS_JSON_KEY = \"tabs\";\nconst PANELS_JSON_KEY = \"panels\";\n\nexport const SELECTED_LAYER_SIDE_PANEL_DEFAULT_LOCATION = {\n ...DEFAULT_SIDE_PANEL_LOCATION,\n row: 0,\n};\nexport const LAYER_SIDE_PANEL_DEFAULT_LOCATION = {\n ...DEFAULT_SIDE_PANEL_LOCATION,\n visible: true,\n row: 0,\n};\n\nexport class UserLayerSidePanelState extends RefCounted {\n layer = this.panels.layer;\n location = new TrackableSidePanelLocation(LAYER_SIDE_PANEL_DEFAULT_LOCATION);\n constructor(public panels: UserLayerSidePanelsState) {\n super();\n }\n\n initialize() {\n const { panels } = this;\n this.tabsChanged.add(panels.specificationChanged.dispatch);\n this.selectedTab.changed.add(panels.specificationChanged.dispatch);\n this.location.changed.add(() => {\n panels.specificationChanged.dispatch();\n const { layer } = this;\n const { selectedLayer } = layer.manager.root;\n if (selectedLayer.layer?.layer !== layer) return;\n if (this !== layer.panels.panels[0]) return;\n const curLocation = this.location.value;\n if (selectedLayer.location.value !== curLocation) {\n selectedLayer.location.value = curLocation;\n selectedLayer.location.locationChanged.dispatch();\n }\n });\n this.location.locationChanged.add(() => {\n if (this.location.visible) return;\n if (this === this.panels.panels[0]) return;\n this.panels.removePanel(this);\n });\n\n // TODO, is it safe to put this here?\n for (const id of this.tabs) {\n const { hidden } = this.layer.tabs.options.get(id)!;\n if (hidden) {\n this.registerDisposer(\n hidden.changed.add(() => {\n this.panels.updateTabs();\n this.tabsChanged.dispatch();\n }),\n );\n }\n }\n }\n tabsChanged = new Signal();\n selectedTab = new WatchableValue(undefined);\n explicitTabs: Set | undefined;\n tabs: string[] = [];\n\n normalizeTabs() {\n const { tabs } = this;\n if (tabs.length === 0) {\n this.selectedTab.value = undefined;\n return;\n }\n const layerTabs = this.layer.tabs.options;\n const getOrder = (tab: string) => layerTabs.get(tab)!.order ?? 0;\n tabs.sort((a, b) => getOrder(a) - getOrder(b));\n const { selectedTab } = this;\n const selectedTabValue = selectedTab.value;\n if (selectedTabValue === undefined || !tabs.includes(selectedTabValue)) {\n selectedTab.value = tabs[0];\n }\n }\n\n pin() {\n // \"Pin\" this panel, which means converting it from the selected layer panel to an extra panel.\n const { layer } = this;\n const { selectedLayer } = layer.manager.root;\n // Check that this is the selected layer panel.\n if (selectedLayer.layer?.layer !== layer) return;\n if (this !== layer.panels.panels[0]) return;\n if (this.tabs.length === 0) return;\n const { panels } = this;\n const newPanel = layer.registerDisposer(\n new UserLayerSidePanelState(panels),\n );\n panels.panels.splice(0, 1, newPanel);\n panels.panels.push(this);\n panels.updateTabs();\n newPanel.initialize();\n selectedLayer.layerManager.layersChanged.dispatch();\n this.panels.specificationChanged.dispatch();\n }\n\n unpin() {\n // \"Unpin\" this panel, which means pinning the current selected layer panel, if any, and making\n // this panel the selected layer panel.\n const { panels } = this;\n const panelIndex = panels.panels.indexOf(this);\n if (panelIndex === -1 || panelIndex === 0) return;\n const { layer } = this;\n const { selectedLayer } = layer.manager.root;\n const selectedUserLayer = selectedLayer.layer?.layer;\n if (\n selectedLayer.visible &&\n selectedUserLayer != null &&\n selectedUserLayer !== layer\n ) {\n const prevSelectedLayerPanel = selectedUserLayer.panels.panels[0];\n prevSelectedLayerPanel.pin();\n }\n panels.panels.splice(panelIndex, 1);\n const [origSelectedPanel] = panels.panels.splice(0, 1, this);\n if (this.explicitTabs === undefined) {\n // This layer will contain all remaining tabs. The old selected layer panel should be\n // removed, as otherwise `updateTabs` will incorrectly assign it all tabs.\n layer.unregisterDisposer(origSelectedPanel);\n } else {\n panels.panels.push(origSelectedPanel);\n // This layer will contain only the explicit tabs. All other extra layers must be set to have\n // explicit tabs as well, as otherwise `updateTabs` will assign all tabs to them.\n for (let i = 1, length = panels.panels.length; i < length; ++i) {\n const panel = panels.panels[i];\n if (panel.explicitTabs === undefined) {\n panel.explicitTabs = new Set(panel.tabs);\n }\n }\n }\n this.explicitTabs = undefined;\n panels.updateTabs();\n selectedLayer.layer = layer.managedLayer;\n selectedLayer.location.value = this.location.value;\n selectedLayer.location.locationChanged.dispatch();\n selectedLayer.layerManager.layersChanged.dispatch();\n this.panels.specificationChanged.dispatch();\n }\n\n splitOffTab(tab: string, location: SidePanelLocation) {\n // Move the specified tab to a new panel.\n if (!this.tabs.includes(tab)) return;\n const { panels } = this;\n {\n const { explicitTabs } = this;\n if (explicitTabs !== undefined) {\n explicitTabs.delete(tab);\n }\n }\n const { layer } = this;\n const newPanel = layer.registerDisposer(\n new UserLayerSidePanelState(panels),\n );\n newPanel.location.value = location;\n newPanel.explicitTabs = new Set([tab]);\n panels.panels.splice(1, 0, newPanel);\n panels.updateTabs();\n newPanel.initialize();\n layer.manager.root.layerManager.layersChanged.dispatch();\n panels.specificationChanged.dispatch();\n }\n\n moveTabTo(tab: string, target: UserLayerSidePanelState) {\n if (!this.tabs.includes(tab)) return;\n {\n const { explicitTabs } = this;\n if (explicitTabs !== undefined) {\n explicitTabs.delete(tab);\n }\n }\n {\n const { explicitTabs } = target;\n if (explicitTabs !== undefined) {\n explicitTabs.add(tab);\n }\n }\n const { panels } = this;\n panels.updateTabs();\n target.selectedTab.value = tab;\n panels.specificationChanged.dispatch();\n }\n\n mergeInto(target: UserLayerSidePanelState) {\n const { explicitTabs } = target;\n if (explicitTabs !== undefined) {\n for (const tab of this.tabs) {\n explicitTabs.add(tab);\n }\n }\n const { panels } = this;\n panels.removePanel(this);\n }\n}\n\nexport class UserLayerSidePanelsState {\n panels: UserLayerSidePanelState[];\n specificationChanged = new Signal();\n updating = false;\n constructor(public layer: UserLayer) {\n this.panels = [layer.registerDisposer(new UserLayerSidePanelState(this))];\n }\n\n restoreState(obj: unknown) {\n const { panels } = this;\n panels[0].selectedTab.value = verifyOptionalObjectProperty(\n obj,\n TAB_JSON_KEY,\n verifyString,\n );\n const { layer } = this;\n const { tabs } = layer;\n const availableTabs = new Set(tabs.options.keys());\n verifyOptionalObjectProperty(obj, PANELS_JSON_KEY, (panelsObj) =>\n parseArray(panelsObj, (panelObj) => {\n verifyObject(panelObj);\n const panel = new UserLayerSidePanelState(this);\n panel.location.restoreState(panelObj);\n if (!panel.location.visible) return;\n panel.selectedTab.value = verifyOptionalObjectProperty(\n panelObj,\n TAB_JSON_KEY,\n verifyString,\n );\n panel.explicitTabs = verifyOptionalObjectProperty(\n panelObj,\n TABS_JSON_KEY,\n (tabsObj) => {\n const curTabs = new Set();\n for (const tab of verifyStringArray(tabsObj)) {\n if (!availableTabs.has(tab)) continue;\n availableTabs.delete(tab);\n curTabs.add(tab);\n }\n return curTabs;\n },\n );\n if (panel.explicitTabs === undefined) {\n panel.tabs = Array.from(availableTabs);\n availableTabs.clear();\n } else {\n panel.tabs = Array.from(panel.explicitTabs);\n }\n if (panel.tabs.length === 0) return;\n panel.normalizeTabs();\n layer.registerDisposer(panel);\n panel.initialize();\n panels.push(panel);\n }),\n );\n panels[0].tabs = Array.from(availableTabs);\n panels[0].normalizeTabs();\n this.panels[0].initialize();\n }\n\n removePanel(panel: UserLayerSidePanelState) {\n if (this.updating) return;\n const i = this.panels.indexOf(panel);\n this.panels.splice(i, 1);\n this.layer.unregisterDisposer(panel);\n this.updateTabs();\n }\n\n updateTabs() {\n const { layer } = this;\n const { tabs } = layer;\n const availableTabs = new Set(tabs.options.keys());\n const { panels } = this;\n this.updating = true;\n const updatePanelTabs = (panel: UserLayerSidePanelState) => {\n const oldTabs = panel.tabs;\n if (panel.explicitTabs === undefined) {\n panel.tabs = Array.from(availableTabs);\n availableTabs.clear();\n } else {\n panel.tabs = Array.from(panel.explicitTabs);\n for (const tab of panel.tabs) {\n availableTabs.delete(tab);\n }\n }\n if (!arraysEqual(oldTabs, panel.tabs)) {\n panel.normalizeTabs();\n panel.tabsChanged.dispatch();\n }\n };\n for (let i = 1; i < panels.length; ) {\n const panel = panels[i];\n if (panel.location.visible) {\n updatePanelTabs(panel);\n if (panel.tabs.length !== 0) {\n ++i;\n continue;\n }\n }\n panels.splice(i, 1);\n layer.unregisterDisposer(panel);\n }\n updatePanelTabs(panels[0]);\n if (panels[0].tabs.length === 0) {\n const { selectedLayer } = this.layer.manager.root;\n if (selectedLayer.layer?.layer === this.layer) {\n selectedLayer.location.visible = false;\n }\n }\n this.updating = false;\n }\n\n toJSON() {\n const { panels } = this;\n const obj: any = {};\n obj[TAB_JSON_KEY] = panels[0].selectedTab.value;\n if (panels.length > 1) {\n const panelsObj: any[] = [];\n for (let i = 1, numPanels = panels.length; i < numPanels; ++i) {\n const panel = panels[i];\n const panelObj = panel.location.toJSON() ?? {};\n panelObj[TAB_JSON_KEY] = panel.selectedTab.value;\n const { explicitTabs } = panel;\n if (explicitTabs !== undefined) {\n panelObj[TABS_JSON_KEY] = Array.from(explicitTabs);\n }\n panelsObj.push(panelObj);\n }\n obj[PANELS_JSON_KEY] = panelsObj;\n }\n return obj;\n }\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Signal } from \"#src/util/signal.js\";\n\nexport function removeSignalBinding(\n signal: Signal,\n handler: T,\n) {\n signal.remove(handler);\n}\n\nexport function addSignalBinding(\n signal: Signal,\n handler: T,\n) {\n signal.add(handler);\n}\n\nexport interface SignalBindingUpdater {\n (signal: Signal, handler: T): void;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { debounce, throttle } from \"lodash-es\";\nimport type { AnnotationLayerState } from \"#src/annotation/annotation_layer_state.js\";\nimport type { AnnotationType } from \"#src/annotation/index.js\";\nimport type { ChunkManager } from \"#src/chunk_manager/frontend.js\";\nimport type {\n CoordinateSpace,\n CoordinateTransformSpecification,\n} from \"#src/coordinate_transform.js\";\nimport {\n CoordinateSpaceCombiner,\n coordinateTransformSpecificationFromLegacyJson,\n emptyInvalidCoordinateSpace,\n isGlobalDimension,\n isLocalDimension,\n isLocalOrChannelDimension,\n TrackableCoordinateSpace,\n} from \"#src/coordinate_transform.js\";\nimport type {\n DataSourceProviderRegistry,\n DataSourceSpecification,\n DataSubsource,\n} from \"#src/datasource/index.js\";\nimport { makeEmptyDataSourceSpecification } from \"#src/datasource/index.js\";\nimport type { DisplayContext, RenderedPanel } from \"#src/display_context.js\";\nimport type { LoadedDataSubsource } from \"#src/layer/layer_data_source.js\";\nimport {\n LayerDataSource,\n layerDataSourceSpecificationFromJson,\n} from \"#src/layer/layer_data_source.js\";\nimport type {\n DisplayDimensions,\n WatchableDisplayDimensionRenderInfo,\n} from \"#src/navigation_state.js\";\nimport {\n CoordinateSpacePlaybackVelocity,\n PlaybackManager,\n Position,\n} from \"#src/navigation_state.js\";\nimport type { RenderLayerTransform } from \"#src/render_coordinate_transform.js\";\nimport {\n RENDERED_VIEW_ADD_LAYER_RPC_ID,\n RENDERED_VIEW_REMOVE_LAYER_RPC_ID,\n} from \"#src/render_layer_common.js\";\nimport type {\n RenderLayer,\n RenderLayerRole,\n VisibilityTrackedRenderLayer,\n} from \"#src/renderlayer.js\";\nimport type { VolumeType } from \"#src/sliceview/volume/base.js\";\nimport { StatusMessage } from \"#src/status.js\";\nimport { TrackableBoolean } from \"#src/trackable_boolean.js\";\nimport type {\n TrackableValueInterface,\n WatchableSet,\n WatchableValueInterface,\n} from \"#src/trackable_value.js\";\nimport { registerNested, WatchableValue } from \"#src/trackable_value.js\";\nimport {\n SELECTED_LAYER_SIDE_PANEL_DEFAULT_LOCATION,\n UserLayerSidePanelsState,\n} from \"#src/ui/layer_side_panel_state.js\";\nimport {\n DEFAULT_SIDE_PANEL_LOCATION,\n TrackableSidePanelLocation,\n} from \"#src/ui/side_panel_location.js\";\nimport type { GlobalToolBinder } from \"#src/ui/tool.js\";\nimport { LocalToolBinder, SelectedLegacyTool } from \"#src/ui/tool.js\";\nimport { gatherUpdate } from \"#src/util/array.js\";\nimport type { Borrowed, Owned } from \"#src/util/disposable.js\";\nimport { invokeDisposers, RefCounted } from \"#src/util/disposable.js\";\nimport {\n emptyToUndefined,\n parseArray,\n parseFixedLengthArray,\n verifyBoolean,\n verifyFiniteFloat,\n verifyInt,\n verifyObject,\n verifyObjectProperty,\n verifyOptionalObjectProperty,\n verifyOptionalString,\n verifyString,\n} from \"#src/util/json.js\";\nimport { MessageList } from \"#src/util/message_list.js\";\nimport type { AnyConstructor } from \"#src/util/mixin.js\";\nimport { NullarySignal, Signal } from \"#src/util/signal.js\";\nimport type { SignalBindingUpdater } from \"#src/util/signal_binding_updater.js\";\nimport {\n addSignalBinding,\n removeSignalBinding,\n} from \"#src/util/signal_binding_updater.js\";\nimport type { Trackable } from \"#src/util/trackable.js\";\nimport { Uint64 } from \"#src/util/uint64.js\";\nimport { kEmptyFloat32Vec } from \"#src/util/vector.js\";\nimport type { WatchableVisibilityPriority } from \"#src/visibility_priority/frontend.js\";\nimport type { DependentViewContext } from \"#src/widget/dependent_view_widget.js\";\nimport type { Tab } from \"#src/widget/tab_view.js\";\nimport { TabSpecification } from \"#src/widget/tab_view.js\";\nimport type { RPC } from \"#src/worker_rpc.js\";\n\nconst TOOL_JSON_KEY = \"tool\";\nconst TOOL_BINDINGS_JSON_KEY = \"toolBindings\";\nconst LOCAL_POSITION_JSON_KEY = \"localPosition\";\nconst LOCAL_VELOCITY_JSON_KEY = \"localVelocity\";\nconst LOCAL_COORDINATE_SPACE_JSON_KEY = \"localDimensions\";\nconst SOURCE_JSON_KEY = \"source\";\nconst TRANSFORM_JSON_KEY = \"transform\";\nconst PICK_JSON_KEY = \"pick\";\n\nexport interface UserLayerSelectionState {\n generation: number;\n\n // If `false`, selection is not associated with a position.\n localPositionValid: boolean;\n localPosition: Float32Array;\n localCoordinateSpace: CoordinateSpace | undefined;\n\n annotationId: string | undefined;\n annotationType: AnnotationType | undefined;\n annotationBuffer: Uint8Array | undefined;\n annotationIndex: number | undefined;\n annotationCount: number | undefined;\n annotationSourceIndex: number | undefined;\n annotationSubsource: string | undefined;\n annotationSubsubsourceId: string | undefined;\n annotationPartIndex: number | undefined;\n\n value: any;\n}\n\nexport class LayerActionContext {\n callbacks: (() => void)[] = [];\n defer(callback: () => void) {\n this.callbacks.push(callback);\n }\n}\n\nexport interface UserLayerTab {\n id: string;\n label: string;\n order: number;\n getter: (layer: UserLayer) => Tab;\n}\n\nexport const USER_LAYER_TABS: UserLayerTab[] = [];\n\nexport class UserLayer extends RefCounted {\n get localPosition() {\n return this.managedLayer.localPosition;\n }\n\n get localVelocity() {\n return this.managedLayer.localVelocity;\n }\n\n get localCoordinateSpaceCombiner() {\n return this.managedLayer.localCoordinateSpaceCombiner;\n }\n\n get localCoordinateSpace() {\n return this.managedLayer.localCoordinateSpace;\n }\n\n static type: string;\n static typeAbbreviation: string;\n\n get type() {\n return (this.constructor as typeof UserLayer).type;\n }\n\n static supportsPickOption = false;\n\n pick = new TrackableBoolean(true, true);\n\n selectionState: UserLayerSelectionState;\n\n messages = new MessageList();\n\n layerEventListeners = new Map();\n\n dispatchLayerEvent(type: string) {\n this.layerEventListeners.get(type)?.dispatch();\n }\n\n registerLayerEvent(type: string, handler: () => void) {\n const { layerEventListeners } = this;\n let existingSignal = layerEventListeners.get(type);\n if (!existingSignal) {\n existingSignal = new Signal();\n layerEventListeners.set(type, existingSignal);\n }\n const unregister = existingSignal.add(handler);\n return () => {\n const res = unregister();\n // TODO delete from layerEventListeners if no other handlers attached? currently Signal.handlers is private\n /*\n if (existingSignal.handlers.length === 0) {\n layerEventListeners.delete(type);\n }\n */\n return res;\n };\n }\n\n initializeSelectionState(state: this[\"selectionState\"]) {\n state.generation = -1;\n state.localPositionValid = false;\n state.localPosition = kEmptyFloat32Vec;\n state.localCoordinateSpace = undefined;\n state.annotationId = undefined;\n state.annotationType = undefined;\n state.annotationBuffer = undefined;\n state.annotationIndex = undefined;\n state.annotationCount = undefined;\n state.annotationSourceIndex = undefined;\n state.annotationSubsource = undefined;\n state.annotationPartIndex = undefined;\n state.value = undefined;\n }\n\n resetSelectionState(state: this[\"selectionState\"]) {\n state.localPositionValid = false;\n state.annotationId = undefined;\n state.value = undefined;\n }\n\n selectionStateFromJson(state: this[\"selectionState\"], json: any) {\n const localCoordinateSpace = (state.localCoordinateSpace =\n this.localCoordinateSpace.value);\n const { rank } = localCoordinateSpace;\n if (rank !== 0) {\n const localPosition = verifyOptionalObjectProperty(\n json,\n LOCAL_POSITION_JSON_KEY,\n (positionObj) =>\n parseFixedLengthArray(\n new Float32Array(rank),\n positionObj,\n verifyFiniteFloat,\n ),\n );\n if (localPosition === undefined) {\n state.localPositionValid = false;\n } else {\n state.localPositionValid = true;\n state.localPosition = localPosition;\n }\n }\n const annotationId = (state.annotationId = verifyOptionalObjectProperty(\n json,\n \"annotationId\",\n verifyString,\n ));\n if (annotationId !== undefined) {\n state.annotationSourceIndex = verifyOptionalObjectProperty(\n json,\n \"annotationSource\",\n verifyInt,\n 0,\n );\n state.annotationPartIndex = verifyOptionalObjectProperty(\n json,\n \"annotationPart\",\n verifyInt,\n );\n state.annotationSubsource = verifyOptionalObjectProperty(\n json,\n \"annotationSubsource\",\n verifyString,\n );\n }\n\n state.value = json.value;\n }\n\n // Derived classes should override.\n displaySelectionState(\n state: this[\"selectionState\"],\n parent: HTMLElement,\n context: DependentViewContext,\n ) {\n state;\n parent;\n context;\n return false;\n }\n\n selectionStateToJson(state: this[\"selectionState\"], forPython: boolean): any {\n forPython;\n const json: any = {};\n if (state.localPositionValid) {\n const { localPosition } = state;\n if (localPosition.length > 0) {\n json.localPosition = Array.from(localPosition);\n }\n }\n if (state.annotationId !== undefined) {\n json.annotationId = state.annotationId;\n json.annotationPart = state.annotationPartIndex;\n json.annotationSource = state.annotationSourceIndex;\n json.annotationSubsource = state.annotationSubsource;\n }\n if (state.value != null) {\n json.value = state.value;\n }\n return json;\n }\n\n captureSelectionState(\n state: this[\"selectionState\"],\n mouseState: MouseSelectionState,\n ) {\n state.localCoordinateSpace = this.localCoordinateSpace.value;\n const curLocalPosition = this.localPosition.value;\n const { localPosition } = state;\n if (localPosition.length !== curLocalPosition.length) {\n state.localPosition = curLocalPosition.slice();\n } else {\n localPosition.set(curLocalPosition);\n }\n state.localPositionValid = true;\n state.value = this.getValueAt(mouseState.position, mouseState);\n }\n\n copySelectionState(\n dest: this[\"selectionState\"],\n source: this[\"selectionState\"],\n ) {\n dest.generation = source.generation;\n dest.localPositionValid = source.localPositionValid;\n dest.localCoordinateSpace = source.localCoordinateSpace;\n const curLocalPosition = source.localPosition;\n const { localPosition } = dest;\n if (localPosition.length !== curLocalPosition.length) {\n dest.localPosition = curLocalPosition.slice();\n } else {\n dest.localPosition.set(curLocalPosition);\n }\n dest.annotationId = source.annotationId;\n dest.annotationType = source.annotationType;\n dest.annotationBuffer = source.annotationBuffer;\n dest.annotationIndex = source.annotationIndex;\n dest.annotationCount = source.annotationCount;\n dest.annotationSourceIndex = source.annotationSourceIndex;\n dest.annotationSubsource = source.annotationSubsource;\n dest.annotationPartIndex = source.annotationPartIndex;\n dest.value = source.value;\n }\n\n layersChanged = new NullarySignal();\n readyStateChanged = new NullarySignal();\n specificationChanged = new NullarySignal();\n renderLayers = new Array();\n private loadingCounter = 1;\n get isReady() {\n return this.loadingCounter === 0;\n }\n\n tabs = this.registerDisposer(new TabSpecification());\n panels = new UserLayerSidePanelsState(this);\n tool = this.registerDisposer(new SelectedLegacyTool(this));\n toolBinder = this.registerDisposer(\n new LocalToolBinder(this, this.manager.root.toolBinder),\n );\n\n dataSourcesChanged = new NullarySignal();\n dataSources: LayerDataSource[] = [];\n\n get manager() {\n return this.managedLayer.manager;\n }\n\n constructor(public managedLayer: Borrowed) {\n super();\n this.localCoordinateSpaceCombiner.includeDimensionPredicate =\n isLocalOrChannelDimension;\n this.tabs.changed.add(this.specificationChanged.dispatch);\n this.panels.specificationChanged.add(this.specificationChanged.dispatch);\n this.tool.changed.add(this.specificationChanged.dispatch);\n this.toolBinder.changed.add(this.specificationChanged.dispatch);\n this.localPosition.changed.add(this.specificationChanged.dispatch);\n this.pick.changed.add(this.specificationChanged.dispatch);\n this.pick.changed.add(this.layersChanged.dispatch);\n this.dataSourcesChanged.add(this.specificationChanged.dispatch);\n this.dataSourcesChanged.add(() => this.updateDataSubsourceActivations());\n this.messages.changed.add(this.layersChanged.dispatch);\n for (const tab of USER_LAYER_TABS) {\n this.tabs.add(tab.id, {\n label: tab.label,\n order: tab.order,\n getter: () => tab.getter(this),\n });\n }\n }\n\n canAddDataSource() {\n return true;\n }\n\n addDataSource(spec: DataSourceSpecification | undefined) {\n const layerDataSource = new LayerDataSource(this, spec);\n this.dataSources.push(layerDataSource);\n this.dataSourcesChanged.dispatch();\n return layerDataSource;\n }\n\n // Should be overridden by derived classes.\n activateDataSubsources(subsources: Iterable): void {\n subsources;\n }\n\n updateDataSubsourceActivations() {\n function* getDataSubsources(\n this: UserLayer,\n ): Iterable {\n for (const dataSource of this.dataSources) {\n const { loadState } = dataSource;\n if (loadState === undefined || loadState.error !== undefined) continue;\n for (const subsource of loadState.subsources) {\n if (subsource.enabled) {\n yield subsource;\n } else {\n const { activated } = subsource;\n subsource.messages.clearMessages();\n if (activated !== undefined) {\n activated.dispose();\n subsource.activated = undefined;\n loadState.activatedSubsourcesChanged.dispatch();\n }\n }\n }\n }\n }\n this.activateDataSubsources(getDataSubsources.call(this));\n }\n\n private decrementLoadingCounter() {\n if (--this.loadingCounter === 0) {\n this.readyStateChanged.dispatch();\n }\n }\n\n markLoading() {\n const localRetainer = this.localCoordinateSpaceCombiner.retain();\n const globalRetainer = this.manager.root.coordinateSpaceCombiner.retain();\n if (++this.loadingCounter === 1) {\n this.readyStateChanged.dispatch();\n }\n const disposer = () => {\n localRetainer();\n globalRetainer();\n this.decrementLoadingCounter();\n };\n return disposer;\n }\n\n addCoordinateSpace(\n coordinateSpace: WatchableValueInterface,\n ) {\n const globalBinding =\n this.manager.root.coordinateSpaceCombiner.bind(coordinateSpace);\n const localBinding =\n this.localCoordinateSpaceCombiner.bind(coordinateSpace);\n return () => {\n globalBinding();\n localBinding();\n };\n }\n\n initializationDone() {\n const selectionState = (this.selectionState = {} as any);\n this.initializeSelectionState(selectionState);\n this.decrementLoadingCounter();\n }\n\n getLegacyDataSourceSpecifications(\n sourceSpec: string | undefined,\n layerSpec: any,\n legacyTransform: CoordinateTransformSpecification | undefined,\n explicitSpecs: DataSourceSpecification[],\n ): DataSourceSpecification[] {\n layerSpec;\n explicitSpecs;\n if (sourceSpec === undefined) return [];\n return [layerDataSourceSpecificationFromJson(sourceSpec, legacyTransform)];\n }\n\n getDataSourceSpecifications(layerSpec: any): DataSourceSpecification[] {\n let legacySpec: any = undefined;\n let specs = verifyObjectProperty(\n layerSpec,\n SOURCE_JSON_KEY,\n (sourcesObj) => {\n if (Array.isArray(sourcesObj)) {\n return sourcesObj.map((source) =>\n layerDataSourceSpecificationFromJson(source),\n );\n }\n if (typeof sourcesObj === \"object\") {\n return [layerDataSourceSpecificationFromJson(sourcesObj)];\n }\n legacySpec = sourcesObj;\n return [];\n },\n );\n const legacyTransform = verifyObjectProperty(\n layerSpec,\n TRANSFORM_JSON_KEY,\n coordinateTransformSpecificationFromLegacyJson,\n );\n specs.push(\n ...this.getLegacyDataSourceSpecifications(\n legacySpec,\n layerSpec,\n legacyTransform,\n specs,\n ),\n );\n specs = specs.filter((spec) => spec.url);\n if (specs.length === 0) {\n specs.push(makeEmptyDataSourceSpecification());\n }\n return specs;\n }\n\n restoreState(specification: any) {\n this.tool.restoreState(specification[TOOL_JSON_KEY]);\n this.panels.restoreState(specification);\n this.localCoordinateSpace.restoreState(\n specification[LOCAL_COORDINATE_SPACE_JSON_KEY],\n );\n this.localPosition.restoreState(specification[LOCAL_POSITION_JSON_KEY]);\n this.localVelocity.restoreState(specification[LOCAL_VELOCITY_JSON_KEY]);\n this.toolBinder.restoreState(specification[TOOL_BINDINGS_JSON_KEY]);\n if ((this.constructor as typeof UserLayer).supportsPickOption) {\n this.pick.restoreState(specification[PICK_JSON_KEY]);\n }\n for (const spec of this.getDataSourceSpecifications(specification)) {\n this.addDataSource(spec);\n }\n }\n\n addRenderLayer(layer: Owned) {\n this.renderLayers.push(layer);\n const { layersChanged } = this;\n layer.layerChanged.add(layersChanged.dispatch);\n layer.userLayer = this;\n layersChanged.dispatch();\n return () => this.removeRenderLayer(layer);\n }\n\n removeRenderLayer(layer: RenderLayer) {\n const { renderLayers, layersChanged } = this;\n const index = renderLayers.indexOf(layer);\n if (index === -1) {\n throw new Error(\"Attempted to remove invalid RenderLayer\");\n }\n renderLayers.splice(index, 1);\n layer.layerChanged.remove(layersChanged.dispatch);\n layer.userLayer = undefined;\n layer.dispose();\n layersChanged.dispatch();\n }\n\n disposed() {\n const { layersChanged } = this;\n invokeDisposers(this.dataSources);\n for (const layer of this.renderLayers) {\n layer.layerChanged.remove(layersChanged.dispatch);\n layer.dispose();\n }\n this.renderLayers.length = 0;\n super.disposed();\n }\n\n getValueAt(position: Float32Array, pickState: PickState) {\n let result: any;\n const { renderLayers } = this;\n const { pickedRenderLayer } = pickState;\n if (\n pickedRenderLayer !== null &&\n renderLayers.indexOf(pickedRenderLayer) !== -1\n ) {\n result = pickedRenderLayer.transformPickedValue(pickState);\n result = this.transformPickedValue(result);\n if (result != null) return result;\n }\n for (const layer of renderLayers) {\n result = layer.getValueAt(position);\n if (result != null) {\n break;\n }\n }\n return this.transformPickedValue(result);\n }\n\n transformPickedValue(value: any) {\n return value;\n }\n\n toJSON(): any {\n return {\n type: this.type,\n [SOURCE_JSON_KEY]: dataSourcesToJson(this.dataSources),\n [TOOL_JSON_KEY]: this.tool.toJSON(),\n [TOOL_BINDINGS_JSON_KEY]: this.toolBinder.toJSON(),\n [LOCAL_COORDINATE_SPACE_JSON_KEY]: this.localCoordinateSpace.toJSON(),\n [LOCAL_POSITION_JSON_KEY]: this.localPosition.toJSON(),\n [LOCAL_VELOCITY_JSON_KEY]: this.localVelocity.toJSON(),\n [PICK_JSON_KEY]: this.pick.toJSON(),\n ...this.panels.toJSON(),\n };\n }\n\n // Derived classes should override.\n handleAction(_action: string, _context: LayerActionContext): void {}\n\n selectedValueToJson(value: any) {\n return value;\n }\n\n selectedValueFromJson(json: any) {\n return json;\n }\n\n setLayerPosition(\n modelTransform: RenderLayerTransform,\n layerPosition: Float32Array,\n ) {\n const { globalPosition } = this.manager.root;\n const { localPosition } = this;\n gatherUpdate(\n globalPosition.value,\n layerPosition,\n modelTransform.globalToRenderLayerDimensions,\n );\n gatherUpdate(\n localPosition.value,\n layerPosition,\n modelTransform.localToRenderLayerDimensions,\n );\n localPosition.changed.dispatch();\n globalPosition.changed.dispatch();\n }\n}\n\nfunction dataSourcesToJson(sources: readonly LayerDataSource[]) {\n if (sources.length === 0) return undefined;\n if (sources.length === 1) return sources[0].toJSON();\n return sources.map((x) => x.toJSON());\n}\n\nexport class ManagedUserLayer extends RefCounted {\n localCoordinateSpace = new TrackableCoordinateSpace();\n localCoordinateSpaceCombiner = new CoordinateSpaceCombiner(\n this.localCoordinateSpace,\n isLocalDimension,\n );\n localPosition = this.registerDisposer(\n new Position(this.localCoordinateSpace),\n );\n localVelocity = this.registerDisposer(\n new CoordinateSpacePlaybackVelocity(this.localCoordinateSpace),\n );\n\n // Index of layer within root layer manager, counting only non-archived layers. This is the layer\n // number shown in the layer bar and layer list panel.\n nonArchivedLayerIndex = -1;\n\n readyStateChanged = new NullarySignal();\n layerChanged = new NullarySignal();\n specificationChanged = new NullarySignal();\n containers = new Set>();\n private layer_: UserLayer | null = null;\n get layer() {\n return this.layer_;\n }\n private unregisterUserLayer: (() => void) | undefined;\n\n /**\n * If layer is not null, tranfers ownership of a reference.\n */\n set layer(layer: UserLayer | null) {\n const oldLayer = this.layer_;\n if (oldLayer != null) {\n this.unregisterUserLayer!();\n oldLayer.dispose();\n }\n this.layer_ = layer;\n if (layer != null) {\n const removers = [\n layer.layersChanged.add(this.layerChanged.dispatch),\n layer.readyStateChanged.add(this.readyStateChanged.dispatch),\n layer.specificationChanged.add(this.specificationChanged.dispatch),\n ];\n this.unregisterUserLayer = () => {\n removers.forEach((x) => x());\n };\n this.readyStateChanged.dispatch();\n this.layerChanged.dispatch();\n }\n }\n\n isReady() {\n const { layer } = this;\n return layer?.isReady;\n }\n\n private name_: string;\n\n get name() {\n return this.name_;\n }\n\n set name(value: string) {\n if (value !== this.name_) {\n this.name_ = value;\n this.layerChanged.dispatch();\n }\n }\n\n visible = true;\n archived = false;\n\n get supportsPickOption() {\n const userLayer = this.layer;\n return (\n userLayer !== null &&\n (userLayer.constructor as typeof UserLayer).supportsPickOption\n );\n }\n\n get pickEnabled() {\n const userLayer = this.layer;\n return (\n userLayer !== null &&\n (userLayer.constructor as typeof UserLayer).supportsPickOption &&\n userLayer.pick.value\n );\n }\n\n set pickEnabled(value: boolean) {\n const userLayer = this.layer;\n if (\n userLayer !== null &&\n (userLayer.constructor as typeof UserLayer).supportsPickOption\n ) {\n userLayer.pick.value = value;\n }\n }\n\n /**\n * If layer is not null, tranfers ownership of a reference.\n */\n constructor(\n name: string,\n public manager: Borrowed,\n ) {\n super();\n this.name_ = name;\n this.registerDisposer(\n new PlaybackManager(\n this.manager.root.display,\n this.localPosition,\n this.localVelocity,\n ),\n );\n }\n\n toJSON() {\n const userLayer = this.layer;\n if (userLayer === null) {\n return undefined;\n }\n const layerSpec = userLayer.toJSON();\n layerSpec.name = this.name;\n if (!this.visible) {\n if (this.archived) {\n layerSpec.archived = true;\n } else {\n layerSpec.visible = false;\n }\n }\n return layerSpec;\n }\n\n setVisible(value: boolean) {\n if (value === this.visible) return;\n if (value && this.archived) {\n this.visible = true;\n this.setArchived(false);\n return;\n }\n this.visible = value;\n this.layerChanged.dispatch();\n }\n\n setArchived(value: boolean) {\n if (this.archived === value) return;\n if (value === true) {\n this.visible = false;\n this.archived = true;\n for (const { layerManager } of this.manager.root.subsets) {\n if (!layerManager.has(this)) continue;\n layerManager.removeManagedLayer(this);\n }\n } else {\n for (const { layerManager } of this.manager.root.subsets) {\n if (layerManager.has(this)) continue;\n layerManager.addManagedLayer(this.addRef());\n }\n this.archived = false;\n }\n this.layerChanged.dispatch();\n }\n\n disposed() {\n this.layer = null;\n super.disposed();\n }\n}\n\nexport class LayerManager extends RefCounted {\n managedLayers = new Array>();\n layerSet = new Set>();\n layersChanged = new NullarySignal();\n readyStateChanged = new NullarySignal();\n specificationChanged = new NullarySignal();\n boundPositions = new WeakSet();\n numDirectUsers = 0;\n nonArchivedLayerIndexGeneration = -1;\n private renderLayerToManagedLayerMapGeneration = -1;\n private renderLayerToManagedLayerMap_ = new Map<\n RenderLayer,\n ManagedUserLayer\n >();\n\n constructor() {\n super();\n this.layersChanged.add(this.scheduleRemoveLayersWithSingleRef);\n }\n\n private scheduleRemoveLayersWithSingleRef = this.registerCancellable(\n debounce(() => this.removeLayersWithSingleRef(), 0),\n );\n\n updateNonArchivedLayerIndices() {\n const generation = this.layersChanged.count;\n if (generation === this.nonArchivedLayerIndexGeneration) return;\n this.nonArchivedLayerIndexGeneration = generation;\n let index = 0;\n for (const layer of this.managedLayers) {\n if (!layer.archived) {\n layer.nonArchivedLayerIndex = index++;\n }\n }\n for (const layer of this.managedLayers) {\n if (layer.archived) {\n layer.nonArchivedLayerIndex = index++;\n }\n }\n }\n\n getLayerByNonArchivedIndex(index: number): ManagedUserLayer | undefined {\n let i = 0;\n for (const layer of this.managedLayers) {\n if (!layer.archived) {\n if (i === index) return layer;\n ++i;\n }\n }\n return undefined;\n }\n\n get renderLayerToManagedLayerMap() {\n const generation = this.layersChanged.count;\n const map = this.renderLayerToManagedLayerMap_;\n if (this.renderLayerToManagedLayerMapGeneration !== generation) {\n this.renderLayerToManagedLayerMapGeneration = generation;\n map.clear();\n for (const managedLayer of this.managedLayers) {\n const userLayer = managedLayer.layer;\n if (userLayer !== null) {\n for (const renderLayer of userLayer.renderLayers) {\n map.set(renderLayer, managedLayer);\n }\n }\n }\n }\n return map;\n }\n\n filter(predicate: (layer: ManagedUserLayer) => boolean) {\n let changed = false;\n this.managedLayers = this.managedLayers.filter((layer) => {\n if (!predicate(layer)) {\n this.unbindManagedLayer(layer);\n this.layerSet.delete(layer);\n changed = true;\n return false;\n }\n return true;\n });\n if (changed) {\n this.layersChanged.dispatch();\n }\n }\n\n private removeLayersWithSingleRef() {\n if (this.numDirectUsers > 0) {\n return;\n }\n this.filter((layer) => layer.refCount !== 1 || layer.archived);\n }\n\n private updateSignalBindings(\n layer: ManagedUserLayer,\n callback: SignalBindingUpdater<() => void>,\n ) {\n callback(layer.layerChanged, this.layersChanged.dispatch);\n callback(layer.readyStateChanged, this.readyStateChanged.dispatch);\n callback(layer.specificationChanged, this.specificationChanged.dispatch);\n }\n\n useDirectly() {\n if (++this.numDirectUsers === 1) {\n this.layersChanged.remove(this.scheduleRemoveLayersWithSingleRef);\n }\n return () => {\n if (--this.numDirectUsers === 0) {\n this.layersChanged.add(this.scheduleRemoveLayersWithSingleRef);\n this.scheduleRemoveLayersWithSingleRef();\n }\n };\n }\n\n /**\n * Assumes ownership of an existing reference to managedLayer.\n */\n addManagedLayer(managedLayer: ManagedUserLayer, index?: number | undefined) {\n this.updateSignalBindings(managedLayer, addSignalBinding);\n this.layerSet.add(managedLayer);\n managedLayer.containers.add(this);\n if (index === undefined) {\n index = this.managedLayers.length;\n }\n this.managedLayers.splice(index, 0, managedLayer);\n this.layersChanged.dispatch();\n this.readyStateChanged.dispatch();\n return managedLayer;\n }\n\n *readyRenderLayers() {\n for (const managedUserLayer of this.managedLayers) {\n if (!managedUserLayer.visible || !managedUserLayer.layer) {\n continue;\n }\n yield* managedUserLayer.layer.renderLayers;\n }\n }\n\n unbindManagedLayer(managedLayer: ManagedUserLayer) {\n this.updateSignalBindings(managedLayer, removeSignalBinding);\n managedLayer.containers.delete(this);\n // Also notify the root LayerManager, to ensures the layer is removed if this is the last direct\n // reference.\n managedLayer.manager.rootLayers.layersChanged.dispatch();\n managedLayer.dispose();\n }\n\n clear() {\n for (const managedLayer of this.managedLayers) {\n this.unbindManagedLayer(managedLayer);\n }\n this.managedLayers.length = 0;\n this.layerSet.clear();\n this.layersChanged.dispatch();\n }\n\n remove(index: number) {\n const layer = this.managedLayers[index];\n this.unbindManagedLayer(layer);\n this.managedLayers.splice(index, 1);\n this.layerSet.delete(layer);\n this.layersChanged.dispatch();\n }\n\n removeManagedLayer(managedLayer: ManagedUserLayer) {\n const index = this.managedLayers.indexOf(managedLayer);\n if (index === -1) {\n throw new Error(\"Internal error: invalid managed layer.\");\n }\n this.remove(index);\n }\n\n reorderManagedLayer(oldIndex: number, newIndex: number) {\n const numLayers = this.managedLayers.length;\n if (\n oldIndex === newIndex ||\n oldIndex < 0 ||\n oldIndex >= numLayers ||\n newIndex < 0 ||\n newIndex >= numLayers\n ) {\n // Don't do anything.\n return;\n }\n const [oldLayer] = this.managedLayers.splice(oldIndex, 1);\n this.managedLayers.splice(newIndex, 0, oldLayer);\n this.layersChanged.dispatch();\n }\n\n disposed() {\n this.clear();\n super.disposed();\n }\n\n getLayerByName(name: string) {\n return this.managedLayers.find((x) => x.name === name);\n }\n\n getUniqueLayerName(name: string) {\n let suggestedName = name;\n let suffix = 0;\n while (this.getLayerByName(suggestedName) !== undefined) {\n suggestedName = name + ++suffix;\n }\n return suggestedName;\n }\n\n has(layer: Borrowed) {\n return this.layerSet.has(layer);\n }\n\n get renderLayers() {\n const layerManager = this;\n return {\n *[Symbol.iterator]() {\n for (const managedLayer of layerManager.managedLayers) {\n if (managedLayer.layer === null) {\n continue;\n }\n for (const renderLayer of managedLayer.layer.renderLayers) {\n yield renderLayer;\n }\n }\n },\n };\n }\n\n get visibleRenderLayers() {\n const layerManager = this;\n return {\n *[Symbol.iterator]() {\n for (const managedLayer of layerManager.managedLayers) {\n if (managedLayer.layer === null || !managedLayer.visible) {\n continue;\n }\n for (const renderLayer of managedLayer.layer.renderLayers) {\n yield renderLayer;\n }\n }\n },\n };\n }\n\n invokeAction(action: string) {\n const context = new LayerActionContext();\n for (const managedLayer of this.managedLayers) {\n if (managedLayer.layer === null || !managedLayer.visible) {\n continue;\n }\n const userLayer = managedLayer.layer;\n userLayer.handleAction(action, context);\n for (const renderLayer of userLayer.renderLayers) {\n renderLayer.handleAction(action);\n }\n }\n for (const callback of context.callbacks) {\n callback();\n }\n }\n}\n\nexport interface PickState {\n pickedRenderLayer: RenderLayer | null;\n pickedValue: Uint64;\n pickedOffset: number;\n pickedAnnotationLayer: AnnotationLayerState | undefined;\n pickedAnnotationId: string | undefined;\n pickedAnnotationBuffer: ArrayBuffer | undefined;\n pickedAnnotationBufferBaseOffset: number | undefined;\n pickedAnnotationIndex: number | undefined;\n pickedAnnotationCount: number | undefined;\n pickedAnnotationType: AnnotationType | undefined;\n}\n\nexport class MouseSelectionState implements PickState {\n changed = new NullarySignal();\n coordinateSpace: CoordinateSpace = emptyInvalidCoordinateSpace;\n position: Float32Array = kEmptyFloat32Vec;\n unsnappedPosition: Float32Array = kEmptyFloat32Vec;\n active = false;\n displayDimensions: DisplayDimensions | undefined = undefined;\n pickedRenderLayer: RenderLayer | null = null;\n pickedValue = new Uint64(0, 0);\n pickedOffset = 0;\n pickedAnnotationLayer: AnnotationLayerState | undefined = undefined;\n pickedAnnotationId: string | undefined = undefined;\n pickedAnnotationBuffer: ArrayBuffer | undefined = undefined;\n // Base offset into `pickedAnnotationBuffer` of the `pickedAnnotationCount` serialized annotations\n // of `pickedAnnotationType`.\n pickedAnnotationBufferBaseOffset: number | undefined = undefined;\n // Index (out of a total of `pickedAnnotationCount`) of the picked annotation.\n pickedAnnotationIndex: number | undefined = undefined;\n pickedAnnotationCount: number | undefined = undefined;\n pickedAnnotationType: AnnotationType | undefined = undefined;\n pageX: number;\n pageY: number;\n\n private forcerFunction: (() => void) | undefined = undefined;\n\n removeForcer(forcer: () => void) {\n if (forcer === this.forcerFunction) {\n this.forcerFunction = undefined;\n this.setActive(false);\n }\n }\n\n setForcer(forcer: (() => void) | undefined) {\n this.forcerFunction = forcer;\n if (forcer === undefined) {\n this.setActive(false);\n }\n }\n\n updateUnconditionally(): boolean {\n const { forcerFunction } = this;\n if (forcerFunction === undefined) {\n return false;\n }\n forcerFunction();\n return this.active;\n }\n\n setActive(value: boolean) {\n if (this.active !== value || value === true) {\n this.active = value;\n this.changed.dispatch();\n }\n }\n}\n\nexport class LayerSelectedValues extends RefCounted {\n changed = new NullarySignal();\n needsUpdate = true;\n constructor(\n public layerManager: LayerManager,\n public mouseState: MouseSelectionState,\n ) {\n super();\n this.registerDisposer(\n mouseState.changed.add(() => {\n this.handleChange();\n }),\n );\n this.registerDisposer(\n layerManager.layersChanged.add(() => {\n this.handleLayerChange();\n }),\n );\n }\n\n /**\n * This should be called when the layer data may have changed, due to the set of managed layers\n * changing or new data having been received.\n */\n handleLayerChange() {\n if (this.mouseState.active) {\n this.handleChange();\n }\n }\n\n handleChange() {\n this.needsUpdate = true;\n this.changed.dispatch();\n }\n\n update() {\n if (!this.needsUpdate) {\n return;\n }\n this.needsUpdate = false;\n const mouseState = this.mouseState;\n const generation = this.changed.count;\n if (mouseState.active) {\n for (const layer of this.layerManager.managedLayers) {\n const userLayer = layer.layer;\n if (layer.visible && userLayer !== null) {\n const { selectionState } = userLayer;\n userLayer.resetSelectionState(selectionState);\n selectionState.generation = generation;\n userLayer.captureSelectionState(selectionState, mouseState);\n }\n }\n }\n }\n\n get(userLayer: T): T[\"selectionState\"] | undefined {\n this.update();\n const { selectionState } = userLayer;\n if (selectionState.generation !== this.changed.count) return undefined;\n return selectionState;\n }\n\n toJSON() {\n this.update();\n const result: { [key: string]: any } = {};\n for (const layer of this.layerManager.managedLayers) {\n const userLayer = layer.layer;\n if (userLayer) {\n const state = this.get(userLayer);\n if (state !== undefined) {\n result[layer.name] = userLayer.selectionStateToJson(state, true);\n }\n }\n }\n return result;\n }\n}\n\nexport interface PersistentLayerSelectionState {\n layer: UserLayer;\n state: UserLayerSelectionState;\n}\n\nexport interface PersistentViewerSelectionState {\n layers: PersistentLayerSelectionState[];\n coordinateSpace: CoordinateSpace;\n position: Float32Array | undefined;\n}\n\nconst maxSelectionHistorySize = 10;\n\nconst DATA_SELECTION_STATE_DEFAULT_PANEL_LOCATION = {\n ...DEFAULT_SIDE_PANEL_LOCATION,\n minSize: 150,\n row: 1,\n};\n\nconst DATA_SELECTION_STATE_DEFAULT_PANEL_LOCATION_VISIBLE = {\n ...DATA_SELECTION_STATE_DEFAULT_PANEL_LOCATION,\n visible: true,\n};\n\nexport class TrackableDataSelectionState\n extends RefCounted\n implements\n TrackableValueInterface\n{\n changed = new NullarySignal();\n history: PersistentViewerSelectionState[] = [];\n historyIndex = 0;\n location = new TrackableSidePanelLocation(\n DATA_SELECTION_STATE_DEFAULT_PANEL_LOCATION,\n );\n\n constructor(\n public coordinateSpace: WatchableValueInterface,\n public layerSelectedValues: Borrowed,\n ) {\n super();\n this.registerDisposer(\n registerNested((context, pin) => {\n if (pin) return;\n this.capture(true);\n context.registerDisposer(\n layerSelectedValues.changed.add(\n context.registerCancellable(\n throttle(() => this.capture(true), 100, {\n leading: true,\n trailing: true,\n }),\n ),\n ),\n );\n }, this.pin),\n );\n this.pin.changed.add(this.changed.dispatch);\n this.location.changed.add(this.changed.dispatch);\n }\n private value_: PersistentViewerSelectionState | undefined;\n pin = new WatchableValue(true);\n get value() {\n return this.value_;\n }\n\n goBack() {\n const curIndex = this.pin.value ? this.historyIndex : this.history.length;\n if (curIndex > 0) {\n this.historyIndex = curIndex - 1;\n this.value_ = this.history[curIndex - 1];\n this.pin.value = true;\n this.changed.dispatch();\n }\n }\n\n canGoBack() {\n const curIndex = this.pin.value ? this.historyIndex : this.history.length;\n return curIndex > 0;\n }\n\n canGoForward() {\n if (!this.pin.value) return false;\n const curIndex = this.historyIndex;\n return curIndex + 1 < this.history.length;\n }\n\n goForward() {\n if (!this.pin.value) return;\n const curIndex = this.historyIndex;\n if (curIndex + 1 < this.history.length) {\n this.historyIndex = curIndex + 1;\n this.value_ = this.history[curIndex + 1];\n this.changed.dispatch();\n }\n }\n\n set value(value: PersistentViewerSelectionState | undefined) {\n if (value !== this.value_) {\n this.value_ = value;\n if (value !== undefined && this.pin.value) {\n // Add to history\n const { history } = this;\n history.length = Math.min(history.length, this.historyIndex + 1);\n history.push(value);\n if (history.length > maxSelectionHistorySize) {\n history.splice(0, history.length - maxSelectionHistorySize);\n }\n this.historyIndex = history.length - 1;\n }\n this.changed.dispatch();\n }\n }\n\n captureSingleLayerState(\n userLayer: Borrowed,\n capture: (state: T[\"selectionState\"]) => boolean,\n pin: boolean | \"toggle\" = true,\n ) {\n if (pin === false && (!this.location.visible || this.pin.value)) return;\n const state = {} as UserLayerSelectionState;\n userLayer.initializeSelectionState(state);\n if (capture(state)) {\n this.location.visible = true;\n if (pin === true) {\n this.pin.value = true;\n } else if (pin === \"toggle\") {\n this.pin.value = !this.pin.value;\n }\n this.value = {\n layers: [{ layer: userLayer, state }],\n coordinateSpace: this.coordinateSpace.value,\n position: undefined,\n };\n }\n }\n reset() {\n this.location.reset();\n this.pin.value = false;\n this.value = undefined;\n }\n toJSON() {\n // Default panel configuration, not visible: -> undefined\n // Default panel configuration, visible: -> {}\n // Non-default panel configuration, not visible: -> {side: 'left', ..., visible: false}}\n // Non-default panel configuration, visible: -> {side: 'left', ...}\n const { value } = this;\n let obj: any;\n if (this.location.visible) {\n obj = this.location.toJSON(\n DATA_SELECTION_STATE_DEFAULT_PANEL_LOCATION_VISIBLE,\n );\n if (this.pin.value && value !== undefined) {\n const layersJson: any = {};\n for (const layerData of value.layers) {\n const { layer } = layerData;\n let data = layer.selectionStateToJson(layerData.state, false);\n if (Object.keys(data).length === 0) data = undefined;\n layersJson[layerData.layer.managedLayer.name] = data;\n }\n if (value.position !== undefined) {\n obj.position = Array.from(value.position);\n }\n obj.layers = layersJson;\n }\n } else {\n obj = this.location.toJSON(DATA_SELECTION_STATE_DEFAULT_PANEL_LOCATION);\n obj = emptyToUndefined(obj);\n if (obj !== undefined) {\n obj.visible = false;\n }\n }\n return obj;\n }\n select() {\n const { pin } = this;\n this.location.visible = true;\n pin.value = !pin.value;\n if (pin.value) {\n this.capture();\n }\n }\n capture(canRetain = false) {\n const newValue = capturePersistentViewerSelectionState(\n this.layerSelectedValues,\n );\n if (canRetain && newValue === undefined) return;\n this.value = newValue;\n }\n restoreState(obj: unknown) {\n if (obj === undefined) {\n this.pin.value = true;\n this.value = undefined;\n return;\n }\n if (obj === null) {\n // Support for old representation where `null` means visible but unpinned.\n this.pin.value = false;\n this.location.visible = true;\n this.value = undefined;\n return;\n }\n verifyObject(obj);\n // If the object is present, then visible by default.\n this.location.restoreState(\n obj,\n DATA_SELECTION_STATE_DEFAULT_PANEL_LOCATION_VISIBLE,\n );\n const coordinateSpace = this.coordinateSpace.value;\n const position = verifyOptionalObjectProperty(\n obj,\n \"position\",\n (positionObj) =>\n parseFixedLengthArray(\n new Float32Array(coordinateSpace.rank),\n positionObj,\n verifyFiniteFloat,\n ),\n );\n const layers: PersistentLayerSelectionState[] = [];\n verifyOptionalObjectProperty(obj, \"layers\", (layersObj) => {\n verifyObject(layersObj);\n const { layerManager } = this.layerSelectedValues;\n for (const [name, entry] of Object.entries(layersObj)) {\n const managedLayer = layerManager.getLayerByName(name);\n if (managedLayer === undefined) return;\n const layer = managedLayer.layer;\n if (layer === null) return;\n verifyObject(entry);\n const state: UserLayerSelectionState = {} as any;\n layer.initializeSelectionState(state);\n layer.selectionStateFromJson(state, entry);\n layers.push({ layer, state });\n }\n });\n this.pin.value = layers.length > 0 || position !== undefined;\n this.value = { position, coordinateSpace, layers };\n }\n}\n\nexport function capturePersistentViewerSelectionState(\n layerSelectedValues: Borrowed,\n): PersistentViewerSelectionState | undefined {\n const { mouseState } = layerSelectedValues;\n if (!mouseState.active) return undefined;\n const layers: PersistentLayerSelectionState[] = [];\n for (const layer of layerSelectedValues.layerManager.managedLayers) {\n const userLayer = layer.layer;\n if (userLayer === null) continue;\n const state = layerSelectedValues.get(userLayer);\n if (state === undefined) continue;\n const stateCopy = {} as UserLayerSelectionState;\n userLayer.initializeSelectionState(stateCopy);\n userLayer.copySelectionState(stateCopy, state);\n layers.push({\n layer: userLayer,\n state: stateCopy,\n });\n }\n return {\n position: mouseState.position.slice(),\n coordinateSpace: mouseState.coordinateSpace,\n layers,\n };\n}\n\nexport interface LayerView {\n displayDimensionRenderInfo: WatchableDisplayDimensionRenderInfo;\n flushBackendProjectionParameters(): void;\n rpc: RPC;\n rpcId: number;\n}\n\nexport class VisibleLayerInfo<\n View extends LayerView = LayerView,\n AttachmentState = unknown,\n> extends RefCounted {\n messages = new MessageList();\n seenGeneration = -1;\n state: AttachmentState | undefined = undefined;\n constructor(public view: View) {\n super();\n }\n}\n\nlet visibleLayerInfoGeneration = 0;\n\nexport class VisibleRenderLayerTracker<\n View extends LayerView,\n RenderLayerType extends VisibilityTrackedRenderLayer,\n> extends RefCounted {\n /**\n * Maps a layer to the disposer to call when it is no longer visible.\n */\n private visibleLayers_ = new Map>();\n\n private debouncedUpdateVisibleLayers = this.registerCancellable(\n debounce(() => this.updateVisibleLayers(), 0),\n );\n\n constructor(\n public layerManager: LayerManager,\n public renderLayerType: { new (...args: any[]): RenderLayerType },\n public view: View,\n public roles: WatchableSet,\n private layerAdded: (\n layer: RenderLayerType,\n info: VisibleLayerInfo,\n ) => void,\n public visibility: WatchableVisibilityPriority,\n ) {\n super();\n this.registerDisposer(\n layerManager.layersChanged.add(this.debouncedUpdateVisibleLayers),\n );\n this.registerDisposer(roles.changed.add(this.debouncedUpdateVisibleLayers));\n this.updateVisibleLayers();\n }\n\n disposed() {\n this.visibleLayers.forEach((attachment) => attachment.dispose());\n this.visibleLayers.clear();\n super.disposed();\n }\n\n private updateVisibleLayers() {\n const curGeneration = ++visibleLayerInfoGeneration;\n const {\n visibleLayers_: visibleLayers,\n renderLayerType,\n layerAdded,\n roles,\n } = this;\n for (const renderLayer of this.layerManager.readyRenderLayers()) {\n if (\n renderLayer instanceof renderLayerType &&\n roles.has(renderLayer.role)\n ) {\n const typedLayer = renderLayer;\n let info = visibleLayers.get(typedLayer);\n if (info === undefined) {\n info = new VisibleLayerInfo(this.view);\n info.registerDisposer(typedLayer.messages.addChild(info.messages));\n info.registerDisposer(typedLayer.addRef());\n info.registerDisposer(typedLayer.visibility.add(this.visibility));\n visibleLayers.set(typedLayer, info);\n layerAdded(typedLayer, info);\n typedLayer.attach(info);\n }\n info.seenGeneration = curGeneration;\n }\n }\n for (const [renderLayer, info] of visibleLayers) {\n if (info.seenGeneration !== curGeneration) {\n visibleLayers.delete(renderLayer);\n info.dispose();\n }\n }\n }\n\n get visibleLayers() {\n this.debouncedUpdateVisibleLayers.flush();\n return this.visibleLayers_;\n }\n}\n\nexport function makeRenderedPanelVisibleLayerTracker<\n View extends RenderedPanel & LayerView,\n RenderLayerType extends VisibilityTrackedRenderLayer,\n>(\n layerManager: LayerManager,\n renderLayerType: { new (...args: any[]): RenderLayerType },\n roles: WatchableSet,\n panel: View,\n layerAdded?: (layer: RenderLayerType, info: VisibleLayerInfo) => void,\n) {\n return panel.registerDisposer(\n new VisibleRenderLayerTracker(\n layerManager,\n renderLayerType,\n panel,\n roles,\n (layer, info) => {\n info.registerDisposer(\n layer.redrawNeeded.add(() => panel.scheduleRedraw()),\n );\n const { backend } = layer;\n if (backend) {\n backend.rpc!.invoke(RENDERED_VIEW_ADD_LAYER_RPC_ID, {\n layer: backend.rpcId,\n view: panel.rpcId,\n });\n info.registerDisposer(() =>\n backend.rpc!.invoke(RENDERED_VIEW_REMOVE_LAYER_RPC_ID, {\n layer: backend.rpcId,\n view: panel.rpcId,\n }),\n );\n }\n if (layerAdded !== undefined) {\n layerAdded(layer, info);\n }\n panel.scheduleRedraw();\n info.registerDisposer(() => panel.scheduleRedraw());\n },\n panel.visibility,\n ),\n );\n}\n\nexport class SelectedLayerState extends RefCounted implements Trackable {\n changed = new NullarySignal();\n location = new TrackableSidePanelLocation(\n SELECTED_LAYER_SIDE_PANEL_DEFAULT_LOCATION,\n );\n layer_: ManagedUserLayer | undefined;\n\n get layer() {\n return this.layer_;\n }\n\n get visible() {\n return this.location.visible;\n }\n\n toggle(layer: ManagedUserLayer) {\n if (this.layer === layer && this.visible) {\n this.visible = false;\n } else {\n this.layer = layer;\n this.visible = true;\n }\n }\n\n set visible(value: boolean) {\n let existingLayer = this.layer_;\n if (value === true && existingLayer === undefined) {\n // Check if there is a layer\n const { managedLayers } = this.layerManager;\n if (managedLayers.length > 0) {\n existingLayer = this.layer = managedLayers[0];\n } else {\n value = false;\n }\n }\n if (value === true && existingLayer !== undefined) {\n const userLayer = existingLayer.layer;\n if (userLayer === null || userLayer.panels.panels[0].tabs.length === 0) {\n value = false;\n }\n }\n if (this.visible !== value) {\n this.location.visible = value;\n if (!value && existingLayer !== undefined) {\n this.maybeDeleteNewLayer(existingLayer);\n }\n this.changed.dispatch();\n }\n }\n\n private maybeDeleteNewLayer(existingLayer: ManagedUserLayer) {\n if (existingLayer.wasDisposed) return;\n const userLayer = existingLayer.layer;\n if (userLayer !== null && userLayer instanceof NewUserLayer) {\n if (!userLayer.dataSources.some((x) => x.spec.url.length !== 0)) {\n deleteLayer(existingLayer);\n }\n }\n }\n\n private existingLayerDisposer?: () => void;\n\n constructor(public layerManager: Owned) {\n super();\n this.registerDisposer(layerManager);\n this.location.changed.add(() => {\n this.changed.dispatch();\n const userLayer = this.layer?.layer ?? undefined;\n if (userLayer !== undefined) {\n const curLocation = this.location.value;\n if (curLocation.visible) {\n const panel = userLayer.panels.panels[0];\n if (panel.location.value !== curLocation) {\n panel.location.value = curLocation;\n panel.location.locationChanged.dispatch();\n }\n }\n }\n });\n }\n\n set layer(layer: ManagedUserLayer | undefined) {\n if (layer === this.layer_) {\n return;\n }\n const existingLayer = this.layer_;\n if (existingLayer !== undefined) {\n this.existingLayerDisposer!();\n this.existingLayerDisposer = undefined;\n this.maybeDeleteNewLayer(existingLayer);\n }\n this.layer_ = layer;\n if (layer !== undefined) {\n const layerDisposed = () => {\n this.layer_ = undefined;\n this.visible = false;\n this.existingLayerDisposer = undefined;\n this.changed.dispatch();\n };\n layer.registerDisposer(layerDisposed);\n const layerChangedDisposer = layer.specificationChanged.add(() => {\n this.changed.dispatch();\n });\n this.existingLayerDisposer = () => {\n const userLayer = layer.layer;\n if (userLayer !== null) {\n const tool = userLayer.tool.value;\n if (tool !== undefined) {\n tool.deactivate();\n }\n }\n layer.unregisterDisposer(layerDisposed);\n layerChangedDisposer();\n };\n } else {\n this.location.visible = false;\n }\n this.changed.dispatch();\n }\n\n toJSON() {\n const obj: any = this.location.toJSON();\n if (this.layer !== undefined) {\n obj.layer = this.layer.name;\n }\n return emptyToUndefined(obj);\n }\n\n restoreState(obj: any) {\n if (obj === undefined) {\n this.reset();\n return;\n }\n verifyObject(obj);\n this.location.restoreState(obj);\n const layerName = verifyObjectProperty(obj, \"layer\", verifyOptionalString);\n const layer =\n layerName !== undefined\n ? this.layerManager.getLayerByName(layerName)\n : undefined;\n if (layer === undefined) {\n this.visible = false;\n }\n this.layer = layer;\n }\n\n reset() {\n this.location.reset();\n this.layer = undefined;\n }\n}\n\nexport class LayerReference extends RefCounted implements Trackable {\n private layerName_: string | undefined;\n private layer_: ManagedUserLayer | undefined;\n changed = new NullarySignal();\n constructor(\n public layerManager: Owned,\n public filter: (layer: ManagedUserLayer) => boolean,\n ) {\n super();\n this.registerDisposer(layerManager);\n this.registerDisposer(\n layerManager.specificationChanged.add(() => {\n const { layer_ } = this;\n if (layer_ !== undefined) {\n if (!this.layerManager.layerSet.has(layer_) || !this.filter(layer_)) {\n this.layer_ = undefined;\n this.layerName_ = undefined;\n this.changed.dispatch();\n } else {\n const { name } = layer_;\n if (name !== this.layerName_) {\n this.layerName_ = name;\n this.changed.dispatch();\n }\n }\n }\n }),\n );\n }\n\n get layer() {\n return this.layer_;\n }\n\n get layerName() {\n return this.layerName_;\n }\n\n set layer(value: ManagedUserLayer | undefined) {\n if (this.layer_ === value) {\n return;\n }\n if (\n value !== undefined &&\n this.layerManager.layerSet.has(value) &&\n this.filter(value)\n ) {\n this.layer_ = value;\n this.layerName_ = value.name;\n } else {\n this.layer_ = undefined;\n this.layerName_ = undefined;\n }\n this.changed.dispatch();\n }\n\n set layerName(value: string | undefined) {\n if (value === this.layerName_) {\n return;\n }\n this.layer_ = undefined;\n this.layerName_ = value;\n this.changed.dispatch();\n this.validate();\n }\n\n private validate = debounce(() => {\n const { layerName_ } = this;\n if (layerName_ !== undefined) {\n const layer = this.layerManager.getLayerByName(layerName_);\n if (layer !== undefined && this.filter(layer)) {\n this.layer_ = layer;\n this.changed.dispatch();\n } else {\n this.layer_ = undefined;\n this.layerName_ = undefined;\n this.changed.dispatch();\n }\n }\n }, 0);\n\n restoreState(obj: any) {\n const layerName = verifyOptionalString(obj);\n this.layerName = layerName;\n }\n\n toJSON() {\n const { layer_ } = this;\n if (layer_ !== undefined) {\n return layer_.name;\n }\n return this.layerName_;\n }\n\n reset() {\n this.layerName_ = undefined;\n this.layer_ = undefined;\n this.changed.dispatch();\n }\n}\n\n// Group of layers that share a set of properties, e.g. visible segment set.\nexport class LinkedLayerGroup extends RefCounted implements Trackable {\n // Only valid if `root_ == this.layer`.\n private linkedLayers_ = new Set();\n private root_: UserLayer;\n changed = new NullarySignal();\n linkedLayersChanged = new NullarySignal();\n readonly root: WatchableValueInterface;\n\n get linkedLayers(): ReadonlySet {\n return this.linkedLayers_;\n }\n\n get rootGroup(): LinkedLayerGroup {\n return this.getGroup(this.root.value);\n }\n\n constructor(\n public layerManager: LayerManager,\n public layer: UserLayer,\n public predicate: (layer: UserLayer) => boolean,\n public getGroup: (layer: UserLayer) => LinkedLayerGroup,\n ) {\n super();\n this.root_ = layer;\n const self = this;\n this.root = {\n get value() {\n return self.root_;\n },\n changed: self.changed,\n };\n }\n\n reset() {\n this.isolate();\n }\n\n restoreState(obj: unknown) {\n if (obj === undefined) return;\n const name = verifyString(obj);\n this.linkByName(name);\n }\n\n toJSON() {\n const {\n root: { value: root },\n } = this;\n if (root === this.layer) return undefined;\n return root.managedLayer.name;\n }\n\n isolate(notifyChanged = true) {\n const { getGroup, layer, root_: root } = this;\n if (root === layer) {\n const { linkedLayers_ } = this;\n if (linkedLayers_.size !== 0) {\n for (const otherLayer of linkedLayers_) {\n const otherGroup = getGroup(otherLayer);\n otherGroup.root_ = otherLayer;\n otherGroup.changed.dispatch();\n }\n linkedLayers_.clear();\n this.linkedLayersChanged.dispatch();\n }\n return;\n }\n const rootGroup = getGroup(root);\n rootGroup.linkedLayers_.delete(layer);\n rootGroup.linkedLayersChanged.dispatch();\n this.root_ = layer;\n if (notifyChanged) {\n this.changed.dispatch();\n }\n }\n\n linkByName(otherLayerName: string) {\n const { layer } = this;\n const { managedLayer } = layer;\n const { layerManager } = this;\n const otherLayer = layerManager.getLayerByName(otherLayerName);\n if (otherLayer === undefined) return;\n if (otherLayer === managedLayer) return;\n const otherUserLayer = otherLayer.layer;\n if (otherUserLayer === null) return;\n if (!this.predicate(otherUserLayer)) return;\n this.linkToLayer(otherUserLayer);\n }\n\n linkToLayer(otherUserLayer: UserLayer) {\n if (otherUserLayer === this.layer) return;\n if (this.root_ === otherUserLayer) return;\n if (this.root_ !== this.layer) {\n this.isolate(/*notifyChanged=*/ false);\n }\n const { getGroup } = this;\n const newRoot = getGroup(otherUserLayer).root_;\n if (newRoot === this.layer) return;\n const rootGroup = getGroup(newRoot);\n rootGroup.linkedLayers_.add(this.layer);\n rootGroup.linkedLayersChanged.dispatch();\n this.root_ = newRoot;\n this.changed.dispatch();\n }\n\n disposed() {\n this.isolate(/*notifyChanged=*/ false);\n }\n}\n\nfunction initializeLayerFromSpecNoRestoreState(\n managedLayer: ManagedUserLayer,\n spec: any,\n) {\n const layerType = verifyOptionalObjectProperty(\n spec,\n \"type\",\n verifyString,\n \"auto\",\n );\n managedLayer.archived = verifyOptionalObjectProperty(\n spec,\n \"archived\",\n verifyBoolean,\n false,\n );\n if (!managedLayer.archived) {\n managedLayer.visible = verifyOptionalObjectProperty(\n spec,\n \"visible\",\n verifyBoolean,\n true,\n );\n } else {\n managedLayer.visible = false;\n }\n const layerConstructor = layerTypes.get(layerType) || NewUserLayer;\n managedLayer.layer = new layerConstructor(managedLayer);\n return spec;\n}\n\nfunction completeUserLayerInitialization(\n managedLayer: Borrowed,\n spec: any,\n) {\n try {\n const userLayer = managedLayer.layer;\n if (userLayer === null) return;\n userLayer.restoreState(spec);\n userLayer.initializationDone();\n } catch (e) {\n deleteLayer(managedLayer);\n throw e;\n }\n}\n\nexport function initializeLayerFromSpec(\n managedLayer: Borrowed,\n spec: any,\n) {\n try {\n verifyObject(spec);\n initializeLayerFromSpecNoRestoreState(managedLayer, spec);\n completeUserLayerInitialization(managedLayer, spec);\n } catch (e) {\n deleteLayer(managedLayer);\n throw e;\n }\n}\n\nexport function initializeLayerFromSpecShowErrorStatus(\n managedLayer: Borrowed,\n spec: any,\n) {\n try {\n initializeLayerFromSpec(managedLayer, spec);\n } catch (e) {\n const msg = new StatusMessage();\n msg.setErrorMessage(e instanceof Error ? e.message : \"\" + e);\n }\n}\n\nexport function makeLayer(\n manager: LayerListSpecification,\n name: string,\n spec: any,\n): ManagedUserLayer {\n const managedLayer = new ManagedUserLayer(name, manager);\n initializeLayerFromSpec(managedLayer, spec);\n return managedLayer;\n}\n\nexport abstract class LayerListSpecification extends RefCounted {\n changed = new NullarySignal();\n\n abstract rpc: RPC;\n\n abstract dataSourceProviderRegistry: Borrowed;\n abstract layerManager: Borrowed;\n abstract chunkManager: Borrowed;\n abstract layerSelectedValues: Borrowed;\n\n abstract readonly root: TopLevelLayerListSpecification;\n\n abstract add(\n layer: Owned,\n index?: number | undefined,\n ): void;\n\n abstract rootLayers: Borrowed;\n}\n\nexport class TopLevelLayerListSpecification extends LayerListSpecification {\n get rpc() {\n return this.chunkManager.rpc!;\n }\n\n get root() {\n return this;\n }\n\n coordinateSpaceCombiner = new CoordinateSpaceCombiner(\n this.coordinateSpace,\n isGlobalDimension,\n );\n subsets = new Set();\n\n layerSelectedValues = this.selectionState.layerSelectedValues;\n\n constructor(\n public display: DisplayContext,\n public dataSourceProviderRegistry: DataSourceProviderRegistry,\n public layerManager: LayerManager,\n public chunkManager: ChunkManager,\n public selectionState: Borrowed,\n public selectedLayer: Borrowed,\n public coordinateSpace: WatchableValueInterface,\n public globalPosition: Borrowed,\n public toolBinder: Borrowed,\n ) {\n super();\n this.registerDisposer(\n layerManager.layersChanged.add(this.changed.dispatch),\n );\n this.registerDisposer(\n layerManager.specificationChanged.add(this.changed.dispatch),\n );\n }\n\n reset() {\n this.layerManager.clear();\n }\n\n restoreState(x: any) {\n this.layerManager.clear();\n let layerSpecs: any[];\n if (!Array.isArray(x)) {\n verifyObject(x);\n layerSpecs = Object.entries(x).map(([name, layerSpec]) => {\n if (typeof layerSpec === \"string\") {\n return { name, source: layerSpec };\n }\n verifyObject(layerSpec);\n return { ...(layerSpec as any), name };\n });\n } else {\n layerSpecs = x;\n }\n const layersToRestore: { managedLayer: ManagedUserLayer; spec: any }[] = [];\n for (const layerSpec of layerSpecs) {\n verifyObject(layerSpec);\n const name = this.layerManager.getUniqueLayerName(\n verifyObjectProperty(layerSpec, \"name\", verifyString),\n );\n const managedLayer = new ManagedUserLayer(name, this);\n try {\n initializeLayerFromSpecNoRestoreState(managedLayer, layerSpec);\n this.layerManager.addManagedLayer(managedLayer);\n layersToRestore.push({ managedLayer, spec: layerSpec });\n } catch (e) {\n managedLayer.dispose();\n const msg = new StatusMessage();\n msg.setErrorMessage(\n `Error creating layer ${JSON.stringify(name)}: ` +\n (e instanceof Error)\n ? e.message\n : \"\" + e,\n );\n }\n }\n for (const { managedLayer, spec } of layersToRestore) {\n try {\n completeUserLayerInitialization(managedLayer, spec);\n } catch (e) {\n const msg = new StatusMessage();\n msg.setErrorMessage(\n `Error creating layer ${JSON.stringify(name)}: ` +\n (e instanceof Error)\n ? e.message\n : \"\" + e,\n );\n }\n }\n }\n\n add(layer: ManagedUserLayer, index?: number | undefined) {\n if (this.layerManager.managedLayers.indexOf(layer) === -1) {\n layer.name = this.layerManager.getUniqueLayerName(layer.name);\n }\n this.layerManager.addManagedLayer(layer, index);\n }\n\n toJSON() {\n const result = [];\n let numResults = 0;\n for (const managedLayer of this.layerManager.managedLayers) {\n const layerJson = managedLayer.toJSON();\n // A `null` layer specification is used to indicate a transient drag target, and should not be\n // serialized.\n if (layerJson != null) {\n result.push(layerJson);\n ++numResults;\n }\n }\n if (numResults === 0) {\n return undefined;\n }\n return result;\n }\n\n get rootLayers() {\n return this.layerManager;\n }\n}\n\n/**\n * Class for specifying a subset of a TopLevelLayerListsSpecification.\n */\nexport class LayerSubsetSpecification extends LayerListSpecification {\n changed = new NullarySignal();\n get rpc() {\n return this.master.rpc;\n }\n get dataSourceProviderRegistry() {\n return this.master.dataSourceProviderRegistry;\n }\n get chunkManager() {\n return this.master.chunkManager;\n }\n get layerSelectedValues() {\n return this.master.layerSelectedValues;\n }\n\n get root() {\n return this.master;\n }\n\n layerManager = this.registerDisposer(new LayerManager());\n\n constructor(public master: Owned) {\n super();\n this.registerDisposer(master);\n const { layerManager } = this;\n this.registerDisposer(\n layerManager.layersChanged.add(this.changed.dispatch),\n );\n this.registerDisposer(\n layerManager.specificationChanged.add(this.changed.dispatch),\n );\n master.subsets.add(this);\n }\n\n disposed() {\n super.disposed();\n this.master.subsets.delete(this);\n }\n\n reset() {\n this.layerManager.clear();\n }\n\n restoreState(x: any) {\n const masterLayerManager = this.master.layerManager;\n const layers: ManagedUserLayer[] = [];\n for (const name of new Set(parseArray(x, verifyString))) {\n const layer = masterLayerManager.getLayerByName(name);\n if (layer === undefined) {\n throw new Error(\n `Undefined layer referenced in subset specification: ${JSON.stringify(\n name,\n )}`,\n );\n }\n if (layer.archived) continue;\n layers.push(layer);\n }\n this.layerManager.clear();\n for (const layer of layers) {\n this.layerManager.addManagedLayer(layer.addRef());\n }\n }\n\n toJSON() {\n return this.layerManager.managedLayers.map((x) => x.name);\n }\n\n add(layer: ManagedUserLayer, index?: number | undefined) {\n if (this.master.layerManager.managedLayers.indexOf(layer) === -1) {\n layer.name = this.master.layerManager.getUniqueLayerName(layer.name);\n this.master.layerManager.addManagedLayer(layer.addRef());\n }\n this.layerManager.addManagedLayer(layer, index);\n }\n\n get rootLayers() {\n return this.master.rootLayers;\n }\n}\n\nexport type UserLayerConstructor =\n typeof UserLayer & AnyConstructor;\n\nexport const layerTypes = new Map();\nconst volumeLayerTypes = new Map();\nexport interface LayerTypeGuess {\n // Layer constructor\n layerConstructor: UserLayerConstructor;\n // Priority of the guess. Higher values take precedence.\n priority: number;\n}\nexport type LayerTypeDetector = (\n subsource: DataSubsource,\n) => LayerTypeGuess | undefined;\nconst layerTypeDetectors: LayerTypeDetector[] = [\n (subsource) => {\n const { volume } = subsource;\n if (volume === undefined) return undefined;\n const layerConstructor = volumeLayerTypes.get(volume.volumeType);\n if (layerConstructor === undefined) return undefined;\n return { layerConstructor, priority: 0 };\n },\n];\n\nexport function registerLayerType(\n layerConstructor: UserLayerConstructor,\n name: string = layerConstructor.type,\n) {\n layerTypes.set(name, layerConstructor);\n}\n\nexport function registerLayerTypeDetector(detector: LayerTypeDetector) {\n layerTypeDetectors.push(detector);\n}\n\nexport function registerVolumeLayerType(\n volumeType: VolumeType,\n layerConstructor: UserLayerConstructor,\n) {\n volumeLayerTypes.set(volumeType, layerConstructor);\n}\n\nexport function changeLayerType(\n managedLayer: Borrowed,\n layerConstructor: typeof UserLayer,\n) {\n const userLayer = managedLayer.layer;\n if (userLayer === null) return;\n const spec = userLayer.toJSON();\n const newUserLayer = new layerConstructor(managedLayer);\n newUserLayer.restoreState(spec);\n newUserLayer.initializationDone();\n managedLayer.layer = newUserLayer;\n}\n\nexport function changeLayerName(\n managedLayer: Borrowed,\n newName: string,\n): boolean {\n if (newName !== managedLayer.name) {\n newName =\n managedLayer.manager.root.layerManager.getUniqueLayerName(newName);\n managedLayer.name = newName;\n managedLayer.layerChanged.dispatch();\n return true;\n }\n return false;\n}\n\nexport function deleteLayer(managedLayer: Borrowed) {\n if (managedLayer.wasDisposed) return;\n for (const layerManager of managedLayer.containers) {\n layerManager.removeManagedLayer(managedLayer);\n }\n}\n\nfunction getMaxPriorityGuess(\n a: LayerTypeGuess | undefined,\n b: LayerTypeGuess | undefined,\n) {\n if (a === undefined) return b;\n if (b === undefined) return a;\n return a.priority < b.priority ? b : a;\n}\n\nexport function detectLayerTypeFromDataSubsource(\n subsource: DataSubsource,\n): LayerTypeGuess | undefined {\n let bestGuess: LayerTypeGuess | undefined;\n for (const detector of layerTypeDetectors) {\n bestGuess = getMaxPriorityGuess(bestGuess, detector(subsource));\n }\n const { volume } = subsource;\n if (volume !== undefined) {\n const layerConstructor = volumeLayerTypes.get(volume.volumeType);\n if (layerConstructor !== undefined) {\n bestGuess = getMaxPriorityGuess(bestGuess, {\n layerConstructor,\n priority: 0,\n });\n }\n }\n return bestGuess;\n}\n\nexport function detectLayerType(\n userLayer: UserLayer,\n): UserLayerConstructor | undefined {\n let guess: LayerTypeGuess | undefined;\n for (const dataSource of userLayer.dataSources) {\n const { loadState } = dataSource;\n if (loadState === undefined || loadState.error !== undefined) continue;\n for (const loadedSubsource of loadState.subsources) {\n const { subsourceEntry } = loadedSubsource;\n const { subsource } = subsourceEntry;\n if (!loadedSubsource.enabled) continue;\n guess = getMaxPriorityGuess(\n guess,\n detectLayerTypeFromDataSubsource(subsource),\n );\n }\n }\n return guess?.layerConstructor;\n}\n\nfunction detectLayerTypeFromSubsources(\n subsources: Iterable,\n): LayerTypeGuess | undefined {\n let guess: LayerTypeGuess | undefined;\n for (const loadedSubsource of subsources) {\n const { subsourceEntry } = loadedSubsource;\n const { subsource } = subsourceEntry;\n guess = getMaxPriorityGuess(\n guess,\n detectLayerTypeFromDataSubsource(subsource),\n );\n }\n return guess;\n}\n\n/**\n * Special UserLayer type used when creating a new layer in the UI.\n */\nexport class NewUserLayer extends UserLayer {\n static type = \"new\";\n static typeAbbreviation = \"new\";\n detectedLayerConstructor: UserLayerConstructor | undefined;\n\n activateDataSubsources(subsources: Iterable) {\n this.detectedLayerConstructor =\n detectLayerTypeFromSubsources(subsources)?.layerConstructor;\n }\n}\n\n/**\n * Special UserLayer type that automatically changes to the appropriate layer type.\n */\nexport class AutoUserLayer extends UserLayer {\n static type = \"auto\";\n static typeAbbreviation = \"auto\";\n\n activateDataSubsources(subsources: Iterable) {\n const layerConstructor =\n detectLayerTypeFromSubsources(subsources)?.layerConstructor;\n if (layerConstructor !== undefined) {\n changeLayerType(this.managedLayer, layerConstructor);\n }\n }\n}\n\nexport function addNewLayer(\n manager: Borrowed,\n selectedLayer: Borrowed,\n) {\n const layer = makeLayer(manager, \"new layer\", { type: \"new\" });\n manager.add(layer);\n selectedLayer.layer = layer;\n selectedLayer.visible = true;\n}\n\nregisterLayerType(NewUserLayer);\nregisterLayerType(AutoUserLayer);\n","export const SELECTED_ALPHA_JSON_KEY = \"selectedAlpha\";\nexport const NOT_SELECTED_ALPHA_JSON_KEY = \"notSelectedAlpha\";\nexport const OBJECT_ALPHA_JSON_KEY = \"objectAlpha\";\nexport const SATURATION_JSON_KEY = \"saturation\";\nexport const HOVER_HIGHLIGHT_JSON_KEY = \"hoverHighlight\";\nexport const HIDE_SEGMENT_ZERO_JSON_KEY = \"hideSegmentZero\";\nexport const BASE_SEGMENT_COLORING_JSON_KEY = \"baseSegmentColoring\";\nexport const IGNORE_NULL_VISIBLE_SET_JSON_KEY = \"ignoreNullVisibleSet\";\nexport const MESH_JSON_KEY = \"mesh\";\nexport const SKELETONS_JSON_KEY = \"skeletons\";\nexport const SEGMENTS_JSON_KEY = \"segments\";\nexport const EQUIVALENCES_JSON_KEY = \"equivalences\";\nexport const COLOR_SEED_JSON_KEY = \"colorSeed\";\nexport const SEGMENT_STATED_COLORS_JSON_KEY = \"segmentColors\";\nexport const MESH_RENDER_SCALE_JSON_KEY = \"meshRenderScale\";\nexport const CROSS_SECTION_RENDER_SCALE_JSON_KEY = \"crossSectionRenderScale\";\nexport const SKELETON_RENDERING_JSON_KEY = \"skeletonRendering\";\nexport const SKELETON_SHADER_JSON_KEY = \"skeletonShader\";\nexport const SEGMENT_QUERY_JSON_KEY = \"segmentQuery\";\nexport const MESH_SILHOUETTE_RENDERING_JSON_KEY = \"meshSilhouetteRendering\";\nexport const LINKED_SEGMENTATION_GROUP_JSON_KEY = \"linkedSegmentationGroup\";\nexport const LINKED_SEGMENTATION_COLOR_GROUP_JSON_KEY =\n \"linkedSegmentationColorGroup\";\nexport const SEGMENT_DEFAULT_COLOR_JSON_KEY = \"segmentDefaultColor\";\nexport const ANCHOR_SEGMENT_JSON_KEY = \"anchorSegment\";\nexport const SKELETON_RENDERING_SHADER_CONTROL_TOOL_ID =\n \"skeletonShaderControl\";\n","/**\n * @license\n * Copyright 2021 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport \"#src/widget/layer_control.css\";\n\nimport type { DisplayContext } from \"#src/display_context.js\";\nimport type { UserLayer, UserLayerConstructor } from \"#src/layer/index.js\";\nimport type { WatchableValueInterface } from \"#src/trackable_value.js\";\nimport type { ToolActivation } from \"#src/ui/tool.js\";\nimport {\n LayerTool,\n makeToolActivationStatusMessageWithHeader,\n registerTool,\n ToolBindingWidget,\n} from \"#src/ui/tool.js\";\nimport type { RefCounted } from \"#src/util/disposable.js\";\nimport { WatchableVisibilityPriority } from \"#src/visibility_priority/frontend.js\";\nimport { DependentViewWidget } from \"#src/widget/dependent_view_widget.js\";\n\nexport interface LayerControlLabelOptions<\n LayerType extends UserLayer = UserLayer,\n> {\n label: string;\n title?: string;\n toolDescription?: string;\n toolJson: any;\n isValid?: (layer: LayerType) => WatchableValueInterface;\n}\n\nexport interface LayerControlFactory<\n LayerType extends UserLayer,\n ControlType = unknown,\n> {\n makeControl: (\n layer: LayerType,\n context: RefCounted,\n options: {\n labelContainer: HTMLElement;\n labelTextContainer: HTMLElement;\n display: DisplayContext;\n visibility: WatchableVisibilityPriority;\n },\n ) => {\n control: ControlType;\n controlElement: HTMLElement;\n };\n activateTool: (\n activation: ToolActivation>,\n control: ControlType,\n ) => void;\n}\n\nexport interface LayerControlDefinition<\n LayerType extends UserLayer,\n ControlType = unknown,\n> extends LayerControlLabelOptions,\n LayerControlFactory {}\n\nfunction makeControl(\n context: RefCounted,\n layer: LayerType,\n options: LayerControlDefinition,\n visibility: WatchableVisibilityPriority,\n) {\n const controlContainer = document.createElement(\"label\");\n controlContainer.classList.add(\"neuroglancer-layer-control-container\");\n const labelContainer = document.createElement(\"div\");\n labelContainer.classList.add(\"neuroglancer-layer-control-label-container\");\n const label = document.createElement(\"div\");\n label.classList.add(\"neuroglancer-layer-control-label\");\n labelContainer.appendChild(label);\n const labelTextContainer = document.createElement(\"div\");\n labelTextContainer.classList.add(\n \"neuroglancer-layer-control-label-text-container\",\n );\n labelTextContainer.appendChild(document.createTextNode(options.label));\n label.appendChild(labelTextContainer);\n if (options.title) {\n label.title = options.title;\n }\n controlContainer.appendChild(labelContainer);\n\n const { control, controlElement } = options.makeControl(layer, context, {\n labelContainer,\n labelTextContainer,\n display: layer.manager.root.display,\n visibility,\n });\n controlElement.classList.add(\"neuroglancer-layer-control-control\");\n controlContainer.appendChild(controlElement);\n return {\n controlContainer,\n label,\n labelContainer,\n labelTextContainer,\n control,\n };\n}\n\nexport class LayerControlTool<\n LayerType extends UserLayer = UserLayer,\n> extends LayerTool {\n constructor(\n layer: LayerType,\n public options: LayerControlDefinition,\n ) {\n super(layer);\n }\n activate(activation: ToolActivation) {\n const { options } = this;\n const { layer } = this;\n const { isValid } = options;\n if (isValid !== undefined && !isValid(layer).value) return;\n const { header, body } =\n makeToolActivationStatusMessageWithHeader(activation);\n const { controlContainer, control, labelContainer } = makeControl(\n activation,\n layer,\n options,\n new WatchableVisibilityPriority(WatchableVisibilityPriority.VISIBLE),\n );\n header.appendChild(labelContainer);\n body.appendChild(controlContainer);\n options.activateTool(activation, control);\n }\n get description() {\n const { options } = this;\n return options.toolDescription ?? options.label;\n }\n toJSON() {\n return this.options.toolJson;\n }\n}\n\nfunction makeLayerControlToOptionsTab(\n context: RefCounted,\n layer: LayerType,\n options: LayerControlDefinition,\n visibility: WatchableVisibilityPriority,\n): HTMLElement {\n const { controlContainer, label } = makeControl(\n context,\n layer,\n options,\n visibility,\n );\n controlContainer.classList.add(\n \"neuroglancer-layer-options-control-container\",\n );\n label.prepend(\n context.registerDisposer(\n new ToolBindingWidget(layer.toolBinder, options.toolJson),\n ).element,\n );\n return controlContainer;\n}\n\nexport function addLayerControlToOptionsTab(\n context: RefCounted,\n layer: LayerType,\n visibility: WatchableVisibilityPriority,\n options: LayerControlDefinition,\n): HTMLElement {\n const { isValid } = options;\n if (isValid === undefined) {\n return makeLayerControlToOptionsTab(context, layer, options, visibility);\n }\n return context.registerDisposer(\n new DependentViewWidget(\n isValid(layer),\n (valid, parent, context) => {\n if (!valid) return;\n parent.appendChild(\n makeLayerControlToOptionsTab(context, layer, options, visibility),\n );\n },\n visibility,\n ),\n ).element;\n}\n\nexport function registerLayerControl(\n layerType: UserLayerConstructor,\n options: LayerControlDefinition,\n) {\n const { toolJson } = options;\n const toolId = typeof toolJson === \"string\" ? toolJson : toolJson.type;\n registerTool(\n layerType,\n toolId,\n (layer) => new LayerControlTool(layer, options),\n );\n}\n","/**\n * @license\n * Copyright 2021 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { UserLayer } from \"#src/layer/index.js\";\nimport { TrackableBooleanCheckbox } from \"#src/trackable_boolean.js\";\nimport type { WatchableValueInterface } from \"#src/trackable_value.js\";\nimport type { LayerControlFactory } from \"#src/widget/layer_control.js\";\n\nexport function checkboxLayerControl(\n getter: (layer: LayerType) => WatchableValueInterface,\n): LayerControlFactory {\n return {\n makeControl: (layer, context) => {\n const value = getter(layer);\n const control = context.registerDisposer(\n new TrackableBooleanCheckbox(value),\n );\n return { control, controlElement: control.element };\n },\n activateTool: (_activation, control) => {\n control.model.value = !control.model.value;\n },\n };\n}\n","/**\n * @license\n * Copyright 2021 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { UserLayer } from \"#src/layer/index.js\";\nimport type { ActionEvent } from \"#src/util/event_action_map.js\";\nimport { EventActionMap } from \"#src/util/event_action_map.js\";\nimport type { TrackableEnum } from \"#src/util/trackable_enum.js\";\nimport { EnumSelectWidget } from \"#src/widget/enum_widget.js\";\nimport type { LayerControlFactory } from \"#src/widget/layer_control.js\";\n\nconst TOOL_INPUT_EVENT_MAP = EventActionMap.fromObject({\n \"at:shift+wheel\": { action: \"adjust-via-wheel\" },\n});\n\nexport function enumLayerControl(\n getter: (layer: LayerType) => TrackableEnum,\n): LayerControlFactory> {\n return {\n makeControl: (layer, context) => {\n const value = getter(layer);\n const control = context.registerDisposer(new EnumSelectWidget(value));\n return { control, controlElement: control.element };\n },\n activateTool: (activation, control) => {\n activation.bindInputEventMap(TOOL_INPUT_EVENT_MAP);\n activation.bindAction(\n \"adjust-via-wheel\",\n (event: ActionEvent) => {\n event.stopPropagation();\n event.preventDefault();\n control.adjustViaWheel(event.detail);\n },\n );\n },\n };\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport \"#src/widget/range.css\";\n\nimport type { WatchableValueInterface } from \"#src/trackable_value.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport { removeFromParent } from \"#src/util/dom.js\";\n\nexport interface RangeWidgetOptions {\n min?: number;\n max?: number;\n step?: number;\n}\n\nexport class RangeWidget extends RefCounted {\n element = document.createElement(\"label\");\n inputElement = document.createElement(\"input\");\n numericInputElement = document.createElement(\"input\");\n\n constructor(\n public value: WatchableValueInterface,\n { min = 0, max = 1, step = 0.01 }: RangeWidgetOptions = {},\n ) {\n super();\n const { element, inputElement, numericInputElement } = this;\n element.className = \"range-slider\";\n const initInputElement = (el: HTMLInputElement) => {\n el.min = \"\" + min;\n el.max = \"\" + max;\n el.step = \"\" + step;\n el.valueAsNumber = this.value.value;\n this.registerEventListener(el, \"change\", () =>\n this.inputValueChanged(el),\n );\n this.registerEventListener(el, \"input\", () => this.inputValueChanged(el));\n this.registerEventListener(el, \"wheel\", (event: WheelEvent) => {\n this.adjustViaWheel(el, event);\n });\n };\n inputElement.type = \"range\";\n initInputElement(inputElement);\n numericInputElement.type = \"number\";\n const maxNumberWidth = Math.max(\n min.toString().length,\n max.toString().length,\n Math.min(max, min + step).toString().length,\n Math.max(min, max - step).toString().length,\n );\n numericInputElement.style.width = maxNumberWidth + 2 + \"ch\";\n initInputElement(numericInputElement);\n element.appendChild(inputElement);\n element.appendChild(numericInputElement);\n value.changed.add(() => {\n this.inputElement.valueAsNumber = this.value.value;\n this.numericInputElement.valueAsNumber = this.value.value;\n });\n }\n\n private inputValueChanged(element: HTMLInputElement) {\n this.value.value = element.valueAsNumber;\n }\n\n adjustViaWheel(element: HTMLInputElement, event: WheelEvent) {\n const el = this.inputElement;\n const { deltaY } = event;\n if (deltaY > 0) {\n el.stepUp();\n this.inputValueChanged(element);\n } else if (deltaY < 0) {\n el.stepDown();\n this.inputValueChanged(element);\n }\n }\n\n disposed() {\n removeFromParent(this.element);\n super.disposed();\n }\n}\n","/**\n * @license\n * Copyright 2021 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { UserLayer } from \"#src/layer/index.js\";\nimport type { WatchableValueInterface } from \"#src/trackable_value.js\";\nimport type { ActionEvent } from \"#src/util/event_action_map.js\";\nimport { EventActionMap } from \"#src/util/event_action_map.js\";\nimport type { LayerControlFactory } from \"#src/widget/layer_control.js\";\nimport type { RangeWidgetOptions } from \"#src/widget/range.js\";\nimport { RangeWidget } from \"#src/widget/range.js\";\n\nconst TOOL_INPUT_EVENT_MAP = EventActionMap.fromObject({\n \"at:shift+wheel\": { action: \"adjust-via-wheel\" },\n});\n\nexport function rangeLayerControl(\n getter: (layer: LayerType) => {\n value: WatchableValueInterface;\n options?: RangeWidgetOptions;\n },\n): LayerControlFactory {\n return {\n makeControl: (layer, context) => {\n const { value, options } = getter(layer);\n const control = context.registerDisposer(new RangeWidget(value, options));\n return { control, controlElement: control.element };\n },\n activateTool: (activation, control) => {\n activation.bindInputEventMap(TOOL_INPUT_EVENT_MAP);\n activation.bindAction(\n \"adjust-via-wheel\",\n (event: ActionEvent) => {\n event.stopPropagation();\n event.preventDefault();\n control.adjustViaWheel(control.inputElement, event.detail);\n },\n );\n },\n };\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function numberToStringFixed(v: number, maxDigits: number) {\n let s = \"\";\n for (let digits = 0; digits <= maxDigits; ++digits) {\n s = v.toFixed(digits);\n if (parseFloat(s) === v) {\n break;\n }\n }\n return s;\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport \"#src/widget/render_scale_widget.css\";\n\nimport { debounce, throttle } from \"lodash-es\";\nimport type { UserLayer } from \"#src/layer/index.js\";\nimport type { RenderScaleHistogram } from \"#src/render_scale_statistics.js\";\nimport {\n getRenderScaleFromHistogramOffset,\n getRenderScaleHistogramOffset,\n numRenderScaleHistogramBins,\n renderScaleHistogramBinSize,\n renderScaleHistogramOrigin,\n} from \"#src/render_scale_statistics.js\";\nimport type { TrackableValueInterface } from \"#src/trackable_value.js\";\nimport { WatchableValue } from \"#src/trackable_value.js\";\nimport { serializeColor } from \"#src/util/color.js\";\nimport { hsvToRgb } from \"#src/util/colorspace.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport type { ActionEvent } from \"#src/util/event_action_map.js\";\nimport {\n EventActionMap,\n registerActionListener,\n} from \"#src/util/event_action_map.js\";\nimport { vec3 } from \"#src/util/geom.js\";\nimport { clampToInterval } from \"#src/util/lerp.js\";\nimport { MouseEventBinder } from \"#src/util/mouse_bindings.js\";\nimport { numberToStringFixed } from \"#src/util/number_to_string.js\";\nimport { formatScaleWithUnitAsString } from \"#src/util/si_units.js\";\nimport type { LayerControlFactory } from \"#src/widget/layer_control.js\";\n\nconst updateInterval = 200;\n\nconst inputEventMap = EventActionMap.fromObject({\n mousedown0: { action: \"set\" },\n wheel: { action: \"adjust-via-wheel\" },\n dblclick0: { action: \"reset\" },\n});\n\nfunction formatPixelNumber(x: number) {\n if (x < 1 || x > 1024) {\n const exponent = Math.log2(x) | 0;\n const coeff = x / 2 ** exponent;\n return `${numberToStringFixed(coeff, 1)}p${exponent}`;\n }\n return Math.round(x) + \"\";\n}\n\nexport interface RenderScaleWidgetOptions {\n histogram: RenderScaleHistogram;\n target: TrackableValueInterface;\n}\n\nexport class RenderScaleWidget extends RefCounted {\n label = document.createElement(\"div\");\n element = document.createElement(\"div\");\n canvas = document.createElement(\"canvas\");\n legend = document.createElement(\"div\");\n legendRenderScale = document.createElement(\"div\");\n legendSpatialScale = document.createElement(\"div\");\n legendChunks = document.createElement(\"div\");\n protected logScaleOrigin = renderScaleHistogramOrigin;\n protected unitOfTarget = \"px\";\n private ctx = this.canvas.getContext(\"2d\")!;\n hoverTarget = new WatchableValue<[number, number] | undefined>(undefined);\n private throttledUpdateView = this.registerCancellable(\n throttle(() => this.debouncedUpdateView(), updateInterval, {\n leading: true,\n trailing: true,\n }),\n );\n private debouncedUpdateView = this.registerCancellable(\n debounce(() => this.updateView(), 0),\n );\n\n adjustViaWheel(event: WheelEvent) {\n const deltaY = this.getWheelMoveValue(event);\n if (deltaY === 0) {\n return;\n }\n this.hoverTarget.value = undefined;\n const logScaleMax = Math.round(\n this.logScaleOrigin +\n numRenderScaleHistogramBins * renderScaleHistogramBinSize,\n );\n const targetValue = clampToInterval(\n [2 ** this.logScaleOrigin, 2 ** (logScaleMax - 1)],\n this.target.value * 2 ** Math.sign(deltaY),\n ) as number;\n this.target.value = targetValue;\n event.preventDefault();\n }\n\n constructor(\n public histogram: RenderScaleHistogram,\n public target: TrackableValueInterface,\n ) {\n super();\n const {\n canvas,\n label,\n element,\n legend,\n legendRenderScale,\n legendSpatialScale,\n legendChunks,\n } = this;\n label.className = \"neuroglancer-render-scale-widget-prompt\";\n element.className = \"neuroglancer-render-scale-widget\";\n element.title = inputEventMap.describe();\n legend.className = \"neuroglancer-render-scale-widget-legend\";\n element.appendChild(label);\n element.appendChild(canvas);\n element.appendChild(legend);\n legendRenderScale.title = \"Target resolution of data in screen pixels\";\n legendChunks.title = \"Number of chunks rendered\";\n legend.appendChild(legendRenderScale);\n legend.appendChild(legendChunks);\n legend.appendChild(legendSpatialScale);\n this.registerDisposer(histogram.changed.add(this.throttledUpdateView));\n this.registerDisposer(\n histogram.visibility.changed.add(this.debouncedUpdateView),\n );\n this.registerDisposer(target.changed.add(this.debouncedUpdateView));\n this.registerDisposer(new MouseEventBinder(canvas, inputEventMap));\n this.registerDisposer(target.changed.add(this.debouncedUpdateView));\n this.registerDisposer(\n this.hoverTarget.changed.add(this.debouncedUpdateView),\n );\n\n const getTargetValue = (event: MouseEvent) => {\n const position =\n (event.offsetX / canvas.width) * numRenderScaleHistogramBins;\n return getRenderScaleFromHistogramOffset(position, this.logScaleOrigin);\n };\n this.registerEventListener(canvas, \"pointermove\", (event: MouseEvent) => {\n this.hoverTarget.value = [getTargetValue(event), event.offsetY];\n });\n\n this.registerEventListener(canvas, \"pointerleave\", () => {\n this.hoverTarget.value = undefined;\n });\n\n this.registerDisposer(\n registerActionListener(canvas, \"set\", (actionEvent) => {\n this.target.value = getTargetValue(actionEvent.detail);\n }),\n );\n\n this.registerDisposer(\n registerActionListener(\n canvas,\n \"adjust-via-wheel\",\n (actionEvent) => {\n this.adjustViaWheel(actionEvent.detail);\n },\n ),\n );\n\n this.registerDisposer(\n registerActionListener(canvas, \"reset\", (event) => {\n this.reset();\n event.preventDefault();\n }),\n );\n const resizeObserver = new ResizeObserver(() => this.debouncedUpdateView());\n resizeObserver.observe(canvas);\n this.registerDisposer(() => resizeObserver.disconnect());\n this.updateView();\n }\n\n getWheelMoveValue(event: WheelEvent) {\n return event.deltaY;\n }\n\n reset() {\n this.hoverTarget.value = undefined;\n this.target.reset();\n }\n\n updateView() {\n const { ctx } = this;\n const { canvas } = this;\n const width = (canvas.width = canvas.offsetWidth);\n const height = (canvas.height = canvas.offsetHeight);\n const targetValue = this.target.value;\n const hoverValue = this.hoverTarget.value;\n\n {\n const { legendRenderScale } = this;\n const value = hoverValue === undefined ? targetValue : hoverValue[0];\n const valueString = formatPixelNumber(value);\n legendRenderScale.textContent = valueString + \" \" + this.unitOfTarget;\n }\n\n function binToCanvasX(bin: number) {\n return (bin * width) / numRenderScaleHistogramBins;\n }\n\n ctx.clearRect(0, 0, width, height);\n\n const { histogram } = this;\n // histogram.begin(this.frameNumberCounter.frameNumber);\n const { value: histogramData, spatialScales } = histogram;\n\n if (!histogram.visibility.visible) {\n histogramData.fill(0);\n }\n\n const sortedSpatialScales = Array.from(spatialScales.keys());\n sortedSpatialScales.sort();\n\n const tempColor = vec3.create();\n\n let maxCount = 1;\n const numRows = spatialScales.size;\n let totalPresent = 0;\n let totalNotPresent = 0;\n for (let bin = 0; bin < numRenderScaleHistogramBins; ++bin) {\n let count = 0;\n for (let row = 0; row < numRows; ++row) {\n const index = row * numRenderScaleHistogramBins * 2 + bin;\n const presentCount = histogramData[index];\n const notPresentCount =\n histogramData[index + numRenderScaleHistogramBins];\n totalPresent += presentCount;\n totalNotPresent += notPresentCount;\n count += presentCount + notPresentCount;\n }\n maxCount = Math.max(count, maxCount);\n }\n totalNotPresent -= histogram.fakeChunkCount;\n\n const maxBarHeight = height;\n\n const yScale = maxBarHeight / Math.log(1 + maxCount);\n\n function countToCanvasY(count: number) {\n return height - Math.log(1 + count) * yScale;\n }\n\n let hoverSpatialScale: number | undefined = undefined;\n if (hoverValue !== undefined) {\n const i = Math.floor(\n getRenderScaleHistogramOffset(hoverValue[0], this.logScaleOrigin),\n );\n if (i >= 0 && i < numRenderScaleHistogramBins) {\n let sum = 0;\n const hoverY = hoverValue[1];\n for (\n let spatialScaleIndex = numRows - 1;\n spatialScaleIndex >= 0;\n --spatialScaleIndex\n ) {\n const spatialScale = sortedSpatialScales[spatialScaleIndex];\n const row = spatialScales.get(spatialScale)!;\n const index = 2 * row * numRenderScaleHistogramBins + i;\n const count =\n histogramData[index] +\n histogramData[index + numRenderScaleHistogramBins];\n if (count === 0) continue;\n const yStart = Math.round(countToCanvasY(sum));\n sum += count;\n const yEnd = Math.round(countToCanvasY(sum));\n if (yEnd <= hoverY && hoverY <= yStart) {\n hoverSpatialScale = spatialScale;\n break;\n }\n }\n }\n }\n if (hoverSpatialScale !== undefined) {\n totalPresent = 0;\n totalNotPresent = 0;\n const row = spatialScales.get(hoverSpatialScale)!;\n const baseIndex = 2 * row * numRenderScaleHistogramBins;\n for (let bin = 0; bin < numRenderScaleHistogramBins; ++bin) {\n const index = baseIndex + bin;\n totalPresent += histogramData[index];\n totalNotPresent += histogramData[index + numRenderScaleHistogramBins];\n }\n if (Number.isFinite(hoverSpatialScale)) {\n this.legendSpatialScale.textContent = formatScaleWithUnitAsString(\n hoverSpatialScale,\n \"m\",\n { precision: 2, elide1: false },\n );\n } else {\n this.legendSpatialScale.textContent = \"unknown\";\n }\n } else {\n this.legendSpatialScale.textContent = \"\";\n }\n\n this.legendChunks.textContent = `${totalPresent}/${\n totalPresent + totalNotPresent\n }`;\n\n const spatialScaleColors = sortedSpatialScales.map((spatialScale) => {\n const saturation = spatialScale === hoverSpatialScale ? 0.5 : 1;\n let hue;\n if (Number.isFinite(spatialScale)) {\n hue = (((Math.log2(spatialScale) * 0.1) % 1) + 1) % 1;\n } else {\n hue = 0;\n }\n hsvToRgb(tempColor, hue, saturation, 1);\n const presentColor = serializeColor(tempColor);\n hsvToRgb(tempColor, hue, saturation, 0.5);\n const notPresentColor = serializeColor(tempColor);\n return [presentColor, notPresentColor];\n });\n\n for (let i = 0; i < numRenderScaleHistogramBins; ++i) {\n let sum = 0;\n for (\n let spatialScaleIndex = numRows - 1;\n spatialScaleIndex >= 0;\n --spatialScaleIndex\n ) {\n const spatialScale = sortedSpatialScales[spatialScaleIndex];\n const row = spatialScales.get(spatialScale)!;\n const index = row * numRenderScaleHistogramBins * 2 + i;\n const presentCount = histogramData[index];\n const notPresentCount =\n histogramData[index + numRenderScaleHistogramBins];\n const count = presentCount + notPresentCount;\n if (count === 0) continue;\n const xStart = Math.round(binToCanvasX(i));\n const xEnd = Math.round(binToCanvasX(i + 1));\n const yStart = Math.round(countToCanvasY(sum));\n sum += count;\n const yEnd = Math.round(countToCanvasY(sum));\n const ySplit = (presentCount * yEnd + notPresentCount * yStart) / count;\n ctx.fillStyle = spatialScaleColors[spatialScaleIndex][1];\n ctx.fillRect(xStart, yEnd, xEnd - xStart, ySplit - yEnd);\n ctx.fillStyle = spatialScaleColors[spatialScaleIndex][0];\n ctx.fillRect(xStart, ySplit, xEnd - xStart, yStart - ySplit);\n }\n }\n\n {\n const value = targetValue;\n ctx.fillStyle = \"#fff\";\n const startOffset = binToCanvasX(\n getRenderScaleHistogramOffset(value, this.logScaleOrigin),\n );\n const lineWidth = 1;\n ctx.fillRect(Math.floor(startOffset), 0, lineWidth, height);\n }\n\n if (hoverValue !== undefined) {\n const value = hoverValue[0];\n ctx.fillStyle = \"#888\";\n const startOffset = binToCanvasX(\n getRenderScaleHistogramOffset(value, this.logScaleOrigin),\n );\n const lineWidth = 1;\n ctx.fillRect(Math.floor(startOffset), 0, lineWidth, height);\n }\n }\n}\n\nexport class VolumeRenderingRenderScaleWidget extends RenderScaleWidget {\n protected unitOfTarget = \"samples\";\n protected logScaleOrigin = 1;\n\n getWheelMoveValue(event: WheelEvent) {\n return -event.deltaY;\n }\n}\n\nconst TOOL_INPUT_EVENT_MAP = EventActionMap.fromObject({\n \"at:shift+wheel\": { action: \"adjust-via-wheel\" },\n \"at:shift+dblclick0\": { action: \"reset\" },\n});\n\nexport function renderScaleLayerControl<\n LayerType extends UserLayer,\n WidgetType extends RenderScaleWidget,\n>(\n getter: (layer: LayerType) => RenderScaleWidgetOptions,\n widgetClass: new (\n histogram: RenderScaleHistogram,\n target: TrackableValueInterface,\n ) => WidgetType = RenderScaleWidget as new (\n histogram: RenderScaleHistogram,\n target: TrackableValueInterface,\n ) => WidgetType,\n): LayerControlFactory {\n return {\n makeControl: (layer, context) => {\n const { histogram, target } = getter(layer);\n const control = context.registerDisposer(\n new widgetClass(histogram, target),\n );\n return { control, controlElement: control.element };\n },\n activateTool: (activation, control) => {\n activation.bindInputEventMap(TOOL_INPUT_EVENT_MAP);\n activation.bindAction(\n \"adjust-via-wheel\",\n (event: ActionEvent) => {\n event.stopPropagation();\n event.preventDefault();\n control.adjustViaWheel(event.detail);\n },\n );\n activation.bindAction(\"reset\", (event: ActionEvent) => {\n event.stopPropagation();\n event.preventDefault();\n control.reset();\n });\n },\n };\n}\n","/**\n * @license\n * Copyright 2021 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { UserLayer } from \"#src/layer/index.js\";\nimport type { WatchableValueInterface } from \"#src/trackable_value.js\";\nimport type { ActionEvent } from \"#src/util/event_action_map.js\";\nimport { EventActionMap } from \"#src/util/event_action_map.js\";\nimport type { vec3 } from \"#src/util/geom.js\";\nimport { ColorWidget } from \"#src/widget/color.js\";\nimport type { LayerControlFactory } from \"#src/widget/layer_control.js\";\n\nconst TOOL_INPUT_EVENT_MAP = EventActionMap.fromObject({\n \"at:shift+wheel\": { action: \"adjust-hue-via-wheel\" },\n});\n\nexport function colorLayerControl<\n LayerType extends UserLayer,\n Color extends vec3 | undefined,\n>(\n getter: (layer: LayerType) => WatchableValueInterface,\n): LayerControlFactory> {\n return {\n makeControl: (layer, context) => {\n const value = getter(layer);\n const control = context.registerDisposer(new ColorWidget(value));\n return { control, controlElement: control.element };\n },\n activateTool: (activation, control) => {\n activation.bindInputEventMap(TOOL_INPUT_EVENT_MAP);\n activation.bindAction(\n \"adjust-via-wheel\",\n (event: ActionEvent) => {\n event.stopPropagation();\n event.preventDefault();\n control.adjustHueViaWheel(event.detail);\n },\n );\n },\n };\n}\n","/**\n * @license\n * Copyright 2020 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { TrackableValueInterface } from \"#src/trackable_value.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport { removeFromParent } from \"#src/util/dom.js\";\n\nexport class TextInputWidget extends RefCounted {\n element = document.createElement(\"input\");\n constructor(public model: TrackableValueInterface) {\n super();\n this.registerDisposer(model.changed.add(() => this.updateView()));\n const { element } = this;\n element.type = \"text\";\n this.registerEventListener(element, \"change\", () => this.updateModel());\n this.updateView();\n }\n\n disposed() {\n removeFromParent(this.element);\n }\n\n private updateView() {\n this.element.value = (this.model.value ?? \"\") + \"\";\n }\n\n private updateModel() {\n try {\n this.model.restoreState(this.element.value);\n } catch {\n // Ignore invalid input.\n }\n this.updateView();\n }\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport \"#src/widget/segmentation_color_mode.css\";\n\nimport svg_rotate from \"ikonate/icons/rotate.svg?raw\";\nimport type { SegmentationUserLayer } from \"#src/layer/segmentation/index.js\";\nimport { observeWatchable } from \"#src/trackable_value.js\";\nimport { vec3 } from \"#src/util/geom.js\";\nimport type { ColorWidget } from \"#src/widget/color.js\";\nimport { makeIcon } from \"#src/widget/icon.js\";\nimport type { LayerControlFactory } from \"#src/widget/layer_control.js\";\nimport { colorLayerControl } from \"#src/widget/layer_control_color.js\";\nimport { TextInputWidget } from \"#src/widget/text_input.js\";\n\nfunction chooseColorMode(layer: SegmentationUserLayer, useFixedColor: boolean) {\n if (!useFixedColor) {\n layer.displayState.segmentDefaultColor.value = undefined;\n } else {\n layer.displayState.segmentDefaultColor.value = vec3.fromValues(1, 0, 0);\n }\n}\n\nexport function colorSeedLayerControl(): LayerControlFactory {\n const randomize = (layer: SegmentationUserLayer) => {\n layer.displayState.segmentationColorGroupState.value.segmentColorHash.randomize();\n };\n return {\n makeControl: (layer, context, { labelTextContainer }) => {\n const checkbox = document.createElement(\"input\");\n checkbox.type = \"radio\";\n checkbox.addEventListener(\"change\", () => {\n chooseColorMode(layer, !checkbox.checked);\n });\n labelTextContainer.prepend(checkbox);\n const controlElement = document.createElement(\"div\");\n controlElement.classList.add(\n \"neuroglancer-segmentation-color-seed-control\",\n );\n const widget = context.registerDisposer(\n new TextInputWidget(layer.displayState.segmentColorHash),\n );\n controlElement.appendChild(widget.element);\n const randomizeButton = makeIcon({\n svg: svg_rotate,\n title: \"Randomize\",\n onClick: () => randomize(layer),\n });\n controlElement.appendChild(randomizeButton);\n context.registerDisposer(\n observeWatchable((value) => {\n const isVisible = value === undefined;\n controlElement.style.visibility = isVisible ? \"\" : \"hidden\";\n checkbox.checked = isVisible;\n }, layer.displayState.segmentDefaultColor),\n );\n return { controlElement, control: widget };\n },\n activateTool: (activation) => {\n const { layer } = activation.tool;\n chooseColorMode(layer, false);\n randomize(layer);\n },\n };\n}\n\nexport function fixedColorLayerControl(): LayerControlFactory<\n SegmentationUserLayer,\n ColorWidget\n> {\n const options = colorLayerControl(\n (layer: SegmentationUserLayer) => layer.displayState.segmentDefaultColor,\n );\n return {\n ...options,\n makeControl: (layer, context, labelElements) => {\n const result = options.makeControl(layer, context, labelElements);\n const { controlElement } = result;\n const checkbox = document.createElement(\"input\");\n checkbox.type = \"radio\";\n checkbox.addEventListener(\"change\", () => {\n chooseColorMode(layer, checkbox.checked);\n if (checkbox.checked) {\n controlElement.click();\n }\n });\n labelElements.labelTextContainer.prepend(checkbox);\n context.registerDisposer(\n observeWatchable((value) => {\n const isVisible = value !== undefined;\n controlElement.style.visibility = isVisible ? \"\" : \"hidden\";\n checkbox.checked = isVisible;\n }, layer.displayState.segmentDefaultColor),\n );\n return result;\n },\n activateTool: (activation, control) => {\n chooseColorMode(activation.tool.layer, true);\n options.activateTool(activation, control);\n },\n };\n}\n","import type { SegmentationUserLayer } from \"#src/layer/segmentation/index.js\";\nimport * as json_keys from \"#src/layer/segmentation/json_keys.js\";\nimport type { LayerControlDefinition } from \"#src/widget/layer_control.js\";\nimport { registerLayerControl } from \"#src/widget/layer_control.js\";\nimport { checkboxLayerControl } from \"#src/widget/layer_control_checkbox.js\";\nimport { enumLayerControl } from \"#src/widget/layer_control_enum.js\";\nimport { rangeLayerControl } from \"#src/widget/layer_control_range.js\";\nimport { renderScaleLayerControl } from \"#src/widget/render_scale_widget.js\";\nimport {\n colorSeedLayerControl,\n fixedColorLayerControl,\n} from \"#src/widget/segmentation_color_mode.js\";\n\nexport const LAYER_CONTROLS: LayerControlDefinition[] = [\n {\n label: \"Color seed\",\n title: \"Color segments based on a hash of their id\",\n toolJson: json_keys.COLOR_SEED_JSON_KEY,\n ...colorSeedLayerControl(),\n },\n {\n label: \"Fixed color\",\n title:\n \"Use a fixed color for all segments without an explicitly-specified color\",\n toolJson: json_keys.SEGMENT_DEFAULT_COLOR_JSON_KEY,\n ...fixedColorLayerControl(),\n },\n {\n label: \"Saturation\",\n toolJson: json_keys.SATURATION_JSON_KEY,\n title: \"Saturation of segment colors\",\n ...rangeLayerControl((layer) => ({ value: layer.displayState.saturation })),\n },\n {\n label: \"Opacity (on)\",\n toolJson: json_keys.SELECTED_ALPHA_JSON_KEY,\n isValid: (layer) => layer.has2dLayer,\n title: \"Opacity in cross-section views of segments that are selected\",\n ...rangeLayerControl((layer) => ({\n value: layer.displayState.selectedAlpha,\n })),\n },\n {\n label: \"Opacity (off)\",\n toolJson: json_keys.NOT_SELECTED_ALPHA_JSON_KEY,\n isValid: (layer) => layer.has2dLayer,\n title: \"Opacity in cross-section views of segments that are not selected\",\n ...rangeLayerControl((layer) => ({\n value: layer.displayState.notSelectedAlpha,\n })),\n },\n {\n label: \"Resolution (slice)\",\n toolJson: json_keys.CROSS_SECTION_RENDER_SCALE_JSON_KEY,\n isValid: (layer) => layer.has2dLayer,\n ...renderScaleLayerControl((layer) => ({\n histogram: layer.sliceViewRenderScaleHistogram,\n target: layer.sliceViewRenderScaleTarget,\n })),\n },\n {\n label: \"Resolution (mesh)\",\n toolJson: json_keys.MESH_RENDER_SCALE_JSON_KEY,\n isValid: (layer) => layer.has3dLayer,\n ...renderScaleLayerControl((layer) => ({\n histogram: layer.displayState.renderScaleHistogram,\n target: layer.displayState.renderScaleTarget,\n })),\n },\n {\n label: \"Opacity (3d)\",\n toolJson: json_keys.OBJECT_ALPHA_JSON_KEY,\n isValid: (layer) => layer.has3dLayer,\n title: \"Opacity of meshes and skeletons\",\n ...rangeLayerControl((layer) => ({\n value: layer.displayState.objectAlpha,\n })),\n },\n {\n label: \"Silhouette (3d)\",\n toolJson: json_keys.MESH_SILHOUETTE_RENDERING_JSON_KEY,\n isValid: (layer) => layer.has3dLayer,\n title:\n \"Set to a non-zero value to increase transparency of object faces perpendicular to view direction\",\n ...rangeLayerControl((layer) => ({\n value: layer.displayState.silhouetteRendering,\n options: { min: 0, max: maxSilhouettePower, step: 0.1 },\n })),\n },\n {\n label: \"Hide segment ID 0\",\n toolJson: json_keys.HIDE_SEGMENT_ZERO_JSON_KEY,\n title: \"Disallow selection and display of segment id 0\",\n ...checkboxLayerControl((layer) => layer.displayState.hideSegmentZero),\n },\n {\n label: \"Base segment coloring\",\n toolJson: json_keys.BASE_SEGMENT_COLORING_JSON_KEY,\n title: \"Color base segments individually\",\n ...checkboxLayerControl((layer) => layer.displayState.baseSegmentColoring),\n },\n {\n label: \"Show all by default\",\n title: \"Show all segments if none are selected\",\n toolJson: json_keys.IGNORE_NULL_VISIBLE_SET_JSON_KEY,\n ...checkboxLayerControl((layer) => layer.displayState.ignoreNullVisibleSet),\n },\n {\n label: \"Highlight on hover\",\n toolJson: json_keys.HOVER_HIGHLIGHT_JSON_KEY,\n title: \"Highlight the segment under the mouse pointer\",\n ...checkboxLayerControl((layer) => layer.displayState.hoverHighlight),\n },\n ...getViewSpecificSkeletonRenderingControl(\"2d\"),\n ...getViewSpecificSkeletonRenderingControl(\"3d\"),\n];\n\nconst maxSilhouettePower = 10;\n\nfunction getViewSpecificSkeletonRenderingControl(\n viewName: \"2d\" | \"3d\",\n): LayerControlDefinition[] {\n return [\n {\n label: `Skeleton mode (${viewName})`,\n toolJson: `${json_keys.SKELETON_RENDERING_JSON_KEY}.mode${viewName}`,\n isValid: (layer) => layer.hasSkeletonsLayer,\n ...enumLayerControl(\n (layer) =>\n layer.displayState.skeletonRenderingOptions[\n `params${viewName}` as const\n ].mode,\n ),\n },\n {\n label: `Line width (${viewName})`,\n toolJson: `${json_keys.SKELETON_RENDERING_JSON_KEY}.lineWidth${viewName}`,\n isValid: (layer) => layer.hasSkeletonsLayer,\n toolDescription: `Skeleton line width (${viewName})`,\n title: `Skeleton line width (${viewName})`,\n ...rangeLayerControl((layer) => ({\n value:\n layer.displayState.skeletonRenderingOptions[\n `params${viewName}` as const\n ].lineWidth,\n options: { min: 1, max: 40, step: 1 },\n })),\n },\n ];\n}\n\nexport function registerLayerControls(layerType: typeof SegmentationUserLayer) {\n for (const control of LAYER_CONTROLS) {\n registerLayerControl(layerType, control);\n }\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { TypedArray } from \"#src/util/array.js\";\nimport type { Uint64 } from \"#src/util/uint64.js\";\n\nexport function getOctreeChildIndex(x: number, y: number, z: number) {\n return (x & 1) | ((y << 1) & 2) | ((z << 2) & 4);\n}\n\n/**\n * Decodes a \"compressed\" 3-d morton index.\n *\n * Decoded bit `i` of `x`, `y`, and `z` is at bit `i + min(i, yBits) + min(i, zBits)`, `i + min(i +\n * 1, xBits) + min(i, zBits)`, and `i + min(i + 1, xBits) + min(i + 1, zBits)` of `zindex`,\n * respectively, for `i` in `[0, xBits)`, `[0, yBits)`, `[0, zBits)`, respectively.\n */\nexport function decodeZIndexCompressed(\n zindex: Uint64,\n xBits: number,\n yBits: number,\n zBits: number,\n): Uint32Array {\n const maxCoordBits = Math.max(xBits, yBits, zBits);\n let inputBit = 0;\n let inputValue = zindex.low;\n let x = 0;\n let y = 0;\n let z = 0;\n for (let coordBit = 0; coordBit < maxCoordBits; ++coordBit) {\n if (coordBit < xBits) {\n const bit = (inputValue >>> inputBit) & 1;\n x |= bit << coordBit;\n if (inputBit === 31) {\n inputBit = 0;\n inputValue = zindex.high;\n } else {\n ++inputBit;\n }\n }\n if (coordBit < yBits) {\n const bit = (inputValue >>> inputBit) & 1;\n y |= bit << coordBit;\n if (inputBit === 31) {\n inputBit = 0;\n inputValue = zindex.high;\n } else {\n ++inputBit;\n }\n }\n if (coordBit < zBits) {\n const bit = (inputValue >>> inputBit) & 1;\n z |= bit << coordBit;\n if (inputBit === 31) {\n inputBit = 0;\n inputValue = zindex.high;\n } else {\n ++inputBit;\n }\n }\n }\n return Uint32Array.of(x, y, z);\n}\n\nexport function encodeZIndexCompressed3d(\n zindex: Uint64,\n xBits: number,\n yBits: number,\n zBits: number,\n x: number,\n y: number,\n z: number,\n): Uint64 {\n const maxBits = Math.max(xBits, yBits, zBits);\n let outputBit = 0;\n let outputNum = 0;\n let isHigh = false;\n function writeBit(b: number): void {\n outputNum |= (b & 1) << outputBit;\n if (++outputBit === 32) {\n zindex.low = outputNum >>> 0;\n outputNum = 0;\n outputBit = 0;\n isHigh = true;\n }\n }\n for (let bit = 0; bit < maxBits; ++bit) {\n if (bit < xBits) {\n writeBit((x >> bit) & 1);\n }\n if (bit < yBits) {\n writeBit((y >> bit) & 1);\n }\n if (bit < zBits) {\n writeBit((z >> bit) & 1);\n }\n }\n if (isHigh) {\n zindex.high = outputNum >>> 0;\n } else {\n zindex.high = 0;\n zindex.low = outputNum >>> 0;\n }\n return zindex;\n}\n\nexport function encodeZIndexCompressed(\n zindex: Uint64,\n position: TypedArray,\n shape: TypedArray,\n): Uint64 {\n let outputBit = 0;\n const rank = position.length;\n let outputNum = 0;\n let isHigh = false;\n function writeBit(b: number): void {\n outputNum |= (b & 1) << outputBit;\n if (++outputBit === 32) {\n zindex.low = outputNum >>> 0;\n outputNum = 0;\n outputBit = 0;\n isHigh = true;\n }\n }\n\n for (let bit = 0; bit < 32; ++bit) {\n for (let dim = 0; dim < rank; ++dim) {\n if ((shape[dim] - 1) >>> bit) {\n writeBit(position[dim] >>> bit);\n }\n }\n }\n if (isHigh) {\n zindex.high = outputNum >>> 0;\n } else {\n zindex.high = 0;\n zindex.low = outputNum >>> 0;\n }\n return zindex;\n}\n\nfunction lessMsb(a: number, b: number) {\n return a < b && a < (a ^ b);\n}\n\n/**\n * Returns `true` if `(x0, y0, z0)` occurs before `(x1, y1, z1)` in Z-curve order.\n */\nexport function zorder3LessThan(\n x0: number,\n y0: number,\n z0: number,\n x1: number,\n y1: number,\n z1: number,\n): boolean {\n let mostSignificant0 = z0;\n let mostSignificant1 = z1;\n\n if (lessMsb(mostSignificant0 ^ mostSignificant1, y0 ^ y1)) {\n mostSignificant0 = y0;\n mostSignificant1 = y1;\n }\n\n if (lessMsb(mostSignificant0 ^ mostSignificant1, x0 ^ x1)) {\n mostSignificant0 = x0;\n mostSignificant1 = x1;\n }\n\n return mostSignificant0 < mostSignificant1;\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { mat4, vec3 } from \"#src/util/geom.js\";\nimport { isAABBVisible } from \"#src/util/geom.js\";\nimport { getOctreeChildIndex } from \"#src/util/zorder.js\";\n\nconst DEBUG_CHUNKS_TO_DRAW = false;\n\nexport interface MultiscaleMeshManifest {\n /**\n * Size of finest-resolution (base) chunk in object coordinates.\n */\n chunkShape: vec3;\n\n /**\n * Starting corner position of (0, 0, 0) chunk in object coordinates.\n */\n chunkGridSpatialOrigin: vec3;\n\n /**\n * Axis-aligned bounding box lower bound of object in object coordinates to use for clipping and\n * level-of-detail calculations.\n */\n clipLowerBound: vec3;\n\n /**\n * Axis-aligned bounding box upper bound of object in object coordinates to use for clipping and\n * level-of-detail calculations.\n */\n clipUpperBound: vec3;\n\n /**\n * Specifies the number of levels of detail (as `lodScales.length`), and the resolution in object\n * coordinates for each level of detail. If `lodScales[lod] === 0`, then level-of-detail `lod`\n * does not exist.\n *\n * Level of detail `0` is the finest resolution.\n *\n * The non-zero values must be non-decreasing.\n *\n * For each chunk, the chosen `lod` is the largest value such that\n * `lodScales[lod] <= detailCutoff * pixelSize`, where `pixelSize` is the maximum spatial distance\n * spanned by a single viewport pixel within the projected image of the chunk.\n */\n lodScales: Float32Array;\n\n /**\n * C order `[numLods, 3]` array specifying the xyz vertex position offset in object coordinates\n * for each level of detail.\n */\n vertexOffsets: Float32Array;\n\n /**\n * Row-major `[n, 5]` array where each row is of the form `[x, y, z, start, end_and_empty]`, where\n * `x`, `y`, and `z` are the chunk grid coordinates of the entry at a particular level of detail.\n * Row `n-1` corresponds to level of detail `lodScales.length - 1`, the root of the octree. Given\n * a row corresponding to an octree node at level of detail `lod`, bits `start` specifies the row\n * number of the first child octree node at level of detail `lod-1`, and bits `[0,30]` of\n * `end_and_empty` specify one past the row number of the last child octree node. Bit `31` of\n * `end_and_empty` is set to `1` if the mesh for the octree node is empty and should not be\n * requested/rendered.\n */\n octree: Uint32Array;\n}\n\n/**\n * @param detailCutoff Factor by which the spatial resolution of the mesh may be worse than the\n * spatial resolution of a single viewport pixel. For example, a value of 10 means that if a\n * given portion of the object will be rendered such that a pixel corresponds to 50 nm, then a\n * mesh level of detail down to 500 nm will be requested for that portion of the object.\n */\nexport function getDesiredMultiscaleMeshChunks(\n manifest: MultiscaleMeshManifest,\n modelViewProjection: mat4,\n clippingPlanes: Float32Array,\n detailCutoff: number,\n viewportWidth: number,\n viewportHeight: number,\n callback: (\n lod: number,\n row: number,\n renderScale: number,\n empty: number,\n ) => void,\n) {\n const { octree, lodScales, chunkGridSpatialOrigin, chunkShape } = manifest;\n const maxLod = lodScales.length - 1;\n const m00 = modelViewProjection[0];\n const m01 = modelViewProjection[4];\n const m02 = modelViewProjection[8];\n const m10 = modelViewProjection[1];\n const m11 = modelViewProjection[5];\n const m12 = modelViewProjection[9];\n const m30 = modelViewProjection[3];\n const m31 = modelViewProjection[7];\n const m32 = modelViewProjection[11];\n const m33 = modelViewProjection[15];\n\n const minWXcoeff = m30 > 0 ? 0 : 1;\n const minWYcoeff = m31 > 0 ? 0 : 1;\n const minWZcoeff = m32 > 0 ? 0 : 1;\n\n const nearA = clippingPlanes[4 * 4];\n const nearB = clippingPlanes[4 * 4 + 1];\n const nearC = clippingPlanes[4 * 4 + 2];\n const nearD = clippingPlanes[4 * 4 + 3];\n\n function getPointW(x: number, y: number, z: number) {\n return m30 * x + m31 * y + m32 * z + m33;\n }\n\n function getBoxW(\n xLower: number,\n yLower: number,\n zLower: number,\n xUpper: number,\n yUpper: number,\n zUpper: number,\n ) {\n return getPointW(\n xLower + minWXcoeff * (xUpper - xLower),\n yLower + minWYcoeff * (yUpper - yLower),\n zLower + minWZcoeff * (zUpper - zLower),\n );\n }\n\n /**\n * Minimum value of w within clipping frustrum (under the assumption that the minimum value occurs\n * on the near clipping plane).\n */\n const minWClip = getPointW(-nearD * nearA, -nearD * nearB, -nearD * nearC);\n\n const objectXLower = manifest.clipLowerBound[0];\n const objectYLower = manifest.clipLowerBound[1];\n const objectZLower = manifest.clipLowerBound[2];\n const objectXUpper = manifest.clipUpperBound[0];\n const objectYUpper = manifest.clipUpperBound[1];\n const objectZUpper = manifest.clipUpperBound[2];\n\n const xScale = Math.sqrt(\n (m00 * viewportWidth) ** 2 + (m10 * viewportHeight) ** 2,\n );\n const yScale = Math.sqrt(\n (m01 * viewportWidth) ** 2 + (m11 * viewportHeight) ** 2,\n );\n const zScale = Math.sqrt(\n (m02 * viewportWidth) ** 2 + (m12 * viewportHeight) ** 2,\n );\n\n const scaleFactor = Math.max(xScale, yScale, zScale);\n\n function handleChunk(lod: number, row: number, priorLodScale: number) {\n const size = 1 << lod;\n const rowOffset = row * 5;\n const gridX = octree[rowOffset];\n const gridY = octree[rowOffset + 1];\n const gridZ = octree[rowOffset + 2];\n const childBegin = octree[rowOffset + 3];\n const childEndAndEmpty = octree[rowOffset + 4];\n let xLower = gridX * size * chunkShape[0] + chunkGridSpatialOrigin[0];\n let yLower = gridY * size * chunkShape[1] + chunkGridSpatialOrigin[1];\n let zLower = gridZ * size * chunkShape[2] + chunkGridSpatialOrigin[2];\n let xUpper = xLower + size * chunkShape[0];\n let yUpper = yLower + size * chunkShape[1];\n let zUpper = zLower + size * chunkShape[2];\n xLower = Math.max(xLower, objectXLower);\n yLower = Math.max(yLower, objectYLower);\n zLower = Math.max(zLower, objectZLower);\n xUpper = Math.min(xUpper, objectXUpper);\n yUpper = Math.min(yUpper, objectYUpper);\n zUpper = Math.min(zUpper, objectZUpper);\n\n if (\n isAABBVisible(\n xLower,\n yLower,\n zLower,\n xUpper,\n yUpper,\n zUpper,\n clippingPlanes,\n )\n ) {\n const minW = Math.max(\n minWClip,\n getBoxW(xLower, yLower, zLower, xUpper, yUpper, zUpper),\n );\n const pixelSize = minW / scaleFactor;\n\n if (priorLodScale === 0 || pixelSize * detailCutoff < priorLodScale) {\n const lodScale = lodScales[lod];\n if (lodScale !== 0) {\n callback(lod, row, lodScale / pixelSize, childEndAndEmpty >>> 31);\n }\n\n if (\n lod > 0 &&\n (lodScale === 0 || pixelSize * detailCutoff < lodScale)\n ) {\n const nextPriorLodScale = lodScale === 0 ? priorLodScale : lodScale;\n const childEnd = (childEndAndEmpty & 0x7fffffff) >>> 0;\n for (let childRow = childBegin; childRow < childEnd; ++childRow) {\n handleChunk(lod - 1, childRow, nextPriorLodScale);\n }\n }\n }\n }\n }\n handleChunk(maxLod, octree.length / 5 - 1, 0);\n}\n\nexport function getMultiscaleChunksToDraw(\n manifest: MultiscaleMeshManifest,\n modelViewProjection: mat4,\n clippingPlanes: Float32Array,\n detailCutoff: number,\n viewportWidth: number,\n viewportHeight: number,\n hasChunk: (lod: number, row: number, renderScale: number) => boolean,\n callback: (\n lod: number,\n row: number,\n subChunkBegin: number,\n subChunkEnd: number,\n renderScale: number,\n ) => void,\n) {\n const { lodScales } = manifest;\n let maxLod = 0;\n while (maxLod + 1 < lodScales.length && lodScales[maxLod + 1] !== 0) {\n ++maxLod;\n }\n\n const stackEntryStride = 3;\n\n // [row, parentSubChunkIndex, renderScale]\n const stack: number[] = [];\n let stackDepth = 0;\n let priorSubChunkIndex = 0;\n function emitChunksUpTo(targetStackIndex: number, subChunkIndex: number) {\n if (DEBUG_CHUNKS_TO_DRAW) {\n console.log(\n `emitChunksUpTo: stackDepth=${stackDepth}, targetStackIndex=${targetStackIndex}, subChunkIndex=${subChunkIndex}, priorSubChunkIndex=${priorSubChunkIndex}`,\n );\n }\n while (true) {\n if (stackDepth === 0) return;\n\n // Finish last chunk of last (finest) lod.\n const stackIndex = stackDepth - 1;\n const entryLod = maxLod - stackIndex;\n const entryRow = stack[stackIndex * stackEntryStride];\n const numSubChunks = entryLod === 0 ? 1 : 8;\n const entrySubChunkIndex = stack[stackIndex * stackEntryStride + 1];\n const entryRenderScale = stack[stackIndex * stackEntryStride + 2];\n if (targetStackIndex === stackDepth) {\n const endSubChunk = subChunkIndex & (numSubChunks - 1);\n\n if (priorSubChunkIndex !== endSubChunk && entryRow !== -1) {\n if (DEBUG_CHUNKS_TO_DRAW) {\n console.log(\n ` drawing chunk because priorSubChunkIndex (${priorSubChunkIndex}) != endSubChunk (${endSubChunk})`,\n );\n }\n callback(\n entryLod,\n entryRow,\n priorSubChunkIndex,\n endSubChunk,\n entryRenderScale,\n );\n }\n priorSubChunkIndex = endSubChunk + 1;\n return;\n }\n if (priorSubChunkIndex !== numSubChunks && entryRow !== -1) {\n callback(\n entryLod,\n entryRow,\n priorSubChunkIndex,\n numSubChunks,\n entryRenderScale,\n );\n }\n priorSubChunkIndex = entrySubChunkIndex + 1;\n --stackDepth;\n }\n }\n\n let priorMissingLod = 0;\n if (DEBUG_CHUNKS_TO_DRAW) {\n console.log(\"\");\n console.log(\"Starting to draw\");\n }\n const { octree } = manifest;\n getDesiredMultiscaleMeshChunks(\n manifest,\n modelViewProjection,\n clippingPlanes,\n detailCutoff,\n viewportWidth,\n viewportHeight,\n (lod, row, renderScale, empty) => {\n if (!empty && !hasChunk(lod, row, renderScale)) {\n priorMissingLod = Math.max(lod, priorMissingLod);\n return;\n }\n if (lod < priorMissingLod) {\n // A parent chunk (containing chunk at coarser level-of-detail) is missing. We can't draw\n // chunks at this level-of-detail because we would not be able to fill in gaps.\n return;\n }\n priorMissingLod = 0;\n const rowOffset = row * 5;\n const x = octree[rowOffset];\n const y = octree[rowOffset + 1];\n const z = octree[rowOffset + 2];\n const subChunkIndex = getOctreeChildIndex(x, y, z);\n const stackIndex = maxLod - lod;\n emitChunksUpTo(stackIndex, subChunkIndex);\n const stackOffset = stackIndex * stackEntryStride;\n stack[stackOffset] = empty ? -1 : row;\n stack[stackOffset + 1] = subChunkIndex;\n stack[stackOffset + 2] = renderScale;\n if (DEBUG_CHUNKS_TO_DRAW) {\n console.log(\n `Adding to stack: lod=${lod}, row=${stack[stackOffset]}, subChunkIndex=${subChunkIndex}`,\n );\n }\n priorSubChunkIndex = 0;\n stackDepth = stackIndex + 1;\n },\n );\n\n emitChunksUpTo(0, 0);\n}\n\nexport function validateOctree(octree: Uint32Array) {\n if (octree.length % 5 !== 0) {\n throw new Error(\"Invalid length\");\n }\n const numNodes = octree.length / 5;\n const seenNodes = new Set();\n function exploreNode(node: number) {\n if (seenNodes.has(node)) {\n throw new Error(\"Previously seen node\");\n }\n seenNodes.add(node);\n if (node < 0 || node >= numNodes) {\n throw new Error(\"Invalid node reference\");\n }\n const x = octree[node * 5];\n const y = octree[node * 5 + 1];\n const z = octree[node * 5 + 2];\n const beginChild = octree[node * 5 + 3];\n const endChild = octree[node * 5 + 4];\n if (\n beginChild < 0 ||\n endChild < 0 ||\n endChild < beginChild ||\n endChild > numNodes ||\n beginChild + 8 < endChild\n ) {\n throw new Error(\"Invalid child references\");\n }\n for (let child = beginChild; child < endChild; ++child) {\n const childX = octree[child * 5];\n const childY = octree[child * 5 + 1];\n const childZ = octree[child * 5 + 2];\n if (childX >>> 1 !== x || childY >>> 1 !== y || childZ >>> 1 !== z) {\n throw new Error(\"invalid child\");\n }\n exploreNode(child);\n }\n }\n if (numNodes === 0) return;\n exploreNode(numNodes - 1);\n if (seenNodes.size !== numNodes) {\n throw new Error(\"Orphan nodes in octree\");\n }\n}\n\nexport function getMultiscaleFragmentKey(\n objectKey: string,\n lod: number,\n chunkIndex: number,\n) {\n return `${objectKey}/${lod}:${chunkIndex}`;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { VisibleLayerInfo } from \"#src/layer/index.js\";\nimport type { PerspectivePanel } from \"#src/perspective_view/panel.js\";\nimport type {\n ThreeDimensionalReadyRenderContext,\n ThreeDimensionalRenderContext,\n} from \"#src/renderlayer.js\";\nimport { VisibilityTrackedRenderLayer } from \"#src/renderlayer.js\";\nimport type { vec3 } from \"#src/util/geom.js\";\nimport type { ShaderBuilder, ShaderModule } from \"#src/webgl/shader.js\";\nimport type { SharedObject } from \"#src/worker_rpc.js\";\n\nexport type PerspectiveViewReadyRenderContext =\n ThreeDimensionalReadyRenderContext;\n\nexport interface PerspectiveViewRenderContext\n extends PerspectiveViewReadyRenderContext,\n ThreeDimensionalRenderContext {\n lightDirection: vec3;\n ambientLighting: number;\n directionalLighting: number;\n emitter: ShaderModule;\n\n /**\n * Specifies whether the emitted color value will be used.\n */\n emitColor: boolean;\n\n /**\n * Specifies whether the emitted pick ID will be used.\n */\n emitPickID: boolean;\n\n /**\n * Specifies whether there was a previous pick ID pass.\n */\n alreadyEmittedPickID: boolean;\n\n /**\n * Specifies the ID of the depth frame buffer texture to query during rendering.\n */\n depthBufferTexture?: WebGLTexture | null;\n\n /**\n * Specifies if there are any slice views\n */\n sliceViewsPresent: boolean;\n\n /**\n * Specifies if the camera is moving\n */\n isContinuousCameraMotionInProgress: boolean;\n\n /**\n * Specifices how to bind the max projection buffer\n */\n bindMaxProjectionBuffer?: () => void | undefined;\n\n /**\n * Specifies how to bind the volume rendering buffer\n */\n bindVolumeRenderingBuffer?: () => void | undefined;\n\n /**\n * Specifies how to assign the max projection emitter\n */\n maxProjectionEmit?: (builder: ShaderBuilder) => void | undefined;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging\nexport class PerspectiveViewRenderLayer<\n AttachmentState = unknown,\n> extends VisibilityTrackedRenderLayer {\n draw(\n renderContext: PerspectiveViewRenderContext,\n attachment: VisibleLayerInfo,\n ): void {\n renderContext;\n attachment;\n // Must be overridden by subclasses.\n }\n\n isReady(\n renderContext: PerspectiveViewReadyRenderContext,\n attachment: VisibleLayerInfo,\n ) {\n renderContext;\n attachment;\n return true;\n }\n\n get transparentPickEnabled() {\n return true;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport interface PerspectiveViewRenderLayer {\n isTransparent: boolean | undefined;\n isAnnotation: boolean | undefined;\n backend: SharedObject | undefined;\n isVolumeRendering: boolean | undefined;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { hashCombine } from \"#src/gpu_hash/hash_function.js\";\nimport { getRandomValues } from \"#src/util/random.js\";\nimport { Uint64 } from \"#src/util/uint64.js\";\n\nexport const NUM_ALTERNATIVES = 3;\n\n// For 3 hash functions, a DEFAULT_LOAD_FACTOR of 0.8 reliably avoids\n// expensive rehashing caused by unresolvable collisions.\nconst DEFAULT_LOAD_FACTOR = 0.8;\n\nconst DEBUG = false;\n\n// Key that needs to be inserted. Temporary variables used during insert. These can safely be\n// global because control never leaves functions defined in this module while these are in use.\nlet pendingLow = 0;\nlet pendingHigh = 0;\nlet backupPendingLow = 0;\nlet backupPendingHigh = 0;\n\nexport abstract class HashTableBase {\n loadFactor = DEFAULT_LOAD_FACTOR;\n size = 0;\n table: Uint32Array;\n tableSize: number;\n emptyLow = 4294967295;\n emptyHigh = 4294967295;\n maxRehashAttempts = 5;\n maxAttempts = 5;\n capacity: number;\n\n /**\n * Number of uint32 elements per entry in hash table.\n */\n entryStride: number;\n\n generation = 0;\n\n mungedEmptyKey = -1;\n\n constructor(\n public hashSeeds = HashTableBase.generateHashSeeds(NUM_ALTERNATIVES),\n ) {\n // Minimum size must be greater than 2 * hashSeeds.length. Otherwise, tableWithMungedEmptyKey\n // may loop infinitely.\n let initialSize = 8;\n while (initialSize < 2 * hashSeeds.length) {\n initialSize *= 2;\n }\n this.allocate(initialSize);\n }\n\n private updateHashFunctions(numHashes: number) {\n this.hashSeeds = HashTableBase.generateHashSeeds(numHashes);\n this.mungedEmptyKey = -1;\n }\n\n /**\n * Invokes callback with a modified version of the hash table data array.\n *\n * Replaces all slots that appear to be valid entries for (emptyLow, emptyHigh), i.e. slots that\n * contain (emptyLow, emptyHigh) and to which (emptyLow, emptyHigh) hashes, with (mungedEmptyKey,\n * mungedEmptyKey).\n *\n * mungedEmptyKey is chosen to be a 32-bit value with the property that the 64-bit value\n * (mungedEmptyKey, mungedEmptyKey) does not hash to any of the same slots as (emptyLow,\n * emptyHigh).\n *\n * This allows the modified data array to be used for lookups without special casing the empty\n * key.\n */\n tableWithMungedEmptyKey(callback: (table: Uint32Array) => void) {\n const numHashes = this.hashSeeds.length;\n const emptySlots = new Array(numHashes);\n for (let i = 0; i < numHashes; ++i) {\n emptySlots[i] = this.getHash(i, this.emptyLow, this.emptyHigh);\n }\n let { mungedEmptyKey } = this;\n if (mungedEmptyKey === -1) {\n chooseMungedEmptyKey: while (true) {\n mungedEmptyKey = (Math.random() * 0x1000000) >>> 0;\n for (let i = 0; i < numHashes; ++i) {\n const h = this.getHash(i, mungedEmptyKey, mungedEmptyKey);\n for (let j = 0; j < numHashes; ++j) {\n if (emptySlots[j] === h) {\n continue chooseMungedEmptyKey;\n }\n }\n }\n this.mungedEmptyKey = mungedEmptyKey;\n break;\n }\n }\n const { table, emptyLow, emptyHigh } = this;\n for (let i = 0; i < numHashes; ++i) {\n const h = emptySlots[i];\n if (table[h] === emptyLow && table[h + 1] === emptyHigh) {\n table[h] = mungedEmptyKey;\n table[h + 1] = mungedEmptyKey;\n }\n }\n try {\n callback(table);\n } finally {\n for (let i = 0; i < numHashes; ++i) {\n const h = emptySlots[i];\n if (table[h] === mungedEmptyKey && table[h + 1] === mungedEmptyKey) {\n table[h] = emptyLow;\n table[h + 1] = emptyHigh;\n }\n }\n }\n }\n\n static generateHashSeeds(numAlternatives = NUM_ALTERNATIVES) {\n return getRandomValues(new Uint32Array(numAlternatives));\n }\n\n getHash(hashIndex: number, low: number, high: number) {\n let hash = this.hashSeeds[hashIndex];\n hash = hashCombine(hash, low);\n hash = hashCombine(hash, high);\n return this.entryStride * (hash & (this.tableSize - 1));\n }\n\n /**\n * Iterates over the Uint64 keys contained in the hash set.\n *\n * Creates a new Uint64 object at every iteration (otherwise spread and Array.from() fail)\n */\n *keys(): IterableIterator {\n const { emptyLow, emptyHigh, entryStride } = this;\n const { table } = this;\n for (let i = 0, length = table.length; i < length; i += entryStride) {\n const low = table[i];\n const high = table[i + 1];\n if (low !== emptyLow || high !== emptyHigh) {\n yield new Uint64(low, high);\n }\n }\n }\n\n /**\n * Iterates over the Uint64 keys contained in the hash set.\n *\n * The same temp value will be modified and yielded at every iteration.\n */\n *unsafeKeys(temp = new Uint64()): IterableIterator {\n const { emptyLow, emptyHigh, entryStride } = this;\n const { table } = this;\n for (let i = 0, length = table.length; i < length; i += entryStride) {\n const low = table[i];\n const high = table[i + 1];\n if (low !== emptyLow || high !== emptyHigh) {\n temp.low = low;\n temp.high = high;\n yield temp;\n }\n }\n }\n\n indexOfPair(low: number, high: number) {\n const { table, emptyLow, emptyHigh } = this;\n if (low === emptyLow && high === emptyHigh) {\n return -1;\n }\n for (let i = 0, numHashes = this.hashSeeds.length; i < numHashes; ++i) {\n const h = this.getHash(i, low, high);\n if (table[h] === low && table[h + 1] === high) {\n return h;\n }\n }\n return -1;\n }\n\n /**\n * Returns the offset into the hash table of the specified element, or -1 if the element is not\n * present.\n */\n indexOf(x: Uint64) {\n return this.indexOfPair(x.low, x.high);\n }\n\n /**\n * Changes the empty key to a value that is not equal to the current empty key and is not present\n * in the table.\n *\n * This is called when an attempt is made to insert the empty key.\n */\n private chooseAnotherEmptyKey() {\n const { emptyLow, emptyHigh, table, entryStride } = this;\n let newLow: number;\n let newHigh: number;\n while (true) {\n newLow = (Math.random() * 0x100000000) >>> 0;\n newHigh = (Math.random() * 0x100000000) >>> 0;\n if (newLow === emptyLow && newHigh === emptyHigh) {\n continue;\n }\n if (this.hasPair(newLow, newHigh)) {\n continue;\n }\n break;\n }\n\n this.emptyLow = newLow;\n this.emptyHigh = newHigh;\n\n // Replace empty keys in the table.\n for (let h = 0, length = table.length; h < length; h += entryStride) {\n if (table[h] === emptyLow && table[h + 1] === emptyHigh) {\n table[h] = newLow;\n table[h + 1] = newHigh;\n }\n }\n }\n\n /**\n * Returns true iff the specified element is present.\n */\n has(x: Uint64) {\n return this.indexOf(x) !== -1;\n }\n\n /**\n * Returns true iff the specified element is present.\n */\n hasPair(low: number, high: number) {\n return this.indexOfPair(low, high) !== -1;\n }\n\n delete(x: Uint64) {\n const index = this.indexOf(x);\n if (index !== -1) {\n const { table } = this;\n table[index] = this.emptyLow;\n table[index + 1] = this.emptyHigh;\n ++this.generation;\n this.size--;\n return true;\n }\n return false;\n }\n\n private clearTable() {\n const { table, entryStride, emptyLow, emptyHigh } = this;\n const length = table.length;\n\n for (let h = 0; h < length; h += entryStride) {\n table[h] = emptyLow;\n table[h + 1] = emptyHigh;\n }\n }\n\n clear() {\n if (this.size === 0) {\n return false;\n }\n this.size = 0;\n ++this.generation;\n this.clearTable();\n return true;\n }\n\n reserve(x: number) {\n if (x > this.capacity) {\n this.backupPending();\n this.grow(x);\n this.restorePending();\n return true;\n }\n return false;\n }\n\n protected swapPending(table: Uint32Array, offset: number) {\n const tempLow = pendingLow;\n const tempHigh = pendingHigh;\n this.storePending(table, offset);\n table[offset] = tempLow;\n table[offset + 1] = tempHigh;\n }\n\n protected storePending(table: Uint32Array, offset: number) {\n pendingLow = table[offset];\n pendingHigh = table[offset + 1];\n }\n\n protected backupPending() {\n backupPendingLow = pendingLow;\n backupPendingHigh = pendingHigh;\n }\n\n protected restorePending() {\n pendingLow = backupPendingLow;\n pendingHigh = backupPendingHigh;\n }\n\n private tryToInsert() {\n if (DEBUG) {\n console.log(`tryToInsert: ${pendingLow}, ${pendingHigh}`);\n }\n let attempt = 0;\n const { emptyLow, emptyHigh, maxAttempts, table } = this;\n const numHashes = this.hashSeeds.length;\n\n let tableIndex = Math.floor(Math.random() * numHashes);\n while (true) {\n const h = this.getHash(tableIndex, pendingLow, pendingHigh);\n this.swapPending(table, h);\n if (pendingLow === emptyLow && pendingHigh === emptyHigh) {\n return true;\n }\n if (++attempt === maxAttempts) {\n break;\n }\n tableIndex =\n (tableIndex + Math.floor(Math.random() * (numHashes - 1)) + 1) %\n numHashes;\n }\n return false;\n }\n\n private allocate(tableSize: number) {\n this.tableSize = tableSize;\n const { entryStride } = this;\n this.table = new Uint32Array(tableSize * entryStride);\n this.maxAttempts = tableSize;\n this.clearTable();\n this.capacity = tableSize * this.loadFactor;\n this.mungedEmptyKey = -1;\n }\n\n private rehash(oldTable: Uint32Array, tableSize: number) {\n if (DEBUG) {\n console.log(\"rehash begin\");\n }\n this.allocate(tableSize);\n this.updateHashFunctions(this.hashSeeds.length);\n const { emptyLow, emptyHigh, entryStride } = this;\n for (let h = 0, length = oldTable.length; h < length; h += entryStride) {\n const low = oldTable[h];\n const high = oldTable[h + 1];\n if (low !== emptyLow || high !== emptyHigh) {\n this.storePending(oldTable, h);\n if (!this.tryToInsert()) {\n if (DEBUG) {\n console.log(\"rehash failed\");\n }\n return false;\n }\n }\n }\n if (DEBUG) {\n console.log(\"rehash end\");\n }\n return true;\n }\n\n private grow(desiredTableSize: number) {\n if (DEBUG) {\n console.log(`grow: ${desiredTableSize}`);\n }\n const oldTable = this.table;\n let { tableSize } = this;\n while (tableSize < desiredTableSize) {\n tableSize *= 2;\n }\n while (true) {\n for (\n let rehashAttempt = 0;\n rehashAttempt < this.maxRehashAttempts;\n ++rehashAttempt\n ) {\n if (this.rehash(oldTable, tableSize)) {\n if (DEBUG) {\n console.log(\"grow end\");\n }\n return;\n }\n }\n tableSize *= 2;\n }\n }\n\n protected insertInternal() {\n ++this.generation;\n\n if (pendingLow === this.emptyLow && pendingHigh === this.emptyHigh) {\n this.chooseAnotherEmptyKey();\n }\n\n if (++this.size > this.capacity) {\n this.backupPending();\n this.grow(this.tableSize * 2);\n this.restorePending();\n }\n\n while (!this.tryToInsert()) {\n this.backupPending();\n this.grow(this.tableSize);\n this.restorePending();\n }\n }\n}\n\nexport class HashSetUint64 extends HashTableBase {\n add(x: Uint64) {\n const { low, high } = x;\n if (this.hasPair(low, high)) {\n return false;\n }\n if (DEBUG) {\n console.log(`add: ${low},${high}`);\n }\n pendingLow = low;\n pendingHigh = high;\n this.insertInternal();\n return true;\n }\n\n /**\n * Iterates over the keys.\n * Creates a new Uint64 object at every iteration (otherwise spread and Array.from() fail)\n */\n [Symbol.iterator]() {\n return this.unsafeKeys();\n }\n}\nHashSetUint64.prototype.entryStride = 2;\n\n// Value that needs to be inserted. Temporary variables used during insert. These can safely be\n// global because control never leaves functions defined in this module while these are in use.\nlet pendingValueLow = 0;\nlet pendingValueHigh = 0;\nlet backupPendingValueLow = 0;\nlet backupPendingValueHigh = 0;\n\nexport class HashMapUint64 extends HashTableBase {\n set(key: Uint64, value: Uint64) {\n const { low, high } = key;\n if (this.hasPair(low, high)) {\n return false;\n }\n if (DEBUG) {\n console.log(`add: ${low},${high} -> ${value.low},${value.high}`);\n }\n pendingLow = low;\n pendingHigh = high;\n pendingValueLow = value.low;\n pendingValueHigh = value.high;\n this.insertInternal();\n return true;\n }\n\n get(key: Uint64, value: Uint64): boolean {\n const h = this.indexOf(key);\n if (h === -1) {\n return false;\n }\n const { table } = this;\n value.low = table[h + 2];\n value.high = table[h + 3];\n return true;\n }\n\n protected swapPending(table: Uint32Array, offset: number) {\n const tempLow = pendingValueLow;\n const tempHigh = pendingValueHigh;\n super.swapPending(table, offset);\n table[offset + 2] = tempLow;\n table[offset + 3] = tempHigh;\n }\n\n protected storePending(table: Uint32Array, offset: number) {\n super.storePending(table, offset);\n pendingValueLow = table[offset + 2];\n pendingValueHigh = table[offset + 3];\n }\n\n protected backupPending() {\n super.backupPending();\n backupPendingValueLow = pendingValueLow;\n backupPendingValueHigh = pendingValueHigh;\n }\n\n protected restorePending() {\n super.restorePending();\n pendingValueLow = backupPendingValueLow;\n pendingValueHigh = backupPendingValueHigh;\n }\n\n /**\n * Iterates over entries. The same temporary value will be modified and yielded at every\n * iteration.\n */\n [Symbol.iterator]() {\n return this.unsafeEntries();\n }\n\n /**\n * Iterates over entries.\n * Creates new Uint64 objects at every iteration (otherwise spread and Array.from() fail)\n */\n *entries() {\n const { emptyLow, emptyHigh, entryStride } = this;\n const { table } = this;\n for (let i = 0, length = table.length; i < length; i += entryStride) {\n const low = table[i];\n const high = table[i + 1];\n if (low !== emptyLow || high !== emptyHigh) {\n const key = new Uint64(low, high);\n const value = new Uint64(table[i + 2], table[i + 3]);\n yield [key, value];\n }\n }\n }\n\n /**\n * Iterates over entries. The same temporary value will be modified and yielded at every\n * iteration.\n */\n *unsafeEntries(temp: [Uint64, Uint64] = [new Uint64(), new Uint64()]) {\n const { emptyLow, emptyHigh, entryStride } = this;\n const { table } = this;\n const [key, value] = temp;\n for (let i = 0, length = table.length; i < length; i += entryStride) {\n const low = table[i];\n const high = table[i + 1];\n if (low !== emptyLow || high !== emptyHigh) {\n key.low = low;\n key.high = high;\n value.low = table[i + 2];\n value.high = table[i + 3];\n yield temp;\n }\n }\n }\n}\nHashMapUint64.prototype.entryStride = 4;\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @file\n * Facilities for reading various data types from 2-D and 3-D WebGL textures.\n *\n * WebGL2 only supports 2-D and 3-D textures, and because implementations typically limit the size\n * of each dimension, a large 1-D array has to be fit to a rectangular 2-D texture, which may\n * require padding.\n */\n\nimport type { TypedArray, TypedArrayConstructor } from \"#src/util/array.js\";\nimport { maybePadArray } from \"#src/util/array.js\";\nimport { DATA_TYPE_SIGNED, DataType } from \"#src/util/data_type.js\";\nimport type { vec3 } from \"#src/util/geom.js\";\nimport type { GL } from \"#src/webgl/context.js\";\nimport type {\n ShaderBuilder,\n ShaderCodePart,\n ShaderSamplerPrefix,\n} from \"#src/webgl/shader.js\";\nimport {\n getShaderType,\n glsl_float,\n glsl_int16,\n glsl_int32,\n glsl_int8,\n glsl_log2Exact,\n glsl_uint16,\n glsl_uint32,\n glsl_uint64,\n glsl_uint8,\n glsl_unpackUint64leFromUint32,\n} from \"#src/webgl/shader_lib.js\";\nimport {\n setRawTexture3DParameters,\n setRawTextureParameters,\n} from \"#src/webgl/texture.js\";\n\nexport type TextureAccessCoefficients = vec3;\n\nexport class TextureFormat {\n /**\n * Number of texels per multi-channel element.\n */\n texelsPerElement: number;\n\n /**\n * Texture internal format to specify when uploading the texture data.\n */\n textureInternalFormat: number;\n\n /**\n * Texture format to specify when uploading the texture data.\n */\n textureFormat: number;\n\n /**\n * Texel type to specify when uploading the texture data.\n */\n texelType: number;\n\n /**\n * Number of typed array elements per texel.\n */\n arrayElementsPerTexel: number;\n\n /**\n * TypedArray type that must be used when uploading the texture data.\n */\n arrayConstructor: TypedArrayConstructor;\n\n samplerPrefix: ShaderSamplerPrefix;\n}\n\nexport const integerTextureFormatForNumComponents = [\n -1,\n WebGL2RenderingContext.RED_INTEGER,\n WebGL2RenderingContext.RG_INTEGER,\n WebGL2RenderingContext.RGB_INTEGER,\n WebGL2RenderingContext.RGBA_INTEGER,\n];\nexport const floatTextureFormatForNumComponents = [\n -1,\n WebGL2RenderingContext.RED,\n WebGL2RenderingContext.RG,\n WebGL2RenderingContext.RGB,\n WebGL2RenderingContext.RGBA,\n];\nexport const textureSelectorForNumComponents = [\"\", \"r\", \"rg\", \"rgb\", \"rgba\"];\nexport const internalUint8FormatForNumComponents = [\n -1,\n WebGL2RenderingContext.R8UI,\n WebGL2RenderingContext.RG8UI,\n WebGL2RenderingContext.RGB8UI,\n WebGL2RenderingContext.RGBA8UI,\n];\nexport const internalInt8FormatForNumComponents = [\n -1,\n WebGL2RenderingContext.R8I,\n WebGL2RenderingContext.RG8I,\n WebGL2RenderingContext.RGB8I,\n WebGL2RenderingContext.RGBA8I,\n];\nexport const internalUint16FormatForNumComponents = [\n -1,\n WebGL2RenderingContext.R16UI,\n WebGL2RenderingContext.RG16UI,\n WebGL2RenderingContext.RGB16UI,\n WebGL2RenderingContext.RGBA16UI,\n];\nexport const internalInt16FormatForNumComponents = [\n -1,\n WebGL2RenderingContext.R16I,\n WebGL2RenderingContext.RG16I,\n WebGL2RenderingContext.RGB16I,\n WebGL2RenderingContext.RGBA16I,\n];\nexport const internalUint32FormatForNumComponents = [\n -1,\n WebGL2RenderingContext.R32UI,\n WebGL2RenderingContext.RG32UI,\n WebGL2RenderingContext.RGB32UI,\n WebGL2RenderingContext.RGBA32UI,\n];\nexport const internalInt32FormatForNumComponents = [\n -1,\n WebGL2RenderingContext.R32I,\n WebGL2RenderingContext.RG32I,\n WebGL2RenderingContext.RGB32I,\n WebGL2RenderingContext.RGBA32I,\n];\nexport const internalFloatFormatForNumComponents = [\n -1,\n WebGL2RenderingContext.R32F,\n WebGL2RenderingContext.RG32F,\n WebGL2RenderingContext.RGB32F,\n WebGL2RenderingContext.RGBA32F,\n];\n\nexport function getSamplerPrefixForDataType(\n dataType: DataType,\n): ShaderSamplerPrefix {\n return dataType === DataType.FLOAT32\n ? \"\"\n : DATA_TYPE_SIGNED[dataType]\n ? \"i\"\n : \"u\";\n}\n\n/**\n * Fills in a OneDimensionalTextureFormat object with the suitable texture format for the specified\n * DataType and number of components.\n */\nexport function computeTextureFormat(\n format: TextureFormat,\n dataType: DataType,\n numComponents = 1,\n) {\n switch (dataType) {\n case DataType.UINT8:\n if (numComponents < 1 || numComponents > 4) {\n break;\n }\n format.texelsPerElement = 1;\n format.textureInternalFormat =\n internalUint8FormatForNumComponents[numComponents];\n format.textureFormat =\n integerTextureFormatForNumComponents[numComponents];\n format.texelType = WebGL2RenderingContext.UNSIGNED_BYTE;\n format.arrayElementsPerTexel = numComponents;\n format.arrayConstructor = Uint8Array;\n format.samplerPrefix = \"u\";\n return format;\n case DataType.INT8:\n if (numComponents < 1 || numComponents > 4) {\n break;\n }\n format.texelsPerElement = 1;\n format.textureInternalFormat =\n internalInt8FormatForNumComponents[numComponents];\n format.textureFormat =\n integerTextureFormatForNumComponents[numComponents];\n format.texelType = WebGL2RenderingContext.BYTE;\n format.arrayElementsPerTexel = numComponents;\n format.arrayConstructor = Int8Array;\n format.samplerPrefix = \"i\";\n return format;\n case DataType.UINT16:\n if (numComponents < 1 || numComponents > 4) {\n break;\n }\n format.texelsPerElement = 1;\n format.textureInternalFormat =\n internalUint16FormatForNumComponents[numComponents];\n format.textureFormat =\n integerTextureFormatForNumComponents[numComponents];\n format.texelType = WebGL2RenderingContext.UNSIGNED_SHORT;\n format.arrayElementsPerTexel = numComponents;\n format.arrayConstructor = Uint16Array;\n format.samplerPrefix = \"u\";\n return format;\n case DataType.INT16:\n if (numComponents < 1 || numComponents > 4) {\n break;\n }\n format.texelsPerElement = 1;\n format.textureInternalFormat =\n internalInt16FormatForNumComponents[numComponents];\n format.textureFormat =\n integerTextureFormatForNumComponents[numComponents];\n format.texelType = WebGL2RenderingContext.SHORT;\n format.arrayElementsPerTexel = numComponents;\n format.arrayConstructor = Int16Array;\n format.samplerPrefix = \"i\";\n return format;\n case DataType.UINT32:\n if (numComponents < 1 || numComponents > 4) {\n break;\n }\n format.texelsPerElement = 1;\n format.textureInternalFormat =\n internalUint32FormatForNumComponents[numComponents];\n format.textureFormat =\n integerTextureFormatForNumComponents[numComponents];\n format.texelType = WebGL2RenderingContext.UNSIGNED_INT;\n format.arrayElementsPerTexel = 1;\n format.arrayConstructor = Uint32Array;\n format.samplerPrefix = \"u\";\n return format;\n case DataType.INT32:\n if (numComponents < 1 || numComponents > 4) {\n break;\n }\n format.texelsPerElement = 1;\n format.textureInternalFormat =\n internalInt32FormatForNumComponents[numComponents];\n format.textureFormat =\n integerTextureFormatForNumComponents[numComponents];\n format.texelType = WebGL2RenderingContext.INT;\n format.arrayElementsPerTexel = 1;\n format.arrayConstructor = Int32Array;\n format.samplerPrefix = \"i\";\n return format;\n case DataType.UINT64:\n if (numComponents < 1 || numComponents > 2) {\n break;\n }\n format.texelsPerElement = 1;\n format.textureInternalFormat =\n internalUint32FormatForNumComponents[numComponents * 2];\n format.textureFormat =\n integerTextureFormatForNumComponents[numComponents * 2];\n format.texelType = WebGL2RenderingContext.UNSIGNED_INT;\n format.arrayElementsPerTexel = 2 * numComponents;\n format.arrayConstructor = Uint32Array;\n format.samplerPrefix = \"u\";\n return format;\n case DataType.FLOAT32:\n if (numComponents < 1 || numComponents > 4) {\n break;\n }\n format.texelsPerElement = 1;\n format.textureInternalFormat =\n internalFloatFormatForNumComponents[numComponents];\n format.textureFormat = floatTextureFormatForNumComponents[numComponents];\n format.texelType = WebGL2RenderingContext.FLOAT;\n format.arrayElementsPerTexel = numComponents;\n format.arrayConstructor = Float32Array;\n format.samplerPrefix = \"\";\n return format;\n }\n throw new Error(\n `No supported texture format for ${DataType[dataType]}[${numComponents}].`,\n );\n}\n\nexport function setOneDimensionalTextureData(\n gl: GL,\n format: TextureFormat,\n data: TypedArray,\n) {\n const {\n arrayConstructor,\n arrayElementsPerTexel,\n textureInternalFormat,\n textureFormat,\n texelsPerElement,\n } = format;\n const { maxTextureSize } = gl;\n const numElements = data.length / arrayElementsPerTexel;\n if (numElements * texelsPerElement > maxTextureSize * maxTextureSize) {\n throw new Error(\n \"Number of elements exceeds maximum texture size: \" +\n texelsPerElement +\n \" * \" +\n numElements,\n );\n }\n const minX = Math.ceil(numElements / maxTextureSize);\n const textureXBits = Math.ceil(Math.log2(minX));\n const textureWidth = (1 << textureXBits) * texelsPerElement;\n const textureHeight = Math.ceil(numElements / (1 << textureXBits));\n const requiredSize = textureWidth * textureHeight * arrayElementsPerTexel;\n if (data.constructor !== arrayConstructor) {\n data = new arrayConstructor(\n data.buffer,\n data.byteOffset,\n data.byteLength / arrayConstructor.BYTES_PER_ELEMENT,\n );\n }\n const padded = maybePadArray(data, requiredSize);\n gl.pixelStorei(WebGL2RenderingContext.UNPACK_ALIGNMENT, 1);\n setRawTextureParameters(gl);\n gl.texImage2D(\n WebGL2RenderingContext.TEXTURE_2D,\n /*level=*/ 0,\n textureInternalFormat,\n /*width=*/ textureWidth,\n /*height=*/ textureHeight,\n /*border=*/ 0,\n textureFormat,\n format.texelType,\n padded,\n );\n}\n\nexport function setTwoDimensionalTextureData(\n gl: GL,\n format: TextureFormat,\n data: TypedArray,\n width: number,\n height: number,\n) {\n const {\n arrayConstructor,\n textureInternalFormat,\n textureFormat,\n texelsPerElement,\n } = format;\n if (data.constructor !== arrayConstructor) {\n data = new arrayConstructor(\n data.buffer,\n data.byteOffset,\n data.byteLength / arrayConstructor.BYTES_PER_ELEMENT,\n );\n }\n gl.pixelStorei(WebGL2RenderingContext.UNPACK_ALIGNMENT, 1);\n setRawTextureParameters(gl);\n gl.texImage2D(\n WebGL2RenderingContext.TEXTURE_2D,\n /*level=*/ 0,\n textureInternalFormat,\n /*width=*/ width * texelsPerElement,\n /*height=*/ height,\n /*border=*/ 0,\n textureFormat,\n format.texelType,\n data,\n );\n}\n\nexport function setThreeDimensionalTextureData(\n gl: GL,\n format: TextureFormat,\n data: TypedArray,\n width: number,\n height: number,\n depth: number,\n) {\n const {\n arrayConstructor,\n textureInternalFormat,\n textureFormat,\n texelsPerElement,\n } = format;\n if (data.constructor !== arrayConstructor) {\n data = new arrayConstructor(\n data.buffer,\n data.byteOffset,\n data.byteLength / arrayConstructor.BYTES_PER_ELEMENT,\n );\n }\n gl.pixelStorei(WebGL2RenderingContext.UNPACK_ALIGNMENT, 1);\n setRawTexture3DParameters(gl);\n gl.texImage3D(\n WebGL2RenderingContext.TEXTURE_3D,\n /*level=*/ 0,\n textureInternalFormat,\n /*width=*/ width * texelsPerElement,\n /*height=*/ height,\n /*depth=*/ depth,\n /*border=*/ 0,\n textureFormat,\n format.texelType,\n data,\n );\n}\n\nfunction getShaderCodeForDataType(dataType: DataType): ShaderCodePart {\n switch (dataType) {\n case DataType.UINT8:\n return glsl_uint8;\n case DataType.INT8:\n return glsl_int8;\n case DataType.UINT16:\n return glsl_uint16;\n case DataType.INT16:\n return glsl_int16;\n case DataType.UINT32:\n return glsl_uint32;\n case DataType.INT32:\n return glsl_int32;\n case DataType.UINT64:\n return glsl_uint64;\n case DataType.FLOAT32:\n return glsl_float;\n }\n}\n\nfunction getAccessorFunction(\n functionName: string,\n readTextureValue: string,\n samplerName: string,\n indexType: string,\n dataType: DataType,\n numComponents: number,\n): ShaderCodePart[] {\n const shaderType = getShaderType(dataType, numComponents);\n const parts: ShaderCodePart[] = [getShaderCodeForDataType(dataType)];\n let code = `\n${shaderType} ${functionName}(${indexType} index) {\n`;\n switch (dataType) {\n case DataType.UINT8:\n case DataType.UINT16:\n case DataType.UINT32:\n code += `\n ${shaderType} result;\n highp uvec4 temp;\n ${readTextureValue}(${samplerName}, index, temp);\n result.value = temp.${textureSelectorForNumComponents[numComponents]};\n return result;\n`;\n break;\n case DataType.INT8:\n case DataType.INT16:\n case DataType.INT32:\n code += `\n ${shaderType} result;\n highp ivec4 temp;\n ${readTextureValue}(${samplerName}, index, temp);\n result.value = temp.${textureSelectorForNumComponents[numComponents]};\n return result;\n`;\n break;\n case DataType.UINT64:\n parts.push(glsl_unpackUint64leFromUint32);\n code += `\n highp uvec4 temp;\n ${readTextureValue}(${samplerName}, index, temp);\n return unpackUint64leFromUint32(temp.${\n textureSelectorForNumComponents[numComponents * 2]\n });\n`;\n break;\n case DataType.FLOAT32:\n parts.push(glsl_float);\n code += `\n highp vec4 temp;\n ${readTextureValue}(${samplerName}, index, temp);\n return temp.${textureSelectorForNumComponents[numComponents]};\n`;\n break;\n }\n code += `\n}\n`;\n parts.push(code);\n return parts;\n}\n\nexport class OneDimensionalTextureAccessHelper {\n readTextureValue = `readTextureValue_${this.key}`;\n constructor(public key: string) {}\n defineShader(builder: ShaderBuilder) {\n builder;\n }\n\n getReadTextureValueCode(\n texelsPerElement: number,\n samplerPrefix: ShaderSamplerPrefix,\n ) {\n let code = `\nvoid ${this.readTextureValue}(highp ${samplerPrefix}sampler2D sampler, highp uint index`;\n for (let i = 0; i < texelsPerElement; ++i) {\n code += `, out ${samplerPrefix}vec4 output${i}`;\n }\n code += `) {\n highp int width = textureSize(sampler, 0).x / ${texelsPerElement};\n highp uint log2width = log2Exact(uint(width));\n highp int y = int(index >> log2width);\n highp int x = int((index - (uint(y) << log2width)) * ${texelsPerElement}u);\n`;\n for (let i = 0; i < texelsPerElement; ++i) {\n code += `\n output${i} = texelFetch(sampler, ivec2(x + ${i}, y), 0);\n`;\n }\n code += `\n}\n`;\n return [glsl_log2Exact, code];\n }\n\n getAccessor(\n functionName: string,\n samplerName: string,\n dataType: DataType,\n numComponents = 1,\n ) {\n const samplerPrefix = getSamplerPrefixForDataType(dataType);\n return [\n this.getReadTextureValueCode(1, samplerPrefix),\n ...getAccessorFunction(\n functionName,\n this.readTextureValue,\n samplerName,\n \"highp uint\",\n dataType,\n numComponents,\n ),\n ];\n }\n}\n\nexport class TextureAccessHelper {\n readTextureValue = `readTextureValue_${this.key}`;\n constructor(\n public key: string,\n public textureDims: number,\n ) {}\n getReadTextureValueCode(\n texelsPerElement: number,\n samplerPrefix: ShaderSamplerPrefix,\n ) {\n const { textureDims } = this;\n let code = `\nvoid ${this.readTextureValue}(highp ${samplerPrefix}sampler${this.textureDims}D sampler, highp ivec${textureDims} p`;\n for (let i = 0; i < texelsPerElement; ++i) {\n code += `, out ${samplerPrefix}vec4 output${i}`;\n }\n code += `) {\n`;\n for (let i = 0; i < texelsPerElement; ++i) {\n code += `\n output${i} = texelFetch(sampler, ivec${textureDims}(p.x * ${texelsPerElement} + ${i}, p.y\n ${\n textureDims === 3 ? \", p.z\" : \"\"\n }), 0);\n`;\n }\n code += `\n}\n`;\n return code;\n }\n\n getAccessor(\n functionName: string,\n samplerName: string,\n dataType: DataType,\n numComponents = 1,\n ) {\n const samplerPrefix = getSamplerPrefixForDataType(dataType);\n return [\n this.getReadTextureValueCode(1, samplerPrefix),\n ...getAccessorFunction(\n functionName,\n this.readTextureValue,\n samplerName,\n `highp ivec${this.textureDims}`,\n dataType,\n numComponents,\n ),\n ];\n }\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { HashTableBase } from \"#src/gpu_hash/hash_table.js\";\nimport { NUM_ALTERNATIVES } from \"#src/gpu_hash/hash_table.js\";\nimport { DataType } from \"#src/util/data_type.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport type { GL } from \"#src/webgl/context.js\";\nimport type { ShaderBuilder, ShaderProgram } from \"#src/webgl/shader.js\";\nimport { glsl_equalUint64, glsl_uint64 } from \"#src/webgl/shader_lib.js\";\nimport {\n computeTextureFormat,\n OneDimensionalTextureAccessHelper,\n setOneDimensionalTextureData,\n TextureFormat,\n} from \"#src/webgl/texture_access.js\";\n\n// MumurHash, excluding the final mixing steps.\nexport const glsl_hashCombine = [\n glsl_uint64,\n `\nhighp uint hashCombine(highp uint state, highp uint value) {\n value *= 0xcc9e2d51u;\n value = (value << 15u) | (value >> 17u);\n value *= 0x1b873593u;\n state ^= value;\n state = (state << 13u) | (state >> 19u);\n state = (state * 5u) + 0xe6546b64u;\n return state;\n}\nhighp uint hashCombine(highp uint state, uint64_t x) {\n state = hashCombine(state, x.value[0]);\n return hashCombine(state, x.value[1]);\n}\n`,\n];\n\nconst textureFormat = computeTextureFormat(\n new TextureFormat(),\n DataType.UINT64,\n 1,\n);\n\nexport class GPUHashTable extends RefCounted {\n generation = -1;\n texture: WebGLTexture | null = null;\n\n constructor(\n public gl: GL,\n public hashTable: HashTable,\n ) {\n super();\n // createTexture should never actually return null.\n this.texture = gl.createTexture();\n }\n\n copyToGPU() {\n const { hashTable } = this;\n const { generation } = hashTable;\n if (this.generation === generation) {\n return;\n }\n const { gl, texture } = this;\n this.generation = generation;\n gl.activeTexture(WebGL2RenderingContext.TEXTURE0 + gl.tempTextureUnit);\n gl.bindTexture(WebGL2RenderingContext.TEXTURE_2D, texture);\n hashTable.tableWithMungedEmptyKey((table) => {\n setOneDimensionalTextureData(this.gl, textureFormat, table);\n });\n gl.bindTexture(WebGL2RenderingContext.TEXTURE_2D, null);\n }\n\n disposed() {\n const { gl } = this;\n gl.deleteTexture(this.texture);\n this.texture = null;\n this.gl = undefined;\n this.hashTable = undefined;\n super.disposed();\n }\n\n static get(gl: GL, hashTable: HashTable) {\n return gl.memoize.get(hashTable, () => new GPUHashTable(gl, hashTable));\n }\n}\n\nexport class HashSetShaderManager {\n textureUnitSymbol = Symbol.for(`gpuhashtable:${this.prefix}`);\n private accessHelper = new OneDimensionalTextureAccessHelper(\n `gpuhashtable_${this.prefix}`,\n );\n samplerName = this.prefix + \"_sampler\";\n hashSeedsName = this.prefix + \"_seeds\";\n hashKeyMask = this.prefix + \"_keyMask\";\n readTable = this.prefix + \"_readTable\";\n\n constructor(\n public prefix: string,\n public numAlternatives = NUM_ALTERNATIVES,\n ) {}\n\n defineShader(builder: ShaderBuilder) {\n const { hashSeedsName, samplerName, numAlternatives, hashKeyMask } = this;\n builder.addUniform(\"highp uint\", hashSeedsName, numAlternatives);\n builder.addUniform(\"highp uint\", hashKeyMask);\n builder.addTextureSampler(\n \"usampler2D\",\n samplerName,\n this.textureUnitSymbol,\n );\n builder.addFragmentCode(glsl_hashCombine);\n builder.addFragmentCode(glsl_uint64);\n builder.addFragmentCode(glsl_equalUint64);\n this.accessHelper.defineShader(builder);\n builder.addFragmentCode(\n this.accessHelper.getAccessor(\n this.readTable,\n this.samplerName,\n DataType.UINT64,\n 1,\n ),\n );\n let s = \"\";\n s += `\nbool ${this.hasFunctionName}(uint64_t x) {\n`;\n for (let alt = 0; alt < numAlternatives; ++alt) {\n s += `\n {\n uint h = hashCombine(${hashSeedsName}[${alt}], x) & ${hashKeyMask};\n uint64_t key = ${this.readTable}(h);\n if (equals(key, x)) {\n return true;\n }\n }\n`;\n }\n s += `\n return false;\n}\n`;\n builder.addFragmentCode(s);\n }\n\n get hasFunctionName() {\n return `${this.prefix}_has`;\n }\n\n enable(\n gl: GL,\n shader: ShaderProgram,\n hashTable: GPUHashTable,\n ) {\n hashTable.copyToGPU();\n const textureUnit = shader.textureUnit(this.textureUnitSymbol);\n gl.activeTexture(WebGL2RenderingContext.TEXTURE0 + textureUnit);\n gl.bindTexture(WebGL2RenderingContext.TEXTURE_2D, hashTable.texture);\n gl.uniform1ui(\n shader.uniform(this.hashKeyMask),\n hashTable.hashTable.tableSize - 1,\n );\n gl.uniform1uiv(\n shader.uniform(this.hashSeedsName),\n hashTable.hashTable.hashSeeds,\n );\n }\n\n disable(gl: GL, shader: ShaderProgram) {\n const textureUnit = shader.textureUnit(this.textureUnitSymbol);\n gl.activeTexture(WebGL2RenderingContext.TEXTURE0 + textureUnit);\n gl.bindTexture(WebGL2RenderingContext.TEXTURE_2D, null);\n }\n}\n\nexport class HashMapShaderManager extends HashSetShaderManager {\n defineShader(builder: ShaderBuilder) {\n super.defineShader(builder);\n const { numAlternatives, hashSeedsName, hashKeyMask } = this;\n let s = `\nbool ${this.getFunctionName}(uint64_t x, out uint64_t value) {\n`;\n for (let alt = 0; alt < numAlternatives; ++alt) {\n s += `\n {\n uint h = hashCombine(${hashSeedsName}[${alt}], x) & ${hashKeyMask};\n uint64_t key = ${this.readTable}(h * 2u);\n if (equals(key, x)) {\n value = ${this.readTable}(h * 2u + 1u);\n return true;\n }\n }\n`;\n }\n s += `\n return false;\n}\n`;\n builder.addFragmentCode(s);\n }\n\n get getFunctionName() {\n return `${this.prefix}_get`;\n }\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { hashCombine } from \"#src/gpu_hash/hash_function.js\";\nimport type { HashTableBase } from \"#src/gpu_hash/hash_table.js\";\nimport type { GPUHashTable } from \"#src/gpu_hash/shader.js\";\nimport {\n glsl_hashCombine,\n HashMapShaderManager,\n} from \"#src/gpu_hash/shader.js\";\nimport { hsvToRgb } from \"#src/util/colorspace.js\";\nimport { getRandomUint32 } from \"#src/util/random.js\";\nimport { NullarySignal } from \"#src/util/signal.js\";\nimport type { Trackable } from \"#src/util/trackable.js\";\nimport type { Uint64 } from \"#src/util/uint64.js\";\nimport type { GL } from \"#src/webgl/context.js\";\nimport type { ShaderBuilder, ShaderProgram } from \"#src/webgl/shader.js\";\nimport { glsl_hsvToRgb, glsl_uint64 } from \"#src/webgl/shader_lib.js\";\n\nconst NUM_COMPONENTS = 2;\n\nexport class SegmentColorShaderManager {\n seedName = this.prefix + \"_seed\";\n\n constructor(public prefix: string) {}\n\n defineShader(builder: ShaderBuilder) {\n const { seedName } = this;\n builder.addUniform(\"highp uint\", seedName);\n builder.addFragmentCode(glsl_uint64);\n builder.addFragmentCode(glsl_hashCombine);\n builder.addFragmentCode(glsl_hsvToRgb);\n let s = `\nvec3 ${this.prefix}(uint64_t x) {\n uint h = hashCombine(${seedName}, x);\n vec${NUM_COMPONENTS} v;\n`;\n for (let i = 0; i < NUM_COMPONENTS; ++i) {\n s += `\n v[${i}] = float(h & 0xFFu) / 255.0;\n h >>= 8u;\n`;\n }\n s += `\n vec3 hsv = vec3(v.x, 0.5 + v.y * 0.5, 1.0);\n return hsvToRgb(hsv);\n}\n`;\n builder.addFragmentCode(s);\n }\n\n enable(gl: GL, shader: ShaderProgram, segmentColorHash: number) {\n gl.uniform1ui(shader.uniform(this.seedName), segmentColorHash);\n }\n}\n\nconst tempColor = new Float32Array(3);\n\nexport function getCssColor(color: Float32Array) {\n return `rgb(${color[0] * 100}%,${color[1] * 100}%,${color[2] * 100}%)`;\n}\n\nexport class SegmentColorHash implements Trackable {\n changed = new NullarySignal();\n\n constructor(public hashSeed: number = getRandomUint32()) {}\n\n static getDefault() {\n return new SegmentColorHash(0);\n }\n\n get value() {\n return this.hashSeed;\n }\n\n set value(value: number) {\n if (value !== this.hashSeed) {\n this.hashSeed = value;\n this.changed.dispatch();\n }\n }\n\n compute(out: Float32Array, x: Uint64) {\n let h = hashCombine(this.hashSeed, x.low);\n h = hashCombine(h, x.high);\n const c0 = (h & 0xff) / 255;\n const c1 = ((h >> 8) & 0xff) / 255;\n hsvToRgb(out, c0, 0.5 + 0.5 * c1, 1.0);\n return out;\n }\n\n computeCssColor(x: Uint64) {\n this.compute(tempColor, x);\n return getCssColor(tempColor);\n }\n\n randomize() {\n this.hashSeed = getRandomUint32();\n this.changed.dispatch();\n }\n\n toString() {\n return `new SegmentColorHash(${this.hashSeed})`;\n }\n\n toJSON() {\n return this.hashSeed === 0 ? undefined : this.hashSeed;\n }\n\n reset() {\n this.restoreState(0);\n }\n\n restoreState(x: any) {\n const newSeed = x >>> 0;\n if (newSeed !== this.hashSeed) {\n this.hashSeed = newSeed;\n this.changed.dispatch();\n }\n }\n}\n\n/**\n * Adds the shader code to get a segment's color if it is present in the map.\n */\nexport class SegmentStatedColorShaderManager {\n private hashMapShaderManager = new HashMapShaderManager(\n \"segmentStatedColorHash\",\n );\n\n constructor(public prefix: string) {}\n\n defineShader(builder: ShaderBuilder) {\n this.hashMapShaderManager.defineShader(builder);\n const s = `\nbool ${this.getFunctionName}(uint64_t x, out vec4 value) {\n uint64_t uint64Value;\n if (${this.hashMapShaderManager.getFunctionName}(x, uint64Value)) {\n uint uintValue = uint64Value.value[0];\n value.r = float((uintValue & 0x0000ffu)) / 255.0;\n value.g = float((uintValue & 0x00ff00u) >> 8) / 255.0;\n value.b = float((uintValue & 0xff0000u) >> 16) / 255.0;\n value.a = float((uintValue & 0xff000000u) >> 24) / 255.0;\n return true;\n }\n return false;\n}\n`;\n builder.addFragmentCode(s);\n }\n\n get getFunctionName() {\n return `${this.prefix}_get`;\n }\n\n enable(\n gl: GL,\n shader: ShaderProgram,\n hashTable: GPUHashTable,\n ) {\n this.hashMapShaderManager.enable(gl, shader, hashTable);\n }\n\n disable(gl: GL, shader: ShaderProgram) {\n this.hashMapShaderManager.disable(gl, shader);\n }\n}\n","/**\n * @license\n * Copyright 2017 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { EventActionMap } from \"#src/util/event_action_map.js\";\nimport type { InputEventBindings } from \"#src/viewer.js\";\n\nlet defaultGlobalBindings: EventActionMap | undefined;\n\nexport function getDefaultGlobalBindings() {\n if (defaultGlobalBindings === undefined) {\n const map = new EventActionMap();\n map.set(\"keyl\", \"recolor\");\n map.set(\"keyx\", \"clear-segments\");\n map.set(\"keys\", \"toggle-show-slices\");\n map.set(\"keyb\", \"toggle-scale-bar\");\n map.set(\"keyv\", \"toggle-default-annotations\");\n map.set(\"keya\", \"toggle-axis-lines\");\n map.set(\"keyo\", \"toggle-orthographic-projection\");\n\n for (let i = 1; i <= 9; ++i) {\n map.set(\"digit\" + i, \"toggle-layer-\" + i);\n map.set(\"control+digit\" + i, \"select-layer-\" + i);\n map.set(\"alt+digit\" + i, \"toggle-pick-layer-\" + i);\n }\n\n for (let i = 0; i < 26; ++i) {\n const lowercase = String.fromCharCode(97 + i);\n const uppercase = String.fromCharCode(65 + i);\n map.set(`alt?+control?+shift+key${lowercase}`, `tool-${uppercase}`);\n }\n\n map.set(\"keyn\", \"add-layer\");\n map.set(\"keyh\", \"help\");\n\n map.set(\"space\", \"toggle-layout\");\n map.set(\"shift+space\", \"toggle-layout-alternative\");\n map.set(\"backslash\", \"toggle-show-statistics\");\n\n map.set(\"alt+arrowup\", \"select-previous\");\n map.set(\"alt+arrowdown\", \"select-next\");\n defaultGlobalBindings = map;\n }\n return defaultGlobalBindings;\n}\n\nlet defaultSelectBindings: EventActionMap | undefined;\nexport function getDefaultSelectBindings() {\n if (defaultSelectBindings === undefined) {\n defaultSelectBindings = EventActionMap.fromObject({\n \"control+mousedown2\": \"select-position\",\n });\n }\n return defaultSelectBindings;\n}\n\nlet defaultAnnotationListBindings: EventActionMap | undefined;\nexport function getDefaultAnnotationListBindings() {\n if (defaultAnnotationListBindings === undefined) {\n defaultAnnotationListBindings = EventActionMap.fromObject(\n {\n click0: \"pin-annotation\",\n mousedown2: \"move-to-annotation\",\n },\n { parents: [[getDefaultSelectBindings(), 0]] },\n );\n }\n return defaultAnnotationListBindings;\n}\n\nlet defaultRenderedDataPanelBindings: EventActionMap | undefined;\nexport function getDefaultRenderedDataPanelBindings() {\n if (defaultRenderedDataPanelBindings === undefined) {\n defaultRenderedDataPanelBindings = EventActionMap.fromObject(\n {\n arrowleft: \"x-\",\n arrowright: \"x+\",\n arrowup: \"y-\",\n arrowdown: \"y+\",\n comma: \"z-\",\n period: \"z+\",\n bracketleft: \"t-\",\n bracketright: \"t+\",\n keyz: \"snap\",\n \"control+equal\": \"zoom-in\",\n \"alt+equal\": \"depth-range-decrease\",\n \"control+shift+equal\": \"zoom-in\",\n \"alt+shift+equal\": \"depth-range-decrease\",\n \"control+minus\": \"zoom-out\",\n \"alt+minus\": \"depth-range-increase\",\n keyr: \"rotate-relative-z-\",\n keye: \"rotate-relative-z+\",\n \"shift+arrowdown\": \"rotate-relative-x-\",\n \"shift+arrowup\": \"rotate-relative-x+\",\n \"shift+arrowleft\": \"rotate-relative-y-\",\n \"shift+arrowright\": \"rotate-relative-y+\",\n \"control+wheel\": { action: \"zoom-via-wheel\", preventDefault: true },\n \"alt+wheel\": {\n action: \"adjust-depth-range-via-wheel\",\n preventDefault: true,\n },\n \"at:wheel\": { action: \"z+1-via-wheel\", preventDefault: true },\n \"at:shift+wheel\": { action: \"z+10-via-wheel\", preventDefault: true },\n \"at:dblclick0\": \"select\",\n \"at:shift+dblclick0\": \"star\",\n \"at:control+mousedown0\": \"annotate\",\n \"at:mousedown2\": \"move-to-mouse-position\",\n \"at:alt+mousedown0\": \"move-annotation\",\n \"at:control+alt+mousedown2\": \"delete-annotation\",\n \"at:touchpinch\": \"zoom-via-touchpinch\",\n \"at:touchrotate\": \"rotate-in-plane-via-touchrotate\",\n \"at:touchtranslate2\": \"translate-in-plane-via-touchtranslate\",\n \"at:touchhold1\": \"move-to-mouse-position\",\n \"at:touchtap1x2\": \"select\",\n \"at:touchtap2x3\": \"snap\",\n },\n {\n label: \"All Data Panels\",\n parents: [[getDefaultSelectBindings(), 0]],\n },\n );\n }\n return defaultRenderedDataPanelBindings;\n}\n\nlet defaultPerspectivePanelBindings: EventActionMap | undefined;\nexport function getDefaultPerspectivePanelBindings() {\n if (defaultPerspectivePanelBindings === undefined) {\n defaultPerspectivePanelBindings = EventActionMap.fromObject(\n {\n \"at:mousedown0\": {\n action: \"rotate-via-mouse-drag\",\n stopPropagation: true,\n },\n \"at:shift+mousedown0\": {\n action: \"translate-via-mouse-drag\",\n stopPropagation: true,\n },\n \"at:touchtranslate1\": \"rotate-out-of-plane-via-touchtranslate\",\n },\n {\n parents: [\n [getDefaultRenderedDataPanelBindings(), Number.NEGATIVE_INFINITY],\n ],\n },\n );\n }\n return defaultPerspectivePanelBindings;\n}\n\nlet defaultSliceViewPanelBindings: EventActionMap | undefined;\nexport function getDefaultSliceViewPanelBindings() {\n if (defaultSliceViewPanelBindings === undefined) {\n defaultSliceViewPanelBindings = EventActionMap.fromObject(\n {\n \"at:mousedown0\": {\n action: \"translate-via-mouse-drag\",\n stopPropagation: true,\n },\n \"at:shift+mousedown0\": {\n action: \"rotate-via-mouse-drag\",\n stopPropagation: true,\n },\n \"at:touchtranslate1\": \"translate-z-via-touchtranslate\",\n },\n {\n parents: [\n [getDefaultRenderedDataPanelBindings(), Number.NEGATIVE_INFINITY],\n ],\n },\n );\n }\n return defaultSliceViewPanelBindings;\n}\n\nexport function setDefaultInputEventBindings(\n inputEventBindings: InputEventBindings,\n) {\n inputEventBindings.global.addParent(\n getDefaultGlobalBindings(),\n Number.NEGATIVE_INFINITY,\n );\n inputEventBindings.sliceView.addParent(\n getDefaultSliceViewPanelBindings(),\n Number.NEGATIVE_INFINITY,\n );\n inputEventBindings.perspectiveView.addParent(\n getDefaultPerspectivePanelBindings(),\n Number.NEGATIVE_INFINITY,\n );\n}\n","/**\n * @license\n * Copyright 2021 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport \"#src/ui/drag_and_drop.css\";\nimport { filterArrayInplace } from \"#src/util/array.js\";\nimport { removeChildren } from \"#src/util/dom.js\";\n\nlet dragStatusElement: HTMLElement | undefined;\n\nexport type DragStatusRenderer = string | (() => Node);\n\nexport type DragStatusType = \"drag\" | \"drop\";\n\nconst dragStatusStack: {\n target: EventTarget;\n operation: DragStatusType;\n status: DragStatusRenderer;\n}[] = [];\n\nfunction getStatusElement() {\n if (dragStatusElement === undefined) {\n const element = (dragStatusElement = document.createElement(\"div\"));\n element.classList.add(\"neuroglancer-drag-status\");\n document.body.appendChild(element);\n }\n return dragStatusElement;\n}\n\nfunction clearStatus() {\n if (dragStatusElement !== undefined) {\n removeChildren(dragStatusElement);\n dragStatusElement.style.display = \"none\";\n }\n}\n\nfunction applyStatus(status: DragStatusRenderer) {\n const element = getStatusElement();\n removeChildren(element);\n if (typeof status === \"string\") {\n element.appendChild(document.createTextNode(status));\n } else {\n element.appendChild(status());\n }\n element.style.display = \"\";\n}\n\nfunction removeDragStatus(target: EventTarget, operation: DragStatusType) {\n filterArrayInplace(\n dragStatusStack,\n (entry) => !(entry.target === target && entry.operation === operation),\n );\n}\n\nexport function pushDragStatus(\n target: EventTarget,\n operation: DragStatusType,\n status: DragStatusRenderer,\n) {\n removeDragStatus(target, operation);\n dragStatusStack.push({ target, operation, status });\n applyStatus(status);\n}\n\nexport function popDragStatus(target: EventTarget, operation: DragStatusType) {\n removeDragStatus(target, operation);\n const entry =\n dragStatusStack.length === 0\n ? undefined\n : dragStatusStack[dragStatusStack.length - 1];\n if (entry === undefined) {\n clearStatus();\n } else {\n applyStatus(entry.status);\n }\n}\n","/**\n * @license\n * Copyright 2021 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport \"#src/ui/side_panel.css\";\n\nimport type { DisplayContext } from \"#src/display_context.js\";\nimport { popDragStatus, pushDragStatus } from \"#src/ui/drag_and_drop.js\";\nimport type { Side } from \"#src/ui/side_panel_location.js\";\nimport { TrackableSidePanelLocation } from \"#src/ui/side_panel_location.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport { updateChildren } from \"#src/util/dom.js\";\nimport { startRelativeMouseDrag } from \"#src/util/mouse_drag.js\";\nimport { Signal } from \"#src/util/signal.js\";\nimport { WatchableVisibilityPriority } from \"#src/visibility_priority/frontend.js\";\nimport { makeCloseButton } from \"#src/widget/close_button.js\";\n\nexport const DRAG_OVER_CLASSNAME = \"neuroglancer-drag-over\";\n\ntype FlexDirection = \"row\" | \"column\";\n\nconst LOCATION_KEY_FOR_DIRECTION: Record = {\n row: \"row\",\n column: \"col\",\n};\n\nconst OPPOSITE_SIDE: Record = {\n left: \"right\",\n right: \"left\",\n top: \"bottom\",\n bottom: \"top\",\n};\nconst FLEX_DIRECTION_FOR_SIDE: Record = {\n left: \"column\",\n right: \"column\",\n top: \"row\",\n bottom: \"row\",\n};\nconst CROSS_DIRECTION_FOR_SIDE: Record = {\n left: \"row\",\n right: \"row\",\n top: \"column\",\n bottom: \"column\",\n};\nexport const SIZE_FOR_DIRECTION: Record = {\n row: \"width\",\n column: \"height\",\n};\nconst BEGIN_SIDE_FOR_DIRECTION: Record = {\n row: \"left\",\n column: \"top\",\n};\nconst END_SIDE_FOR_DIRECTION: Record = {\n row: \"right\",\n column: \"bottom\",\n};\nconst MARGIN_FOR_SIDE: Record<\n Side,\n \"marginLeft\" | \"marginRight\" | \"marginTop\" | \"marginBottom\"\n> = {\n left: \"marginLeft\",\n right: \"marginRight\",\n top: \"marginTop\",\n bottom: \"marginBottom\",\n};\nconst OUTWARDS_SIGN_FOR_SIDE: Record = {\n left: -1,\n right: +1,\n top: -1,\n bottom: +1,\n};\n\nexport class SidePanel extends RefCounted {\n element: HTMLElement = document.createElement(\"div\");\n visibility = new WatchableVisibilityPriority(\n WatchableVisibilityPriority.VISIBLE,\n );\n constructor(\n public sidePanelManager: SidePanelManager,\n public location: TrackableSidePanelLocation = new TrackableSidePanelLocation(),\n ) {\n super();\n const { element } = this;\n element.classList.add(\"neuroglancer-side-panel\");\n element.draggable = true;\n element.addEventListener(\"dragstart\", (event: DragEvent) => {\n this.sidePanelManager.startDrag(this.makeDragSource(), event);\n element.style.backgroundColor = \"black\";\n setTimeout(() => {\n element.style.backgroundColor = \"\";\n }, 0);\n pushDragStatus(element, \"drag\", () => {\n return document.createTextNode(\n \"Drag side panel to move it to the left/right/top/bottom of another panel\",\n );\n });\n });\n element.addEventListener(\"dragend\", (event: DragEvent) => {\n event;\n this.sidePanelManager.endDrag();\n popDragStatus(element, \"drag\");\n });\n }\n\n makeDragSource(): DragSource {\n return {\n dropAsNewPanel: (location) => {\n const oldLocation = this.location.value;\n this.location.value = { ...oldLocation, ...location };\n this.location.locationChanged.dispatch();\n },\n };\n }\n\n close() {\n this.location.visible = false;\n }\n\n addTitleBar(options: { title?: string }) {\n const titleBar = document.createElement(\"div\");\n titleBar.classList.add(\"neuroglancer-side-panel-titlebar\");\n const { title } = options;\n let titleElement: HTMLElement | undefined;\n if (title !== undefined) {\n titleElement = document.createElement(\"div\");\n titleElement.classList.add(\"neuroglancer-side-panel-title\");\n titleElement.textContent = title;\n titleBar.appendChild(titleElement);\n }\n const closeButton = makeCloseButton({\n title: \"Close panel\",\n onClick: () => {\n this.close();\n },\n });\n closeButton.style.order = \"100\";\n titleBar.appendChild(closeButton);\n this.element.appendChild(titleBar);\n return { titleBar, titleElement, closeButton };\n }\n\n addBody(body: HTMLElement) {\n body.draggable = true;\n body.addEventListener(\"dragstart\", (event: DragEvent) => {\n event.preventDefault();\n event.stopPropagation();\n });\n this.element.appendChild(body);\n }\n}\n\ninterface SidePanelCell {\n registeredPanel: RegisteredSidePanel;\n gutterElement: HTMLElement | undefined;\n}\n\ninterface SidePanelFlex {\n element: HTMLElement;\n visible: boolean;\n crossSize: number;\n // Maximum minWidth over all visible panels in the column.\n minSize: number;\n gutterElement: HTMLElement;\n cells: SidePanelCell[];\n\n beginDropZone: HTMLElement;\n endDropZone: HTMLElement;\n}\n\ninterface SidePanelSideState {\n flexGroups: SidePanelFlex[];\n outerDropZoneElement: HTMLElement;\n}\n\nexport interface SidePanelDropLocation {\n side: Side;\n row: number;\n col: number;\n}\n\nexport interface DragSource {\n canDropAsTabs?: (target: SidePanel) => number;\n dropAsTab?: (target: SidePanel) => void;\n dropAsNewPanel: (location: SidePanelDropLocation) => void;\n}\n\nexport interface RegisteredSidePanel {\n location: TrackableSidePanelLocation;\n makePanel: () => SidePanel;\n panel?: SidePanel | undefined;\n}\n\nexport class SidePanelManager extends RefCounted {\n public element = document.createElement(\"div\");\n public centerColumn = document.createElement(\"div\");\n beforeRender = new Signal();\n private sides: Record = {\n left: this.makeSidePanelSideState(\"left\"),\n right: this.makeSidePanelSideState(\"right\"),\n top: this.makeSidePanelSideState(\"top\"),\n bottom: this.makeSidePanelSideState(\"bottom\"),\n };\n private registeredPanels = new Set();\n dragSource: DragSource | undefined;\n private layoutNeedsUpdate = false;\n\n get visible() {\n return this.visibility.visible;\n }\n constructor(\n public display: DisplayContext,\n public center: HTMLElement,\n public visibility = new WatchableVisibilityPriority(\n WatchableVisibilityPriority.VISIBLE,\n ),\n ) {\n super();\n const { element, centerColumn } = this;\n element.style.display = \"flex\";\n element.style.flex = \"1\";\n element.style.flexDirection = \"row\";\n centerColumn.style.display = \"flex\";\n centerColumn.style.flex = \"1\";\n centerColumn.style.flexDirection = \"column\";\n centerColumn.style.flexBasis = \"0px\";\n centerColumn.style.minWidth = \"0px\";\n this.render();\n this.registerDisposer(\n display.updateStarted.add(() => {\n this.beforeRender.dispatch();\n if (!this.layoutNeedsUpdate) return;\n this.render();\n // Changing the side panel layout can affect the bounds of rendered panels as well.\n ++display.resizeGeneration;\n }),\n );\n this.registerDisposer(this.visibility.changed.add(this.invalidateLayout));\n }\n private makeSidePanelSideState(side: Side): SidePanelSideState {\n return {\n flexGroups: [],\n outerDropZoneElement: this.makeDropZone(\n side,\n /*crossIndex=*/ OUTWARDS_SIGN_FOR_SIDE[side] * Infinity,\n /*flexIndex=*/ 0,\n /*zoneSide=*/ side,\n /*centered=*/ false,\n ),\n };\n }\n\n hasDroppablePanel() {\n return this.dragSource !== undefined;\n }\n\n startDrag(dragSource: DragSource, event: DragEvent) {\n // Use setTimeout to set the attribute that enables the drop zones, rather than setting it\n // synchronously, as otherwise Chrome sometimes fires dragend immediately.\n //\n // https://stackoverflow.com/questions/14203734/dragend-dragenter-and-dragleave-firing-off-immediately-when-i-drag\n setTimeout(() => {\n if (this.dragSource === dragSource) {\n this.element.dataset.neuroglancerSidePanelDrag = \"true\";\n }\n }, 0);\n this.dragSource = dragSource;\n event.stopPropagation();\n event.dataTransfer!.setData(\"neuroglancer-side-panel\", \"\");\n }\n\n endDrag() {\n delete this.element.dataset.neuroglancerSidePanelDrag;\n this.dragSource = undefined;\n }\n\n private makeDropZone(\n side: Side,\n crossIndex: number,\n flexIndex: number,\n zoneSide: Side,\n centered = false,\n ): HTMLElement {\n const element = document.createElement(\"div\");\n element.className = \"neuroglancer-side-panel-drop-zone\";\n const size = 10;\n const zoneFlexDirection = FLEX_DIRECTION_FOR_SIDE[zoneSide];\n const zoneCrossDirection = CROSS_DIRECTION_FOR_SIDE[zoneSide];\n element.style[SIZE_FOR_DIRECTION[zoneCrossDirection]] = `${size}px`;\n element.style[SIZE_FOR_DIRECTION[zoneFlexDirection]] = \"100%\";\n if (centered) {\n element.style.position = \"absolute\";\n element.style[zoneSide] = \"50%\";\n element.style[MARGIN_FOR_SIDE[zoneSide]] = \"-${size/2}px\";\n } else {\n element.style.position = \"relative\";\n element.style[MARGIN_FOR_SIDE[OPPOSITE_SIDE[zoneSide]]] = `-${size}px`;\n }\n element.addEventListener(\"dragenter\", (event) => {\n if (!this.hasDroppablePanel()) return;\n element.classList.add(DRAG_OVER_CLASSNAME);\n event.preventDefault();\n pushDragStatus(element, \"drop\", () =>\n document.createTextNode(`Drop side panel as new ${zoneFlexDirection}`),\n );\n });\n element.addEventListener(\"dragleave\", () => {\n popDragStatus(element, \"drop\");\n element.classList.remove(DRAG_OVER_CLASSNAME);\n });\n element.addEventListener(\"dragover\", (event) => {\n if (!this.hasDroppablePanel()) return;\n event.preventDefault();\n });\n element.addEventListener(\"drop\", (event) => {\n const { dragSource } = this;\n if (dragSource === undefined) return;\n popDragStatus(element, \"drop\");\n element.classList.remove(DRAG_OVER_CLASSNAME);\n const flexDirection = FLEX_DIRECTION_FOR_SIDE[side];\n dragSource.dropAsNewPanel({\n side,\n row: flexDirection === \"column\" ? flexIndex : crossIndex,\n col: flexDirection === \"row\" ? flexIndex : crossIndex,\n });\n this.dragSource = undefined;\n event.preventDefault();\n event.stopPropagation();\n });\n return element;\n }\n\n registerPanel(registeredPanel: RegisteredSidePanel) {\n this.registeredPanels.add(registeredPanel);\n this.invalidateLayout();\n registeredPanel.location.locationChanged.add(this.invalidateLayout);\n return () => {\n this.unregisterPanel(registeredPanel);\n };\n }\n\n unregisterPanel(registeredPanel: RegisteredSidePanel) {\n this.registeredPanels.delete(registeredPanel);\n registeredPanel.location.locationChanged.remove(this.invalidateLayout);\n registeredPanel.panel?.dispose();\n this.invalidateLayout();\n }\n\n disposed() {\n for (const { panel } of this.registeredPanels) {\n panel?.dispose();\n }\n super.disposed();\n }\n\n invalidateLayout = () => {\n this.layoutNeedsUpdate = true;\n this.display.scheduleRedraw();\n };\n\n render() {\n this.layoutNeedsUpdate = false;\n const sides: Record = {\n left: [],\n right: [],\n top: [],\n bottom: [],\n };\n for (const panel of this.registeredPanels) {\n sides[panel.location.value.side].push(panel);\n }\n const getSideChildren = (side: Side) =>\n this.renderSide(side, this.sides[side].flexGroups, sides[side]);\n const self = this;\n function* getRowChildren() {\n yield self.sides.left.outerDropZoneElement;\n yield* getSideChildren(\"left\");\n yield self.centerColumn;\n yield* getSideChildren(\"right\");\n yield self.sides.right.outerDropZoneElement;\n }\n updateChildren(this.element, getRowChildren());\n function* getColumnChildren() {\n yield self.sides.top.outerDropZoneElement;\n yield* getSideChildren(\"top\");\n yield self.center;\n yield* getSideChildren(\"bottom\");\n yield self.sides.bottom.outerDropZoneElement;\n }\n updateChildren(this.centerColumn, getColumnChildren());\n }\n\n private makeCrossGutter(side: Side, crossIndex: number) {\n const gutter = document.createElement(\"div\");\n gutter.style.position = \"relative\";\n const direction = CROSS_DIRECTION_FOR_SIDE[side];\n gutter.className = `neuroglancer-resize-gutter-${\n direction === \"row\" ? \"horizontal\" : \"vertical\"\n }`;\n gutter.addEventListener(\"pointerdown\", (event) => {\n if (\"button\" in event && event.button !== 0) {\n return;\n }\n event.preventDefault();\n const flexGroup = this.sides[side].flexGroups[crossIndex];\n if (flexGroup === undefined || !flexGroup.visible) return;\n // Get initial size\n const initialRect = flexGroup.element.getBoundingClientRect();\n let size = initialRect[SIZE_FOR_DIRECTION[direction]];\n const minSize = flexGroup.minSize;\n const updateMessage = () => {\n pushDragStatus(\n gutter,\n \"drag\",\n `Drag to resize, current ${SIZE_FOR_DIRECTION[direction]} is ${flexGroup.crossSize}px`,\n );\n };\n updateMessage();\n startRelativeMouseDrag(\n event,\n (_event, deltaX: number, deltaY: number) => {\n const delta = direction === \"row\" ? deltaX : deltaY;\n size -= OUTWARDS_SIGN_FOR_SIDE[side] * delta;\n flexGroup.crossSize = Math.max(minSize, Math.round(size));\n updateMessage();\n this.invalidateLayout();\n },\n () => {\n popDragStatus(gutter, \"drag\");\n },\n );\n });\n const dropZone = this.makeDropZone(\n side,\n crossIndex - OUTWARDS_SIGN_FOR_SIDE[side] * 0.5,\n /*flexIndex=*/ 0,\n /*zoneSide=*/ side,\n /*centered=*/ true,\n );\n gutter.appendChild(dropZone);\n return gutter;\n }\n\n private makeFlexGutter(side: Side, crossIndex: number, flexIndex: number) {\n const gutter = document.createElement(\"div\");\n gutter.style.position = \"relative\";\n const direction = FLEX_DIRECTION_FOR_SIDE[side];\n gutter.className = `neuroglancer-resize-gutter-${\n direction === \"row\" ? \"horizontal\" : \"vertical\"\n }`;\n gutter.addEventListener(\"pointerdown\", (event) => {\n if (\"button\" in event && event.button !== 0) {\n return;\n }\n event.preventDefault();\n const flexGroup = this.sides[side].flexGroups[crossIndex];\n if (flexGroup === undefined || !flexGroup.visible) return;\n const { cells } = flexGroup;\n const cell = cells[flexIndex];\n if (cell === undefined || !cell.registeredPanel.location.visible) return;\n // Determine the cell index of the next visible panel.\n let nextFlexIndex = flexIndex + 1;\n while (\n nextFlexIndex < cells.length &&\n !cells[nextFlexIndex].registeredPanel.location.visible\n ) {\n ++nextFlexIndex;\n }\n if (nextFlexIndex === cells.length) return;\n const nextCell = cells[nextFlexIndex];\n const updateMessage = () => {\n pushDragStatus(\n gutter,\n \"drag\",\n `Drag to resize, current ${SIZE_FOR_DIRECTION[direction]} ratio is ` +\n `${cell.registeredPanel.location.value.flex} : ` +\n `${nextCell.registeredPanel.location.value.flex}`,\n );\n };\n updateMessage();\n startRelativeMouseDrag(\n event,\n (newEvent) => {\n const firstPanel = cell.registeredPanel.panel;\n const secondPanel = nextCell.registeredPanel.panel;\n if (firstPanel === undefined || secondPanel === undefined) return;\n const firstRect = firstPanel.element.getBoundingClientRect();\n const secondRect = secondPanel.element.getBoundingClientRect();\n const firstFraction = Math.max(\n 0.1,\n Math.min(\n 0.9,\n direction === \"column\"\n ? (newEvent.clientY - firstRect.top) /\n (secondRect.bottom - firstRect.top)\n : (newEvent.clientX - firstRect.left) /\n (secondRect.right - firstRect.left),\n ),\n );\n const firstLocation = cell.registeredPanel.location.value;\n const secondLocation = nextCell.registeredPanel.location.value;\n const existingFlexSum = firstLocation.flex + secondLocation.flex;\n cell.registeredPanel.location.value = {\n ...firstLocation,\n flex: Math.round(firstFraction * existingFlexSum * 100) / 100,\n };\n nextCell.registeredPanel.location.value = {\n ...secondLocation,\n flex: Math.round((1 - firstFraction) * existingFlexSum * 100) / 100,\n };\n updateMessage();\n cell.registeredPanel.location.locationChanged.dispatch();\n nextCell.registeredPanel.location.locationChanged.dispatch();\n this.invalidateLayout();\n },\n () => {\n popDragStatus(gutter, \"drag\");\n },\n );\n });\n const dropZone = this.makeDropZone(\n side,\n crossIndex,\n /*flexIndex=*/ flexIndex + 0.5,\n /*zoneSide=*/ BEGIN_SIDE_FOR_DIRECTION[FLEX_DIRECTION_FOR_SIDE[side]],\n /*centered=*/ true,\n );\n gutter.appendChild(dropZone);\n return gutter;\n }\n\n private renderSide(\n side: Side,\n flexGroups: SidePanelFlex[],\n panels: RegisteredSidePanel[],\n ) {\n const flexKey = LOCATION_KEY_FOR_DIRECTION[CROSS_DIRECTION_FOR_SIDE[side]];\n const crossKey = LOCATION_KEY_FOR_DIRECTION[FLEX_DIRECTION_FOR_SIDE[side]];\n panels.sort((a, b) => {\n const aLoc = a.location.value;\n const bLoc = b.location.value;\n const crossDiff = aLoc[crossKey] - bLoc[crossKey];\n if (crossDiff !== 0) return crossDiff;\n return aLoc[flexKey] - bLoc[flexKey];\n });\n const self = this;\n function* getFlexGroups() {\n let panelIndex = 0;\n const numPanels = panels.length;\n let crossIndex = 0;\n while (panelIndex < numPanels) {\n const origCrossIndex = panels[panelIndex].location.value[crossKey];\n let endPanelIndex = panelIndex;\n let numVisible = 0;\n let minSize = 0;\n do {\n const location = panels[endPanelIndex].location.value;\n if (location[crossKey] !== origCrossIndex) break;\n if (location.visible) {\n ++numVisible;\n minSize = Math.max(minSize, location.minSize);\n }\n ++endPanelIndex;\n } while (endPanelIndex < numPanels);\n const visible = numVisible > 0;\n let flexGroup = flexGroups[crossIndex];\n if (flexGroup === undefined) {\n const gutter = self.makeCrossGutter(side, crossIndex);\n const flexGroupElement = document.createElement(\"div\");\n flexGroupElement.className = `neuroglancer-side-panel-${FLEX_DIRECTION_FOR_SIDE[side]}`;\n flexGroup = flexGroups[crossIndex] = {\n element: flexGroupElement,\n gutterElement: gutter,\n cells: [],\n crossSize: -1,\n minSize,\n visible,\n beginDropZone: self.makeDropZone(\n side,\n crossIndex,\n /*flexIndex=*/ -Infinity,\n BEGIN_SIDE_FOR_DIRECTION[FLEX_DIRECTION_FOR_SIDE[side]],\n ),\n endDropZone: self.makeDropZone(\n side,\n crossIndex,\n /*flexIndex=*/ +Infinity,\n END_SIDE_FOR_DIRECTION[FLEX_DIRECTION_FOR_SIDE[side]],\n ),\n };\n } else {\n flexGroup.visible = visible;\n flexGroup.minSize = minSize;\n flexGroup.crossSize = Math.max(flexGroup.crossSize, minSize);\n }\n function* getCells() {\n yield flexGroup.beginDropZone;\n let prevVisible = 0;\n for (\n let i = panelIndex, flexIndex = 0;\n i < endPanelIndex;\n ++i, ++flexIndex\n ) {\n const registeredPanel = panels[i];\n let cell = flexGroup.cells[flexIndex];\n if (cell === undefined) {\n cell = flexGroup.cells[flexIndex] = {\n registeredPanel,\n gutterElement: undefined,\n };\n } else {\n cell.registeredPanel = registeredPanel;\n }\n const oldLocation = cell.registeredPanel.location.value;\n if (flexGroup.crossSize === -1) {\n flexGroup.crossSize = Math.max(minSize, oldLocation.size);\n }\n if (\n oldLocation[crossKey] !== crossIndex ||\n oldLocation[flexKey] !== flexIndex ||\n (oldLocation.visible && oldLocation.size !== flexGroup.crossSize)\n ) {\n cell.registeredPanel.location.value = {\n ...oldLocation,\n [crossKey]: crossIndex,\n [flexKey]: flexIndex,\n size: oldLocation.visible\n ? flexGroup.crossSize\n : oldLocation.size,\n };\n cell.registeredPanel.location.changed.dispatch();\n }\n const visible = oldLocation.visible && self.visibility.visible;\n let { panel } = registeredPanel;\n if (!visible) {\n if (panel !== undefined) {\n panel.dispose();\n registeredPanel.panel = undefined;\n }\n continue;\n }\n ++prevVisible;\n if (panel === undefined) {\n panel = registeredPanel.panel = registeredPanel.makePanel();\n }\n panel.element.style.flex =\n numVisible > 1 ? `${oldLocation.flex}` : \"1\";\n yield panel.element;\n if (prevVisible === numVisible) {\n // Last cell does not need its own resize gutter.\n cell.gutterElement = undefined;\n } else {\n if (cell.gutterElement === undefined) {\n cell.gutterElement = self.makeFlexGutter(\n side,\n crossIndex,\n flexIndex,\n );\n }\n yield cell.gutterElement;\n }\n }\n yield flexGroup.endDropZone;\n }\n updateChildren(flexGroup.element, getCells());\n flexGroup.cells.length = endPanelIndex - panelIndex;\n if (visible) {\n flexGroup.element.style[\n SIZE_FOR_DIRECTION[CROSS_DIRECTION_FOR_SIDE[side]]\n ] = `${flexGroup.crossSize}px`;\n if (OUTWARDS_SIGN_FOR_SIDE[side] > 0) {\n yield flexGroup.gutterElement;\n yield flexGroup.element;\n } else {\n yield flexGroup.element;\n yield flexGroup.gutterElement;\n }\n }\n panelIndex = endPanelIndex;\n ++crossIndex;\n }\n flexGroups.length = crossIndex;\n }\n return getFlexGroups();\n }\n}\n","/**\n * @license\n * Copyright 2020 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { MakeIconOptions } from \"#src/widget/icon.js\";\nimport { makeIcon } from \"#src/widget/icon.js\";\n\nexport function makeMoveToButton(options: MakeIconOptions = {}) {\n return makeIcon({ text: \"↗\", ...options });\n}\n","/**\n * @license\n * Copyright 2020 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport \"#src/ui/selection_details.css\";\n\nimport svg_arrowLeft from \"ikonate/icons/arrow-left.svg?raw\";\nimport svg_arrowRight from \"ikonate/icons/arrow-right.svg?raw\";\nimport type {\n SelectedLayerState,\n TopLevelLayerListSpecification,\n TrackableDataSelectionState,\n} from \"#src/layer/index.js\";\nimport { getDefaultSelectBindings } from \"#src/ui/default_input_event_bindings.js\";\nimport type { SidePanelManager } from \"#src/ui/side_panel.js\";\nimport { SidePanel } from \"#src/ui/side_panel.js\";\nimport { setClipboard } from \"#src/util/clipboard.js\";\nimport type { Borrowed } from \"#src/util/disposable.js\";\nimport { MouseEventBinder } from \"#src/util/mouse_bindings.js\";\nimport { CheckboxIcon } from \"#src/widget/checkbox_icon.js\";\nimport { makeCopyButton } from \"#src/widget/copy_button.js\";\nimport { DependentViewWidget } from \"#src/widget/dependent_view_widget.js\";\nimport { makeIcon } from \"#src/widget/icon.js\";\nimport { makeMoveToButton } from \"#src/widget/move_to_button.js\";\n\nexport function isWithinSelectionPanel(element: HTMLElement) {\n return element.closest(\".neuroglancer-selection-details\");\n}\n\nexport class SelectionDetailsPanel extends SidePanel {\n body = document.createElement(\"div\");\n\n constructor(\n public sidePanelManager: SidePanelManager,\n public state: Borrowed,\n public manager: Borrowed,\n public selectedLayer: Borrowed,\n ) {\n super(sidePanelManager, state.location);\n const { element, body } = this;\n element.classList.add(\"neuroglancer-selection-details\");\n this.registerDisposer(\n new MouseEventBinder(this.element, getDefaultSelectBindings()),\n );\n\n const { titleBar } = this.addTitleBar({ title: \"Selection\" });\n const backButton = makeIcon({\n svg: svg_arrowLeft,\n title: \"Previous selection\",\n onClick: () => {\n this.state.goBack();\n },\n });\n const forwardButton = makeIcon({\n svg: svg_arrowRight,\n title: \"Next selection\",\n onClick: () => {\n this.state.goForward();\n },\n });\n titleBar.appendChild(backButton);\n titleBar.appendChild(forwardButton);\n titleBar.appendChild(\n this.registerDisposer(\n new CheckboxIcon(state.pin, {\n // Note: \\ufe0e forces text display, as otherwise the pin icon may as an emoji with\n // color.\n text: \"📌\\ufe0e\",\n enableTitle: \"Pin selection\",\n disableTitle: \"Unpin selection\",\n }),\n ).element,\n );\n body.classList.add(\"neuroglancer-selection-details-body\");\n this.addBody(body);\n body.appendChild(\n this.registerDisposer(\n new DependentViewWidget(state, (stateValue, parent, context) => {\n if (!state.location.visible) return;\n backButton.style.visibility = state.canGoBack()\n ? \"visible\"\n : \"hidden\";\n forwardButton.style.visibility = state.canGoForward()\n ? \"visible\"\n : \"hidden\";\n if (stateValue === undefined) return;\n\n // Add position\n const { position } = stateValue;\n if (position !== undefined) {\n const positionElement = document.createElement(\"div\");\n positionElement.classList.add(\n \"neuroglancer-selection-details-position\",\n );\n const copyButton = makeCopyButton({\n title: \"Copy position\",\n onClick: () => {\n setClipboard(position!.map((x) => Math.floor(x)).join(\", \"));\n },\n });\n positionElement.appendChild(copyButton);\n const {\n coordinateSpace: { rank, names },\n position,\n } = stateValue;\n for (let i = 0; i < rank; ++i) {\n const dimElement = document.createElement(\"span\");\n dimElement.classList.add(\n \"neuroglancer-selection-details-position-dimension\",\n );\n const nameElement = document.createElement(\"span\");\n nameElement.classList.add(\n \"neuroglancer-selection-details-position-dimension-name\",\n );\n nameElement.textContent = names[i];\n const coordinateElement = document.createElement(\"span\");\n coordinateElement.classList.add(\n \"neuroglancer-selection-details-position-dimension-coordinate\",\n );\n coordinateElement.textContent = Math.floor(\n position![i],\n ).toString();\n dimElement.appendChild(nameElement);\n dimElement.appendChild(coordinateElement);\n positionElement.appendChild(dimElement);\n }\n const moveToButton = makeMoveToButton({\n title: \"Move to position\",\n onClick: () => {\n this.manager.globalPosition.value = position!;\n },\n });\n positionElement.appendChild(moveToButton);\n parent.appendChild(positionElement);\n }\n\n for (const layerData of stateValue.layers) {\n const { layer } = layerData;\n parent.appendChild(\n context.registerDisposer(\n new DependentViewWidget(\n {\n value: undefined,\n changed: layer.managedLayer.layerChanged,\n },\n (_, parent, context) => {\n if (layer.wasDisposed) return;\n if (!layer.isReady) {\n return;\n }\n const layerBody = document.createElement(\"div\");\n layerBody.classList.add(\n \"neuroglancer-selection-details-layer-body\",\n );\n if (\n !layer.displaySelectionState(\n layerData.state,\n layerBody,\n context,\n )\n ) {\n return;\n }\n const layerElement = document.createElement(\"div\");\n parent.appendChild(layerElement);\n layerElement.classList.add(\n \"neuroglancer-selection-details-layer\",\n );\n const layerTitle = document.createElement(\"div\");\n layerTitle.classList.add(\n \"neuroglancer-selection-details-layer-title\",\n );\n layerTitle.textContent = layer.managedLayer.name;\n layerTitle.addEventListener(\"click\", () => {\n this.selectedLayer.layer = layer.managedLayer;\n this.selectedLayer.visible = true;\n });\n layerTitle.title = \"Click to show layer side panel\";\n layerElement.appendChild(layerTitle);\n layerElement.appendChild(layerBody);\n },\n ),\n ).element,\n );\n }\n }),\n ).element,\n );\n }\n\n close() {\n super.close();\n this.state.value = undefined;\n this.state.pin.value = true;\n }\n}\n","/**\n * @license\n * Copyright 2023 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport \"#src/widget/eye_button.css\";\n\nimport svg_eye_crossed from \"ikonate/icons/eye-crossed.svg?raw\";\nimport type { MakeIconOptions } from \"#src/widget/icon.js\";\nimport { makeIcon } from \"#src/widget/icon.js\";\n\nexport function makeEyeButton(options: MakeIconOptions = {}) {\n const icon = makeIcon({ svg: svg_eye_crossed, ...options });\n icon.classList.add(\"neuroglancer-eye-icon\");\n return icon;\n}\n","/**\n * @license\n * Copyright 2020 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport svg_filter from \"ikonate/icons/filter.svg?raw\";\nimport type { MakeIconOptions } from \"#src/widget/icon.js\";\nimport { makeIcon } from \"#src/widget/icon.js\";\n\nexport function makeFilterButton(options: MakeIconOptions = {}) {\n return makeIcon({ svg: svg_filter, ...options });\n}\n","/**\n * @license\n * Copyright 2019 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport \"#src/widget/star_button.css\";\n\nimport svg_star from \"ikonate/icons/star.svg?raw\";\nimport type { MakeIconOptions } from \"#src/widget/icon.js\";\nimport { makeIcon } from \"#src/widget/icon.js\";\n\nexport function makeStarButton(options: MakeIconOptions = {}) {\n const icon = makeIcon({ svg: svg_star, ...options });\n icon.classList.add(\"neuroglancer-star-icon\");\n return icon;\n}\n","/**\n * @license\n * Copyright 2016 Google Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { LayerChunkProgressInfo } from \"#src/chunk_manager/base.js\";\nimport type { ChunkManager } from \"#src/chunk_manager/frontend.js\";\nimport { ChunkRenderLayerFrontend } from \"#src/chunk_manager/frontend.js\";\nimport type { LayerSelectedValues } from \"#src/layer/index.js\";\nimport type { SegmentationUserLayer } from \"#src/layer/segmentation/index.js\";\nimport type { PickIDManager } from \"#src/object_picking.js\";\nimport type { WatchableRenderLayerTransform } from \"#src/render_coordinate_transform.js\";\nimport type { RenderScaleHistogram } from \"#src/render_scale_statistics.js\";\nimport type { RenderLayer } from \"#src/renderlayer.js\";\nimport type { SegmentColorHash } from \"#src/segment_color.js\";\nimport { getCssColor } from \"#src/segment_color.js\";\nimport type { VisibleSegmentsState } from \"#src/segmentation_display_state/base.js\";\nimport {\n forEachVisibleSegment,\n onTemporaryVisibleSegmentsStateChanged,\n onVisibleSegmentsStateChanged,\n VISIBLE_SEGMENTS_STATE_PROPERTIES,\n} from \"#src/segmentation_display_state/base.js\";\nimport type {\n InlineSegmentNumericalProperty,\n InlineSegmentProperty,\n PreprocessedSegmentPropertyMap,\n} from \"#src/segmentation_display_state/property_map.js\";\nimport { SharedWatchableValue } from \"#src/shared_watchable_value.js\";\nimport type { TrackableAlphaValue } from \"#src/trackable_alpha.js\";\nimport type {\n TrackableValue,\n WatchableValueInterface,\n} from \"#src/trackable_value.js\";\nimport { observeWatchable, registerNestedSync } from \"#src/trackable_value.js\";\nimport { isWithinSelectionPanel } from \"#src/ui/selection_details.js\";\nimport type { Uint64Map } from \"#src/uint64_map.js\";\nimport { setClipboard } from \"#src/util/clipboard.js\";\nimport {\n packColor,\n serializeColor,\n TrackableRGB,\n useWhiteBackground,\n} from \"#src/util/color.js\";\nimport { RefCounted } from \"#src/util/disposable.js\";\nimport { measureElementClone } from \"#src/util/dom.js\";\nimport { kOneVec, vec3, vec4 } from \"#src/util/geom.js\";\nimport { NullarySignal } from \"#src/util/signal.js\";\nimport { Uint64 } from \"#src/util/uint64.js\";\nimport { withSharedVisibility } from \"#src/visibility_priority/frontend.js\";\nimport { ColorWidget } from \"#src/widget/color.js\";\nimport { makeCopyButton } from \"#src/widget/copy_button.js\";\nimport { makeEyeButton } from \"#src/widget/eye_button.js\";\nimport { makeFilterButton } from \"#src/widget/filter_button.js\";\nimport { makeStarButton } from \"#src/widget/star_button.js\";\n\nexport class Uint64MapEntry {\n constructor(\n public key: Uint64,\n public value?: Uint64,\n public label?: string | undefined,\n ) {}\n toString() {\n const { key, value, label } = this;\n let baseString: string;\n if (value === undefined) {\n baseString = `${key}`;\n } else {\n baseString = `${key}→${value}`;\n }\n if (label === undefined) return baseString;\n return `${baseString} ${label}`;\n }\n}\n\nexport class SegmentSelectionState extends RefCounted {\n selectedSegment = new Uint64();\n baseSelectedSegment = new Uint64();\n hasSelectedSegment = false;\n changed = new NullarySignal();\n\n get value() {\n return this.hasSelectedSegment ? this.selectedSegment : undefined;\n }\n\n get baseValue() {\n return this.hasSelectedSegment ? this.baseSelectedSegment : undefined;\n }\n\n set(\n value: number | Uint64MapEntry | Uint64 | null | undefined,\n hideSegmentZero = false,\n ) {\n const { selectedSegment, baseSelectedSegment } = this;\n let newLow = 0;\n let newHigh = 0;\n let newBaseLow = 0;\n let newBaseHigh = 0;\n let hasSelectedSegment: boolean;\n if (value == null) {\n hasSelectedSegment = false;\n } else if (typeof value === \"number\") {\n newLow = newBaseLow = value >>> 0;\n newHigh = newBaseHigh = value < 0 ? 0xffffffff : 0;\n hasSelectedSegment = true;\n } else if (value instanceof Uint64MapEntry) {\n const valueMapped = value.value || value.key;\n newLow = valueMapped.low;\n newHigh = valueMapped.high;\n newBaseLow = value.key.low;\n newBaseHigh = value.key.high;\n hasSelectedSegment = true;\n } else if (value instanceof Uint64) {\n newLow = newBaseLow = value.low;\n newHigh = newBaseHigh = value.high;\n hasSelectedSegment = true;\n } else {\n hasSelectedSegment = false;\n }\n if (hideSegmentZero && newLow === 0 && newHigh === 0) {\n hasSelectedSegment = false;\n }\n if (!hasSelectedSegment) {\n if (this.hasSelectedSegment) {\n this.hasSelectedSegment = false;\n this.changed.dispatch();\n }\n } else if (\n hasSelectedSegment &&\n (!this.hasSelectedSegment ||\n selectedSegment.low !== newLow ||\n selectedSegment.high !== newHigh ||\n baseSelectedSegment.low !== newBaseLow ||\n baseSelectedSegment.high !== newBaseHigh)\n ) {\n selectedSegment.low = newLow;\n selectedSegment.high = newHigh;\n baseSelectedSegment.low = newBaseLow;\n baseSelectedSegment.high = newBaseHigh;\n this.hasSelectedSegment = true;\n this.changed.dispatch();\n }\n }\n\n isSelected(value: Uint64) {\n return this.hasSelectedSegment && Uint64.equal(value, this.selectedSegment);\n }\n\n bindTo(\n layerSelectedValues: LayerSelectedValues,\n userLayer: SegmentationUserLayer,\n ) {\n this.registerDisposer(\n layerSelectedValues.changed.add(() => {\n const state = layerSelectedValues.get(userLayer);\n let value: any = undefined;\n if (state !== undefined) {\n value = state.value;\n }\n this.set(\n value,\n userLayer.displayState.segmentationGroupState.value.hideSegmentZero\n .value,\n );\n }),\n );\n }\n}\n\nexport interface SegmentationGroupState extends VisibleSegmentsState {\n /**\n * Maximum length of base-10 representation of id seen.\n */\n maxIdLength: WatchableValueInterface;\n segmentPropertyMap: WatchableValueInterface<\n PreprocessedSegmentPropertyMap | undefined\n >;\n}\n\nexport interface SegmentationColorGroupState {\n segmentColorHash: SegmentColorHash;\n segmentStatedColors: Uint64Map;\n tempSegmentStatedColors2d: Uint64Map;\n segmentDefaultColor: WatchableValueInterface;\n tempSegmentDefaultColor2d: WatchableValueInterface;\n}\n\nexport interface SegmentationDisplayState {\n segmentSelectionState: SegmentSelectionState;\n saturation: TrackableAlphaValue;\n hoverHighlight: WatchableValueInterface;\n baseSegmentColoring: WatchableValueInterface;\n baseSegmentHighlighting: WatchableValueInterface;\n segmentationGroupState: WatchableValueInterface;\n segmentationColorGroupState: WatchableValueInterface;\n\n selectSegment: (id: Uint64, pin: boolean | \"toggle\") => void;\n filterBySegmentLabel: (id: Uint64) => void;\n moveToSegment: (id: Uint64) => void;\n\n // Indirect properties\n hideSegmentZero: WatchableValueInterface;\n segmentColorHash: WatchableValueInterface;\n segmentStatedColors: WatchableValueInterface;\n tempSegmentStatedColors2d: WatchableValueInterface;\n useTempSegmentStatedColors2d: WatchableValueInterface;\n segmentDefaultColor: WatchableValueInterface;\n tempSegmentDefaultColor2d: WatchableValueInterface;\n highlightColor: WatchableValueInterface;\n}\n\nexport function resetTemporaryVisibleSegmentsState(\n state: VisibleSegmentsState,\n) {\n state.useTemporarySegmentEquivalences.value = false;\n state.useTemporaryVisibleSegments.value = false;\n state.temporaryVisibleSegments.clear();\n state.temporarySegmentEquivalences.clear();\n}\n\n/// Converts a segment id to a Uint64MapEntry or Uint64 (if Uint64MapEntry would add no additional\n/// information).\nexport function maybeAugmentSegmentId(\n displayState: SegmentationDisplayState | undefined | null,\n value: number | Uint64,\n mustCopy = false,\n): Uint64 | Uint64MapEntry {\n let id: Uint64;\n let mappedValue: Uint64;\n let mapped: Uint64 | undefined;\n if (typeof value === \"number\") {\n id = new Uint64(value >>> 0, value < 0 ? 0xffffffff : 0);\n } else if (typeof value === \"string\") {\n id = Uint64.parseString(value);\n } else {\n id = mustCopy ? value.clone() : value;\n }\n if (displayState == null) return id;\n const {\n segmentEquivalences,\n segmentPropertyMap: { value: segmentPropertyMap },\n } = displayState.segmentationGroupState.value;\n if (segmentEquivalences.size !== 0) {\n mappedValue = segmentEquivalences.get(id);\n if (Uint64.equal(mappedValue, id)) {\n mapped = undefined;\n } else {\n mapped = mappedValue;\n }\n } else {\n mappedValue = id;\n }\n const label = segmentPropertyMap?.getSegmentLabel(mappedValue);\n if (label === undefined && mapped === undefined) {\n return id;\n }\n return new Uint64MapEntry(id, mapped, label);\n}\n\n/// Converts a plain segment id to a Uint64MapEntry.\nexport function augmentSegmentId(\n displayState: SegmentationDisplayState | undefined | null,\n value: number | Uint64 | Uint64MapEntry,\n): Uint64MapEntry {\n if (value instanceof Uint64MapEntry) return value;\n const newValue = maybeAugmentSegmentId(displayState, value);\n if (newValue instanceof Uint64) {\n return new Uint64MapEntry(newValue);\n }\n return newValue;\n}\n\nexport function updateIdStringWidth(\n idStringWidth: WatchableValueInterface,\n idString: string,\n) {\n const { length } = idString;\n if (idStringWidth.value < length) {\n idStringWidth.value = length;\n }\n}\n\nexport function bindSegmentListWidth(\n displayState: SegmentationDisplayState,\n element: HTMLElement,\n) {\n return observeWatchable(\n (width) =>\n element.style.setProperty(\n \"--neuroglancer-segment-list-width\",\n `${width}ch`,\n ),\n displayState.segmentationGroupState.value.maxIdLength,\n );\n}\n\nconst segmentWidgetTemplate = (() => {\n const template = document.createElement(\"div\");\n template.classList.add(\"neuroglancer-segment-list-entry\");\n const stickyContainer = document.createElement(\"div\");\n stickyContainer.classList.add(\"neuroglancer-segment-list-entry-sticky\");\n template.appendChild(stickyContainer);\n const copyButton = makeCopyButton({\n title: \"Copy segment ID\",\n });\n copyButton.classList.add(\"neuroglancer-segment-list-entry-copy\");\n const copyContainer = document.createElement(\"div\");\n copyContainer.classList.add(\"neuroglancer-segment-list-entry-copy-container\");\n const copyIndex = copyContainer.childElementCount;\n copyContainer.appendChild(copyButton);\n const copyContainerIndex = stickyContainer.childElementCount;\n stickyContainer.appendChild(copyContainer);\n const visibleIndex = stickyContainer.childElementCount;\n const visibleIcon = makeEyeButton({\n title: \"Toggle segment visibility\",\n });\n visibleIcon.classList.add(\"neuroglancer-segment-list-entry-visible-checkbox\");\n stickyContainer.appendChild(visibleIcon);\n const idContainer = document.createElement(\"div\");\n idContainer.classList.add(\"neuroglancer-segment-list-entry-id-container\");\n const idContainerIndex = stickyContainer.childElementCount;\n stickyContainer.appendChild(idContainer);\n const idElement = document.createElement(\"div\");\n idElement.classList.add(\"neuroglancer-segment-list-entry-id\");\n const idIndex = idContainer.childElementCount;\n idContainer.appendChild(idElement);\n const starButton = makeStarButton({\n title: \"Star segment\",\n });\n starButton.classList.add(\"neuroglancer-segment-list-entry-star\");\n const starIndex = stickyContainer.childElementCount;\n stickyContainer.appendChild(starButton);\n\n const nameElement = document.createElement(\"span\");\n nameElement.classList.add(\"neuroglancer-segment-list-entry-name\");\n const labelIndex = template.childElementCount;\n template.appendChild(nameElement);\n const filterElement = makeFilterButton({\n title: \"Filter by label\",\n });\n filterElement.classList.add(\"neuroglancer-segment-list-entry-filter\");\n const filterIndex = template.childElementCount;\n template.appendChild(filterElement);\n const colorWidgetIndex = template.childElementCount;\n template.appendChild(ColorWidget.template());\n return {\n template,\n copyContainerIndex,\n copyIndex,\n visibleIndex,\n idContainerIndex,\n idIndex,\n labelIndex,\n filterIndex,\n starIndex,\n colorWidgetIndex,\n unmappedIdIndex: -1,\n unmappedCopyIndex: -1,\n };\n})();\n\nconst segmentWidgetTemplateWithUnmapped = (() => {\n const t = segmentWidgetTemplate;\n const template = t.template.cloneNode(/*deep=*/ true) as HTMLDivElement;\n const stickyContainer = template.children[0] as HTMLElement;\n const idContainer = stickyContainer.children[\n t.idContainerIndex\n ] as HTMLElement;\n const unmappedIdIndex = idContainer.childElementCount;\n const unmappedIdElement = idContainer.children[t.idIndex].cloneNode(\n /*deep=*/ true,\n ) as HTMLElement;\n unmappedIdElement.classList.add(\n \"neuroglancer-segment-list-entry-unmapped-id\",\n );\n idContainer.appendChild(unmappedIdElement);\n const copyContainer = stickyContainer.children[\n t.copyContainerIndex\n ] as HTMLElement;\n const unmappedCopyIndex = copyContainer.childElementCount;\n copyContainer.appendChild(\n copyContainer.children[t.copyIndex].cloneNode(/*deep=*/ true),\n );\n return { ...t, template, unmappedIdIndex, unmappedCopyIndex };\n})();\n\nexport type SegmentWidgetTemplate = typeof segmentWidgetTemplate;\n\ninterface SegmentWidgetWithExtraColumnsTemplate extends SegmentWidgetTemplate {\n numericalPropertyIndices: number[];\n}\n\nexport function segmentWidgetTemplateWithExtraColumns(\n numExtraColumns: number,\n): SegmentWidgetWithExtraColumnsTemplate {\n const origTemplate = segmentWidgetTemplate;\n const templateElement = origTemplate.template.cloneNode(\n /*deep=*/ true,\n ) as HTMLDivElement;\n const numericalPropertyIndices: number[] = [];\n for (let i = 0; i < numExtraColumns; ++i) {\n numericalPropertyIndices.push(templateElement.childElementCount);\n const child = document.createElement(\"div\");\n child.classList.add(\"neuroglancer-segment-list-entry-extra-property\");\n child.style.width = `max(var(--neuroglancer-column-${i}-width), var(--neuroglancer-column-${i}-label-width))`;\n templateElement.appendChild(child);\n }\n return {\n ...origTemplate,\n template: templateElement,\n numericalPropertyIndices,\n };\n}\n\nconst cachedRegisterSegmentWidgetEventHandlers = new WeakMap<\n SegmentationDisplayState,\n (element: HTMLElement, template: SegmentWidgetTemplate) => void\n>();\n\nfunction makeRegisterSegmentWidgetEventHandlers(\n displayState: SegmentationDisplayState,\n) {\n const onMouseEnter = (event: Event) => {\n const entryElement = event.currentTarget as HTMLElement;\n const idString = entryElement.dataset.id!;\n const id = tempObjectId;\n id.tryParseString(idString);\n displayState.segmentSelectionState.set(id);\n if (!isWithinSelectionPanel(entryElement)) {\n displayState.selectSegment(id, false);\n }\n };\n\n const selectHandler = (event: Event) => {\n const entryElement = event.currentTarget as HTMLElement;\n const idString = entryElement.dataset.id!;\n const id = tempObjectId;\n id.tryParseString(idString);\n displayState.selectSegment(\n id,\n isWithinSelectionPanel(entryElement) ? \"toggle\" : true,\n );\n };\n\n const onMouseLeave = () => {\n displayState.segmentSelectionState.set(null);\n };\n\n const getEntryElement = (event: Event): HTMLElement => {\n return (event.currentTarget as HTMLElement).closest(\n \".neuroglancer-segment-list-entry\",\n ) as HTMLElement;\n };\n\n const copyHandler = (event: Event) => {\n const entryElement = getEntryElement(event);\n setClipboard(entryElement.dataset.id!);\n event.stopPropagation();\n };\n\n const unmappedCopyHandler = (event: Event) => {\n const entryElement = getEntryElement(event);\n setClipboard(entryElement.dataset.unmappedId!);\n event.stopPropagation();\n };\n\n const visibleCheckboxHandler = (event: Event) => {\n const entryElement = getEntryElement(event);\n const idString = entryElement.dataset.id!;\n const id = tempObjectId;\n id.tryParseString(idString);\n const { selectedSegments, visibleSegments } =\n displayState.segmentationGroupState.value;\n const shouldBeVisible = !visibleSegments.has(id);\n if (shouldBeVisible) {\n selectedSegments.add(id);\n }\n visibleSegments.set(id, shouldBeVisible);\n event.stopPropagation();\n event.preventDefault();\n };\n\n const filterHandler = (event: Event) => {\n const entryElement = getEntryElement(event);\n const idString = entryElement.dataset.id!;\n const id = tempObjectId;\n id.tryParseString(idString);\n displayState.filterBySegmentLabel(id);\n event.stopPropagation();\n };\n\n const onMousedown = (event: MouseEvent) => {\n if (\n event.button !== 2 ||\n event.ctrlKey ||\n event.altKey ||\n event.metaKey ||\n event.shiftKey\n ) {\n return;\n }\n const entryElement = event.currentTarget as HTMLElement;\n const idString = entryElement.dataset.id!;\n const id = tempObjectId;\n id.tryParseString(idString);\n displayState.moveToSegment(id);\n };\n\n return (element: HTMLElement, template: SegmentWidgetTemplate) => {\n const { children } = element;\n const stickyChildren = children[0].children;\n element.addEventListener(\"mousedown\", onMousedown);\n const copyContainer = stickyChildren[\n template.copyContainerIndex\n ] as HTMLElement;\n if (template.unmappedCopyIndex !== -1) {\n copyContainer.children[template.unmappedCopyIndex].addEventListener(\n \"click\",\n unmappedCopyHandler,\n );\n }\n copyContainer.children[template.copyIndex].addEventListener(\n \"click\",\n copyHandler,\n );\n element.addEventListener(\"mouseenter\", onMouseEnter);\n element.addEventListener(\"mouseleave\", onMouseLeave);\n stickyChildren[template.visibleIndex].addEventListener(\n \"click\",\n visibleCheckboxHandler,\n );\n children[template.filterIndex].addEventListener(\"click\", filterHandler);\n element.addEventListener(\"action:select-position\", selectHandler);\n\n const starButton = stickyChildren[template.starIndex] as HTMLElement;\n starButton.addEventListener(\"click\", (event: MouseEvent) => {\n const entryElement = getEntryElement(event);\n const idString = entryElement.dataset.id!;\n const id = tempObjectId;\n id.tryParseString(idString);\n const { selectedSegments } = displayState.segmentationGroupState.value;\n selectedSegments.set(id, !selectedSegments.has(id));\n });\n\n const trackableRGB = new TrackableRGB(vec3.fromValues(0, 0, 0));\n trackableRGB.changed.add(() => {\n const testU = new Uint64(packColor(trackableRGB.value));\n const idString = element.dataset.id!;\n const id = tempObjectId;\n id.tryParseString(idString);\n displayState.segmentStatedColors.value.delete(id);\n displayState.segmentStatedColors.value.set(id, testU);\n });\n\n // TODO, need to register disposer?\n new ColorWidget(\n trackableRGB,\n undefined,\n children[template.colorWidgetIndex] as HTMLInputElement,\n () => {\n const idString = element.dataset.id!;\n const id = tempObjectId;\n id.tryParseString(idString);\n displayState.segmentStatedColors.value.delete(id);\n },\n false,\n );\n };\n}\n\nexport class SegmentWidgetFactory